public virtual void testFormat() { JDFDoc doc = new JDFDoc(ElementName.JDF); JDFNode root = doc.getJDFRoot(); JDFComment c11 = root.appendComment(); string txt = "This element should have no ID attribute and is a rellly long line with many many characters.. asfihAFLKFKJGFaufksgUFGagfAFKJSG"; txt += txt; txt += txt; // even longer... c11.setText(txt); JDFComment c21 = root.appendComment(); const string txt2 = "This element \n has \n crlf"; c21.setText(txt2); Assert.AreEqual(txt, c11.getText(), "text is equal in DOM"); Assert.AreEqual(txt2, c21.getText(), "text is equal in DOM"); string commentFile = sm_dirTestDataTemp + @"\CommentTest.JDF"; doc.write2File(commentFile, 2, true); JDFParser p = new JDFParser(); JDFDoc doc2 = p.parseFile(commentFile); JDFNode root2 = doc2.getJDFRoot(); JDFComment c12 = root2.getComment(0); JDFComment c22 = root2.getComment(1); Assert.AreEqual(txt, c12.getText(), "text is equal after parse"); Assert.AreEqual(txt2, c22.getText(), "text is equal after parse"); }
public virtual void testWorkstepID() { JDFDoc d = new JDFDoc(ElementName.JDF); JDFNode n = d.getJDFRoot(); n.setType("ConventionalPrinting", true); JDFNodeInfo.setDefaultWorkStepID(true); JDFNodeInfo ni = n.getCreateNodeInfo(); Assert.IsTrue(ni.hasAttribute("WorkStepID")); JDFAttributeMap map = new JDFAttributeMap(EnumPartIDKey.Separation, "Cyan"); n.setPartStatus(map, EnumNodeStatus.Ready, null); JDFNodeInfo niPart = (JDFNodeInfo)ni.getPartition(map, null); Assert.IsNotNull(niPart); Assert.IsTrue(niPart.hasAttribute("WorkStepID")); d.write2File(sm_dirTestDataTemp + "workstepidtest.jdf", 2, false); // VString v = ni.getInvalidAttributes(EnumValidationLevel.Incomplete, true, -1); Assert.IsTrue(ni.isValid(EnumValidationLevel.Incomplete)); }
public virtual void testDirtyIDs() { // -i bookintent.jdf -o spawned.jdf -p 4 string xmlFile = "bookintent.jdf"; string outFile = "spawned.jdf"; string strPartID = "4"; JDFParser p = new JDFParser(); JDFDoc jdfDocIn = p.parseFile(sm_dirTestData + xmlFile); Assert.IsTrue(jdfDocIn != null); if (jdfDocIn == null) { return; // soothe findbugs ;) } XMLDocUserData xmlUserData = jdfDocIn.getCreateXMLDocUserData(); xmlUserData.setDirtyPolicy(XMLDocUserData.EnumDirtyPolicy.ID); JDFNode rootIn = (JDFNode)jdfDocIn.getRoot(); JDFNode nodeToSpawn; if (strPartID.Equals("")) { nodeToSpawn = rootIn; } else { nodeToSpawn = rootIn.getJobPart(strPartID, ""); } if (nodeToSpawn == null) { Assert.Fail("No such JobPartID: " + strPartID); } else { ArrayList vRWResources = new ArrayList(); vRWResources.Add("Component"); vRWResources.Add("RunList"); VJDFAttributeMap vSpawnParts = new VJDFAttributeMap(); JDFSpawn spawn = new JDFSpawn(nodeToSpawn); JDFNode node = spawn.spawn(xmlFile, outFile, vRWResources, vSpawnParts, false, false, false, false); // neu gespawntes FileInfo rausschreiben JDFNode rootOut = node; XMLDoc docOut = rootOut.getOwnerDocument_KElement(); docOut.write2File(sm_dirTestDataTemp + outFile, 0, true); // verändertes Ausgangsfile rausschreiben string strOutXMLFile = "_" + xmlFile; rootIn.eraseEmptyNodes(true); jdfDocIn.write2File(sm_dirTestDataTemp + strOutXMLFile, 0, true); Assert.IsTrue(true, "SpawnJDF ok"); // test, if all changed nodes are in our list // Java to C# Conversion - Java version indicated there should be 5 Dirty IDs, but it only checks for 4. // C# version returns 4 Dirty IDs. Set it to 4 for now. VString vstrDirtyIDs = jdfDocIn.getDirtyIDs(); Assert.AreEqual(4, vstrDirtyIDs.Count); Assert.IsTrue(vstrDirtyIDs.Contains("n0014")); // audit pool was added Assert.IsTrue(vstrDirtyIDs.Contains("n0016")); // status changed: // waiting --> spawned Assert.IsTrue(vstrDirtyIDs.Contains("r0017")); //SpawnStatus="SpawnedRW" // added Assert.IsTrue(vstrDirtyIDs.Contains("r0018")); // SizeIntent added } }