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); }
public static void submitMimeToHDM(JDFNode n) { // build SubmitQueueEntry JDFDoc docJMF = new JDFDoc("JMF"); JDFJMF jmf = docJMF.getJMFRoot(); JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry); com.appendQueueSubmissionParams().setURL("dummy"); System.Net.Mail.AttachmentCollection mp = MimeUtil.buildMimePackage(docJMF, n.getOwnerDocument_JDFElement(), true); try { MIMEDetails md = new MIMEDetails(); md.transferEncoding = UrlUtil.BASE64; md.httpDetails.chunkSize = -1; HttpWebRequest response = MimeUtil.writeToURL(mp, "http://192.168.40.71:8889/jmfportal", md); // Java to C# Converstion - What is the ResponseCode for HttpWebRequest? //Assert.AreEqual(200, response.GetResponse().getResponseCode()); MimeUtil.writeToURL(mp, UrlUtil.fileToUrl(new FileInfo("C:\\data\\test.mim"), false), md); } catch (Exception e) { Assert.Fail(e.Message); // fail on exception } }
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)); }
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()); }