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"); } }
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 virtual void testDevice() { JDFDoc d = new JDFDoc(ElementName.JDF); JDFNode n = d.getJDFRoot(); n.setType("Stitching", true); JDFDevice dev = (JDFDevice)n.appendMatchingResource(ElementName.DEVICE, EnumProcessUsage.AnyInput, null); dev.setResStatus(EnumResStatus.Available, true); dev.setKnownLocalizations(new VString("De", null)); dev.setSerialNumber("12345"); dev.setSecureJMFURL("http://fififi"); JDFModule m = dev.appendModule(); // m.setModuleIndex(0); m.setModelDescription("1234"); JDFIconList il = dev.appendIconList(); Assert.IsFalse(il.isValid(EnumValidationLevel.Complete), "empty iconlist"); Assert.IsTrue(il.isValid(EnumValidationLevel.Incomplete), "empty iconlist"); JDFIcon ic = il.appendIcon(); ic.setSize(new JDFXYPair(200, 200)); ic.setBitDepth(8); JDFFileSpec fs = ic.appendFileSpec(); fs.setURL("file:///this.ico"); Assert.IsTrue(ic.isValid(EnumValidationLevel.Complete), "icon valid"); Assert.IsTrue(il.isValid(EnumValidationLevel.Complete), "iconlist valid"); Assert.IsTrue(m.isValid(EnumValidationLevel.Complete), "mod valid"); Assert.IsTrue(dev.isValid(EnumValidationLevel.Complete), "dev valid"); Assert.IsTrue(dev.validClass()); }
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)); }
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()); }
public void testAmpersand() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType("Interpreting", true); JDFFileSpec fs = (JDFFileSpec)n.addResource(ElementName.FILESPEC, null, EnumUsage.Input, null, null, null, null); string url = "FileInfo:///a&b.pdf"; fs.setURL(url); string s = d.write2String(2); JDFParser p = new JDFParser(); JDFDoc dNew = p.parseString(s); string newUrl = ((JDFFileSpec)dNew.getJDFRoot().getResourcePool().getElement(ElementName.FILESPEC, null, 0)).getURL(); Assert.AreEqual(newUrl, url, "url=url"); }
public virtual void testGetMimeURL() { JDFDoc d1 = new JDFDoc("JMF"); d1.setOriginalFileName("JMF.jmf"); JDFJMF jmf = d1.getJMFRoot(); JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry); com.appendQueueSubmissionParams().setURL("cid:TheJDF"); JDFDoc doc = new JDFDoc("JDF"); doc.setOriginalFileName("JDF.jdf"); JDFNode n = doc.getJDFRoot(); n.setType(JDFNode.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); System.Net.Mail.AttachmentCollection m = MimeUtil.buildMimePackage(d1, doc, true); JDFDoc[] d2 = MimeUtil.GetJMFSubmission(m); Assert.IsNotNull(d2); JDFQueueSubmissionParams queueSubmissionParams = d2[0].getJMFRoot().getCommand(0).getQueueSubmissionParams(0); Assert.AreEqual("cid:JDF.jdf", queueSubmissionParams.getURL()); Assert.AreEqual(JDFNode.EnumType.ColorSpaceConversion, d2[1].getJDFRoot().getEnumType()); JDFDoc d3 = queueSubmissionParams.getURLDoc(); Assert.IsNotNull(d3); Assert.AreEqual(JDFNode.EnumType.ColorSpaceConversion, d3.getJDFRoot().getEnumType()); }