public void testXML() throws Exception { QueryElement q1 = new QueryElement("a", "1"); Document doc = XML.createDocument(); Node root = q1.toXML(doc); assertEquals("queryElement", root.getNodeName()); NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node child = children.item(i); if ("tokenRole".equals(child.getNodeName())) { assertEquals("a", XML.text(child)); } else if ("tokenValue".equals(child.getNodeName())) { assertEquals("1", XML.text(child)); } else fail("Unknown node \"" + child.getNodeName() + "\" in XML result"); } QueryElement q2 = new QueryElement(root); assertEquals(q1, q2); }