public virtual void testUmlaut() { XMLDoc d = new XMLDoc("doc", null); string dirStr = sm_dirTestDataTemp + @"dir\dir%20 Grün€"; DirectoryInfo dir = new DirectoryInfo(dirStr); if (dir.Exists) { dir.Delete(true); } dir.Create(); // get the directory path string without the relative path stuff (i.e. ..\..\) dirStr = dir.FullName; string fStr = dirStr + @"\7€ .xml"; FileInfo f = new FileInfo(fStr); Assert.IsTrue(d.write2File(fStr, 0, true)); Assert.IsTrue(f.Exists); JDFParser p = new JDFParser(); JDFDoc d2 = p.parseFile(fStr); Assert.IsNotNull(d2); Assert.AreEqual("doc", d2.getRoot().LocalName); }
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 testFactory() { string strFile = "bookintent.jdf"; JDFParser p = new JDFParser(); JDFDoc jdfDoc = p.parseFile(sm_dirTestData + strFile); Assert.IsTrue(jdfDoc != null, ""); }
public virtual void testParseSpeed() { JDFParser parser = new JDFParser(); System.GC.Collect(); long l1 = DateTime.Now.Ticks; JDFDoc d = parser.parseFile(sm_dirTestData + "bigWhite.jdf"); Assert.IsNotNull(d); Console.WriteLine("big parse: " + (DateTime.Now.Ticks - l1) / 1000000); }
public virtual void testRoots() { string xmlFile = "job.jdf"; JDFParser p = new JDFParser(); JDFDoc jdfDoc = p.parseFile(sm_dirTestData + xmlFile); Assert.IsTrue(jdfDoc != null, xmlFile + ": Parse Error"); if (jdfDoc == null) { return; // soothe findbugs ;) } Assert.IsNotNull(jdfDoc.getJDFRoot(), "jdf root"); Assert.IsNull(jdfDoc.getJMFRoot(), "no jmf root"); }
public virtual void testIsValid() { DirectoryInfo testData = new DirectoryInfo(sm_dirTestData + "SampleFiles"); Assert.IsTrue(testData.Exists, "testData dir"); FileInfo[] fList = testData.GetFiles(); JDFParser p = new JDFParser(); JDFParser p2 = new JDFParser(); p2.m_SchemaLocation = sm_dirTestSchema + "JDF.xsd"; for (int i = 0; i < fList.Length; i++) { FileInfo file = fList[i]; // skip directories in CVS environments //if (file.isDirectory()) // continue; // skip schema files if (file.FullName.EndsWith(".xsd")) { continue; } Console.WriteLine("Parsing: " + file.FullName); JDFDoc jdfDoc = p.parseFile(file.FullName); Assert.IsTrue(jdfDoc != null, "parse ok"); KElement e = null; if (jdfDoc != null) { e = jdfDoc.getRoot(); Assert.IsTrue(e.isValid(EnumValidationLevel.RecursiveComplete), "valid doc: " + file.FullName); } // now with schema validation jdfDoc = p2.parseFile(file.FullName); Assert.IsTrue(jdfDoc != null, "schema parse ok"); // TODO fix handling of prerelease default attributes if (jdfDoc != null) { e = jdfDoc.getRoot(); Assert.IsTrue(e.isValid(EnumValidationLevel.RecursiveComplete), "valid doc: " + file.FullName); } } }
public virtual void testCorrupt() { JDFDoc doc = null; string foo = "wehflkh"; JDFParser p = new JDFParser(); doc = p.parseString(foo); Assert.IsNull(doc); foo = "<xxx><yyy><zzz></yyy></xxx>"; doc = p.parseString(foo); Assert.IsNull(doc); doc = p.parseFile(sm_dirTestData + "corrupt.jdf"); Assert.IsNull(doc); doc = new JDFDoc("JDF"); Assert.IsNotNull(doc.getNodeName()); }
private void _setUp() { // setup the fixture string xmlFile = "bookintent.jdf"; // test jdf functions // ================== JDFParser p = new JDFParser(); m_jdfDoc = p.parseFile(sm_dirTestData + xmlFile); Assert.IsTrue(m_jdfDoc != null, sm_dirTestData + xmlFile + ": Parse Error"); m_jdfRoot = (JDFNode)m_jdfDoc.getRoot(); m_kElement = m_jdfRoot.getChildByTagName("Dimensions", "", 0, null, false, true); m_jdfElement = (JDFElement)m_kElement; }
public virtual void testParseNoNS() { XMLDoc d = new XMLDoc("TEST", null); string fn = sm_dirTestDataTemp + "testParseNoNS.xml"; d.write2File(fn, 2, true); JDFParser p = new JDFParser(); JDFDoc d2 = p.parseFile(fn); KElement root = d2.getRoot(); // Assert.IsNull(root.getNamespaceURI()); Assert.IsFalse(d2.ToString().IndexOf("xmlns=\"\"") >= 0); Assert.IsFalse(d.ToString().IndexOf("xmlns=\"\"") >= 0); Assert.IsFalse(root.ToString().IndexOf("xmlns=\"\"") >= 0); KElement foo = root.appendElement("foofoo"); Assert.IsNull(foo.getNamespaceURI() == "" ? null : ""); }
public virtual void testRemoveAttributeStringString() { JDFParser p = new JDFParser(); JDFDoc jdfDoc = p.parseFile(sm_dirTestData + "emptyAuthorAttribute.jdf"); JDFElement root = jdfDoc.getJDFRoot(); KElement kElem = root.getChildByTagName("Created", "", 0, null, false, true); bool before = kElem.hasAttribute("Author", "", false); Assert.IsTrue(before, "The Attribute 'Author' does not exist"); if (before) { kElem.removeAttribute("Author", ""); bool after = kElem.hasAttribute("Author", "", false); Assert.IsFalse(after, "The Attribute 'Author' was not removed"); } }
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 } }