public void test_XMLNode_convert() { String xmlstr = "<annotation>\n" + " <test xmlns=\"http://test.org/\" id=\"test\">test</test>\n" + "</annotation>"; XMLNode node; XMLNode child, gchild; XMLAttributes attr; XMLNamespaces ns; node = XMLNode.convertStringToXMLNode(xmlstr, null); child = node.getChild(0); gchild = child.getChild(0); attr = child.getAttributes(); ns = child.getNamespaces(); assertTrue(!node.getName().equals("annotation") == false); assertTrue(!child.getName().equals("test") == false); assertTrue(!gchild.getCharacters().equals("test") == false); assertTrue(!attr.getName(0).equals("id") == false); assertTrue(!attr.getValue(0).equals("test") == false); assertTrue(!ns.getURI(0).equals("http://test.org/") == false); assertTrue(ns.getPrefix(0).equals("") == true); String toxmlstring = node.toXMLString(); assertTrue(!toxmlstring.equals(xmlstr) == false); node = null; }
public void test_XMLNode_getters() { XMLToken token; XMLNode node; XMLTriple triple; XMLAttributes attr; XMLNamespaces NS; NS = new XMLNamespaces(); NS.add("http://test1.org/", "test1"); token = new XMLToken("This is a test"); node = new XMLNode(token); assertTrue(node != null); assertTrue(node.getNumChildren() == 0); assertTrue(!node.getCharacters().equals("This is a test") == false); assertTrue(node.getChild(1) != null); attr = new XMLAttributes(); assertTrue(attr != null); attr.add("attr2", "value"); triple = new XMLTriple("attr", "uri", "prefix"); token = new XMLToken(triple, attr); assertTrue(token != null); node = new XMLNode(token); assertTrue(!node.getName().equals("attr") == false); assertTrue(!node.getURI().equals("uri") == false); assertTrue(!node.getPrefix().equals("prefix") == false); XMLAttributes returnattr = node.getAttributes(); assertTrue(!returnattr.getName(0).equals("attr2") == false); assertTrue(!returnattr.getValue(0).equals("value") == false); token = new XMLToken(triple, attr, NS); node = new XMLNode(token); XMLNamespaces returnNS = node.getNamespaces(); assertTrue(returnNS.getLength() == 1); assertTrue(returnNS.isEmpty() == false); triple = null; token = null; node = null; }