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 testCreateBig() { for (int ii = 0; ii < 4; ii++) { XMLDoc d = ii % 2 == 0 ? new XMLDoc("foo", null) : new JDFDoc("JDF"); KElement e = d.getRoot(); long l = DateTime.Now.Ticks; for (int j = 0; j < 2000; j++) { KElement e2 = e.appendElement("AuditPool"); KElement e3 = e2.appendElement("Created"); for (int i = 33; i < 199; i++) { if (i < 2) { e3.setAttribute("k" + Convert.ToString(i), "value" + Convert.ToString(i)); } else { e3.setAttributeRaw("k" + Convert.ToString(i), "value" + Convert.ToString(i)); } } } long l2 = DateTime.Now.Ticks; Console.WriteLine("xmldoc create: " + ii + " " + (l2 - l) / 1000000); string fil = sm_dirTestDataTemp + "big" + ii + "writ.jdf"; d.write2File(fil, 2, false); FileInfo f = new FileInfo(fil); long l3 = DateTime.Now.Ticks; Console.WriteLine("xmldoc write: " + ii + " " + (l3 - l2) / 1000000 + " " + f.Length); Console.WriteLine("xmldoc total: " + ii + " " + (l3 - l) / 1000000 + "\n"); } }
public virtual void testSetSchemaLocation() { XMLDoc doc = new XMLDoc("test", null); doc.write2File(sm_dirTestDataTemp + "schematest.xml", 0, false); // create // a // readable // dummy FileInfo schema = new FileInfo(sm_dirTestDataTemp + "schematest.xml"); const string nsURI = "www.foo.com"; doc.setSchemaLocation(nsURI, schema); Assert.IsNotNull(doc.getSchemaLocation(nsURI)); Assert.AreEqual(doc.getSchemaLocationFile(nsURI).FullName, schema.FullName); }
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 testWriteToFileFile() { XMLDoc d = new XMLDoc("doc", null); string dirStr = sm_dirTestDataTemp + @"dir\dir2"; 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 + @"\d%20.xml"; FileInfo f = new FileInfo(fStr); Assert.IsTrue(d.write2File(fStr, 2, true)); Assert.IsTrue(f.Exists); }
public virtual void testWriteToFileThreadWrite() { XMLDoc d = new XMLDoc("doc", null); string @out = sm_dirTestDataTemp + @"\Thread.jdf"; KElement root = d.getRoot(); for (int i = 0; i < 1000; i++) { root.appendElement("elem0").appendElement("elem1").appendElement("elem2").setAttribute("foo", "bar" + i); } MyWriteThread[] mrs = new MyWriteThread[10]; for (int i = 0; i < 10; i++) { MyWriteThread mr = new MyWriteThread(); mr.d = d; mr.iLoop = i; mrs[i] = mr; new Thread(new ThreadStart(mr.Run)).Start(); } Console.WriteLine("Writing start"); Assert.IsTrue(d.write2File(@out, 2, true)); Console.WriteLine("Writing done"); for (int i = 0; i < 10; i++) { if (mrs[i].hook != null) { // Assert.Fail("exception: "+h.e); Console.WriteLine("******** Xerces known defect: not threadsafe: " + mrs[i].hook); } } FileInfo f = new FileInfo(@out); Assert.IsTrue(f.Exists); }
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 } }