public void testObjectMethods() { QueryElement q1 = new QueryElement("a", "1"); QueryElement q2 = new QueryElement("a", "1"); QueryElement q3 = new QueryElement("b", "2"); assertEquals(q1, q1); assertEquals(q1, q2); assertTrue(!q1.equals(q3)); QueryElement q4 = (QueryElement) q3.clone(); assertEquals(q3, q4); assertTrue(q3 != q4); }
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); }
public void testCtor() { QueryElement full = new QueryElement("role", "value"); assertEquals("role", full.getRole()); assertEquals("value", full.getValue()); }
public void testSetters() { QueryElement q = new QueryElement("role", "value"); assertEquals("role", q.getRole()); q.setRole("newRole"); assertEquals("newRole", q.getRole()); q.setRole(null); assertEquals("UNKNOWN", q.getRole()); assertEquals("value", q.getValue()); q.setValue("newValue"); assertEquals("newValue", q.getValue()); q.setValue(null); assertEquals("UNKNOWN", q.getValue()); }
public void testNoArgsCtor() { QueryElement blank = new QueryElement(); assertEquals("UNKNOWN", blank.getRole()); assertEquals("UNKNOWN", blank.getValue()); }