Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
 public void testCtor() {
   QueryElement full = new QueryElement("role", "value");
   assertEquals("role", full.getRole());
   assertEquals("value", full.getValue());
 }
Example #4
0
  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());
  }
Example #5
0
 public void testNoArgsCtor() {
   QueryElement blank = new QueryElement();
   assertEquals("UNKNOWN", blank.getRole());
   assertEquals("UNKNOWN", blank.getValue());
 }