Exemple #1
0
        public virtual void testReplaceContents()
        {
            JDFDoc doc = new JDFDoc("JDF");

            doc.setOriginalFileName("JDF.jdf");
            JDFNode n = doc.getJDFRoot();

            n.setType(EnumType.ColorSpaceConversion);
            JDFColorSpaceConversionParams cscp = (JDFColorSpaceConversionParams)n.addResource(ElementName.COLORSPACECONVERSIONPARAMS, null, EnumUsage.Input, null, null, null, null);
            JDFFileSpec fs0 = cscp.appendFinalTargetDevice();

            fs0.setURL(StringUtil.uncToUrl(sm_dirTestData + "test.icc", true));
            AttachmentCollection mp = MimeUtil.buildMimePackage(null, doc, true);

            Assert.AreEqual(2, mp.Count, "JDF,  1 icc");

            Attachment bp = mp[1];

            Assert.IsNotNull(bp);
            MimeUtil.SetAttachmentContent(bp, "hello World");

            Attachment bp2 = mp[1];

            Assert.AreEqual("hello World", MimeUtil.GetAttachmentContent(bp2));

            string mimeFile = sm_dirTestDataTemp + "testReplaceContents";

            MimeUtil.writeToFile(mp, mimeFile + ".mjm", null);

            AttachmentCollection mp2  = MimeUtil.GetMultiPart(mimeFile + ".mjm");
            Attachment           bp21 = mp2[1];

            Assert.AreEqual("hello World", MimeUtil.GetAttachmentContent(bp21));

            Attachment bp22 = mp2[1];

            Assert.IsNotNull(bp22);
            MimeUtil.SetAttachmentContent(bp22, "bye World");
            Assert.AreEqual("bye World", MimeUtil.GetAttachmentContent(bp22));
            Attachment bp23 = mp2[1];

            Assert.AreEqual(bp22, bp23);

            MimeUtil.writeToFile(mp2, mimeFile + "_1.mjm", null);
            AttachmentCollection mp3  = MimeUtil.GetMultiPart(mimeFile + "_1.mjm");
            Attachment           bp31 = mp3[1];

            Assert.AreEqual("bye World", MimeUtil.GetAttachmentContent(bp31));
        }
Exemple #2
0
        public virtual void testGetCreatePartByCID()
        {
            AttachmentCollection multipart = null;

            Attachment bp = MimeUtil.GetCreatePartByCID(multipart, "cid1");

            MimeUtil.SetAttachmentContent(bp, "boo");
            Attachment bp2 = MimeUtil.GetCreatePartByCID(multipart, "cid2");

            MimeUtil.SetAttachmentContent(bp2, "bar");
            Attachment bp3 = MimeUtil.GetCreatePartByCID(multipart, "cid1");

            Assert.AreEqual(bp, bp3);
            Assert.AreEqual(2, multipart.Count);
            Assert.AreEqual("boo", MimeUtil.GetAttachmentContent(bp3));
        }