Beispiel #1
0
        public virtual void testBuildMimePackageDoc()
        {
            for (int i = 0; i < 2; i++)
            {
                JDFDoc doc = new JDFDoc("JDF");
                if (i == 1)
                {
                    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));
                JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, null, null, null, null);
                rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1);
                rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1);
                rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url2.pdf", false), 0, -1);
                AttachmentCollection m = MimeUtil.buildMimePackage(null, doc, true);

                string mimeFile = sm_dirTestDataTemp + "testMimePackageDoc" + (i == 0 ? "0" : "") + ".mjm";
                MimeUtil.writeToFile(m, mimeFile, null);

                AttachmentCollection mp = MimeUtil.GetMultiPart(mimeFile);
                Assert.AreEqual(4, mp.Count, "JDF, 2* rl, 1 icc");
            }
        }
Beispiel #2
0
        public virtual void testGetMultiPart()
        {
            testBuildMimePackageDocJMF();
            AttachmentCollection mp = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "testMimePackageDoc.mjm");

            MimeUtil.writeToFile(mp, sm_dirTestDataTemp + "testMimePackageDoc_out.mjm", null);
        }
Beispiel #3
0
        public virtual void testBuildMimePackageDocJMF()
        {
            JDFDoc docJMF = new JDFDoc("JMF");

            docJMF.setOriginalFileName("JMF.jmf");
            JDFJMF     jmf = docJMF.getJMFRoot();
            JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("TheJDF");

            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));
            JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, null, null, null, null);

            rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1);
            for (int i = 0; i < 100; i++)
            {
                rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url?.pdf", false), 0, -1);
            }
            AttachmentCollection m = MimeUtil.buildMimePackage(docJMF, doc, true);

            MimeUtil.writeToFile(m, sm_dirTestDataTemp + "testMimePackageDoc.mjm", null);
        }
Beispiel #4
0
        public virtual void testWritePerformance()
        {
            long   start  = JDFDate.ToMillisecs(DateTime.Now);
            string big    = sm_dirTestData + "big.pdf";
            string bigger = sm_dirTestDataTemp + "bigger.pdf";
            JDFDoc docJMF = new JDFDoc("JMF");

            docJMF.setOriginalFileName("JMF.jmf");
            JDFJMF     jmf = docJMF.getJMFRoot();
            JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("TheJDF");
            FileInfo fBigger = new FileInfo(bigger);

            SupportClass.FileSupport.CreateNewFile(fBigger);
            FileStream fis = new FileStream(big, FileMode.Open);
            FileStream fos = new FileStream(bigger, FileMode.Create);

            byte[] b = new byte[10000];
            while (true)
            {
                int i = fis.Read(b, 0, 10000);
                if (i <= 0)
                {
                    break;
                }
                for (int j = 0; j < 3; j++)
                {
                    fos.Write(b, 0, i);
                }
            }
            fis.Close();
            fos.Flush();
            fos.Close();

            JDFDoc doc = new JDFDoc("JDF");

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

            n.setType(EnumType.Interpreting);
            JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, EnumUsage.Input);

            rl.addPDF(StringUtil.uncToUrl(bigger, false), 0, -1);
            long setup = JDFDate.ToMillisecs(DateTime.Now);

            Console.WriteLine("Setup time: " + (setup - start));
            AttachmentCollection m = MimeUtil.buildMimePackage(null, doc, true);
            long build             = JDFDate.ToMillisecs(DateTime.Now);

            Console.WriteLine("Build time: " + (build - setup));
            Assert.IsNotNull(MimeUtil.writeToFile(m, sm_dirTestDataTemp + "performance.mjm", null));
            long write = JDFDate.ToMillisecs(DateTime.Now);

            Console.WriteLine("Write time: " + (write - build));
        }
Beispiel #5
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));
        }
Beispiel #6
0
        public virtual void testWriteToFile()
        {
            testBuildMimePackageDocJMF();

            AttachmentCollection mp = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "testMimePackageDoc.mjm");

            MimeUtil.writeToFile(mp, sm_dirTestDataTemp + "testMimePackageDoc2.mjm", null);
            FileInfo f1 = new FileInfo(sm_dirTestDataTemp + "testMimePackageDoc2.mjm");
            FileInfo f2 = new FileInfo(sm_dirTestDataTemp + "testMimePackageDoc.mjm");

            Assert.IsTrue(f1.Exists);
            Assert.AreEqual(f1.Length, f2.Length, 100);
            AttachmentCollection mp2 = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "testMimePackageDoc2.mjm");

            Assert.IsNotNull(mp2);
            Assert.AreEqual(mp.Count, mp2.Count);
        }
Beispiel #7
0
        public virtual void testGetJMFSubmission()
        {
            JDFDoc d1 = new JDFDoc("JMF");

            d1.setOriginalFileName("JMF.jmf");
            JDFJMF jmf = d1.getJMFRoot();

            jmf.setDeviceID("gr?n?");
            JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("TheJDF");

            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));
            JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, null, null, null, null);

            rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1);
            for (int i = 0; i < 100; i++)
            {
                rl.addPDF("gr?n?" + i + ".pdf", 0, -1);
            }
            AttachmentCollection m = MimeUtil.buildMimePackage(d1, doc, true);

            JDFDoc[] d2 = MimeUtil.GetJMFSubmission(m);
            Assert.IsNotNull(d2);
            Assert.AreEqual("cid:JDF.jdf", d2[0].getJMFRoot().getCommand(0).getQueueSubmissionParams(0).getURL());
            Assert.AreEqual(EnumType.ColorSpaceConversion, d2[1].getJDFRoot().getEnumType());

            // now serialize to file and reread - should still work
            MimeUtil.writeToFile(m, sm_dirTestDataTemp + "test2.mjm", null);
            AttachmentCollection m2 = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "test2.mjm");

            Assert.IsNotNull(m2);
            d2 = MimeUtil.GetJMFSubmission(m);
            Assert.IsNotNull(d2);
            Assert.AreEqual("cid:JDF.jdf", d2[0].getJMFRoot().getCommand(0).getQueueSubmissionParams(0).getURL());
            Assert.AreEqual(EnumType.ColorSpaceConversion, d2[1].getJDFRoot().getEnumType());
        }
Beispiel #8
0
        public virtual void testUpdateXMLMultipart()
        {
            AttachmentCollection multipart = null;
            JDFDoc jDoc = new JDFDoc("JMF");

            MimeUtil.updateXMLMultipart(multipart, jDoc, null);
            string mimeFile = sm_dirTestDataTemp + "testUpdateXML";

            MimeUtil.writeToFile(multipart, mimeFile + "0.mjm", null);
            AttachmentCollection multiparsed = MimeUtil.GetMultiPart(mimeFile + "0.mjm");
            Attachment           bp          = multiparsed[0];

            Assert.IsTrue(bp.ContentId.Length > 5, "cid >cid_");

            JDFDoc jDoc1 = new JDFDoc("JDF");

            jDoc1.setOriginalFileName("jdf1.jdf");

            MimeUtil.updateXMLMultipart(multipart, jDoc1, null);

            MimeUtil.writeToFile(multipart, mimeFile + "1.mjm", null);
            multiparsed = MimeUtil.GetMultiPart(mimeFile + "1.mjm");
            bp          = multiparsed[0];
            Assert.IsTrue(bp.ContentId.Length > 5, "cid >cid_");

            JDFDoc jDoc2 = new JDFDoc("JDF");

            jDoc2.setOriginalFileName("jdf1.jdf");
            jDoc2.getJDFRoot().setDescriptiveName("updated jdf");
            MimeUtil.updateXMLMultipart(multipart, jDoc2, "jdf1.jdf");
            MimeUtil.writeToFile(multipart, mimeFile + "2.mjm", null);

            AttachmentCollection multipart3 = MimeUtil.GetMultiPart(mimeFile + "2.mjm");

            jDoc2.getJDFRoot().setDescriptiveName("3rd jdf");
            MimeUtil.updateXMLMultipart(multipart3, jDoc2, "jdf2.jdf");
            MimeUtil.writeToFile(multipart3, mimeFile + "3.mjm", null);
        }
Beispiel #9
0
        public virtual void testBuildMimePackage()
        {
            JDFDoc d1 = new JDFDoc("JMF");

            d1.setOriginalFileName("JMF.jmf");
            JDFDoc d2 = new JDFDoc("JDF");

            d2.setOriginalFileName("JDF.jdf");
            ArrayList vXMLDocs = new ArrayList();

            vXMLDocs.Add(d1);
            vXMLDocs.Add(d2);

            AttachmentCollection m    = MimeUtil.buildMimePackage(vXMLDocs);
            FileInfo             file = MimeUtil.writeToFile(m, sm_dirTestDataTemp + "test.mjm", null);

            AttachmentCollection aBp = MimeUtil.GetMultiPart(file.FullName);

            Assert.AreEqual(2, aBp.Count);

            Assert.AreEqual("JMF.jmf", aBp[0].Name);
            Assert.AreEqual("JDF.jdf", aBp[1].Name);
        }
Beispiel #10
0
        public virtual void testWriteToFileMimeDetails()
        {
            testBuildMimePackageDocJMF();

            MIMEDetails md = new MIMEDetails();

            md.modifyBoundarySemicolon = true;
            AttachmentCollection mp = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "testMimePackageDoc.mjm");

            MimeUtil.writeToFile(mp, sm_dirTestDataTemp + "testMimePackageDoc2.mjm", md);
            FileInfo f2 = new FileInfo(sm_dirTestDataTemp + "testMimePackageDoc2.mjm");
            FileInfo f1 = new FileInfo(sm_dirTestDataTemp + "testMimePackageDoc.mjm");

            Assert.IsTrue(f2.Exists);
            Assert.AreEqual(f1.Length, f2.Length, 100);
            AttachmentCollection mp2 = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "testMimePackageDoc2.mjm");

            Assert.IsNotNull(mp2);
            Assert.AreEqual(mp.Count, mp2.Count);
            MemoryStream sw = new MemoryStream();

            IOUtils.CopyStream(new FileStream(f2.FullName, FileMode.Open), sw);
            Assert.AreEqual(-1, sw.ToString().IndexOf("related;"));
        }