public virtual void testForeignRoot() { XMLDoc doc = new XMLDoc("Foo", "fooNS"); KElement r = doc.getRoot(); JDFNode n = new JDFDoc("JDF").getJDFRoot(); r.copyElement(n, null); string s = doc.write2String(0); JDFParser p = new JDFParser(); JDFDoc d = p.parseString(s); Assert.IsNotNull(d.getJDFRoot()); Assert.IsNotNull(d.getRoot()); Assert.AreNotEqual(d.getRoot(), d.getJDFRoot()); }
public virtual void testSize() { Process.GetCurrentProcess(); GC.Collect(); Process.GetCurrentProcess(); GC.Collect(); Process.GetCurrentProcess(); GC.Collect(); XMLDoc d = new XMLDoc("JDF:foo", JDFConstants.JDFNAMESPACE); long memlocal = d.getDocMemoryUsed(); string s = d.write2String(0); Assert.IsTrue(memlocal + 100000 > s.Length, "mem 1"); // the gc is messy and sometimes returns +/- a few 10k Assert.IsTrue(memlocal + 100000 > s.Length, "mem 2"); d = JDFTestCaseBase.creatXMDoc(); memlocal = d.getDocMemoryUsed(); s = d.write2String(0); Assert.IsTrue(memlocal + 10000 > s.Length, "mem 3"); d = new XMLDoc("foo", null); KElement e = d.getRoot(); KElement e2 = e.appendElement("e2"); KElement e3 = e2.appendElement("e3"); for (int i = 33; i < 999; i++) { e3.setAttribute("k" + Convert.ToString(i), "value" + Convert.ToString(i)); } for (int j = 0; j < 99; j++) { e2.copyElement(e3, null); } memlocal = d.getDocMemoryUsed(); s = d.write2String(0); Assert.IsTrue(memlocal + 200000 > s.Length, "mem 4"); }