Beispiel #1
0
        public virtual void testResolveRelativeUrls()
        {
            // Build MIME package
            string path   = sm_dirTestData + "MISPrepress-ICS-Complex.jdf";
            JDFDoc jdfDoc = new JDFParser().parseFile(path);

            Assert.IsNotNull(jdfDoc, "Could not parse JDF: " + path);
            AttachmentCollection multipart = MimeUtil.buildMimePackage(null, jdfDoc, true);

            Assert.IsNotNull(multipart, "Could not build multipart");
            // Verify contents
            Assert.AreEqual(3, multipart.Count);
            JDFDoc jdfDoc2 = MimeUtil.getJDFDoc(multipart[0]);

            Assert.IsNotNull(jdfDoc2);
            JDFNode jdf = jdfDoc2.getJDFRoot();

            Assert.IsNotNull(jdf);
            VElement fileSpecs = jdf.getChildrenByTagName(ElementName.FILESPEC, null, new JDFAttributeMap(AttributeName.URL, "*"), false, false, 0);

            Assert.AreEqual(3, fileSpecs.Count);
            for (IEnumerator i = fileSpecs.GetEnumerator(); i.MoveNext();)
            {
                JDFFileSpec fileSpec = (JDFFileSpec)i.Current;
                string      cid      = fileSpec.getURL();
                Assert.IsTrue(cid.StartsWith("cid:"));
                Assert.IsNotNull(MimeUtil.GetPartByCID(multipart, cid));
            }
        }
Beispiel #2
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 #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 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 #7
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);
        }