Package org.dom4j

Examples of org.dom4j.Element.selectSingleNode()


    Element rootElement = document.getRootElement();

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_1']");
    Node value2 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_2']");
    assertEquals("Label: VALUE_1", rootElement.selectSingleNode("//label[@for = '" + value1.valueOf("@id") + "']").getText());
    assertEquals("Label: VALUE_2", rootElement.selectSingleNode("//label[@for = '" + value2.valueOf("@id") + "']").getText());
    assertEquals(value2, rootElement.selectSingleNode("//input[@checked]"));
  }

  public void testWithNullValue() throws Exception {
View Full Code Here


    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_1']");
    Node value2 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_2']");
    assertEquals("Label: VALUE_1", rootElement.selectSingleNode("//label[@for = '" + value1.valueOf("@id") + "']").getText());
    assertEquals("Label: VALUE_2", rootElement.selectSingleNode("//label[@for = '" + value2.valueOf("@id") + "']").getText());
    assertEquals(value2, rootElement.selectSingleNode("//input[@checked]"));
  }

  public void testWithNullValue() throws Exception {
    try {
View Full Code Here

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_1']");
    Node value2 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_2']");
    assertEquals("Label: VALUE_1", rootElement.selectSingleNode("//label[@for = '" + value1.valueOf("@id") + "']").getText());
    assertEquals("Label: VALUE_2", rootElement.selectSingleNode("//label[@for = '" + value2.valueOf("@id") + "']").getText());
    assertEquals(value2, rootElement.selectSingleNode("//input[@checked]"));
  }

  public void testWithNullValue() throws Exception {
    try {
      this.tag.setPath("name");
View Full Code Here

    SAXReader reader = new SAXReader();
    Document document = reader.read(new StringReader(output));
    Element rootElement = document.getRootElement();

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("option[@value = 'VALUE_1']");
    Node value2 = rootElement.selectSingleNode("option[@value = 'VALUE_2']");
    assertEquals("TestEnum: VALUE_1", value1.getText());
    assertEquals("TestEnum: VALUE_2", value2.getText());
    assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
  }
View Full Code Here

    Document document = reader.read(new StringReader(output));
    Element rootElement = document.getRootElement();

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("option[@value = 'VALUE_1']");
    Node value2 = rootElement.selectSingleNode("option[@value = 'VALUE_2']");
    assertEquals("TestEnum: VALUE_1", value1.getText());
    assertEquals("TestEnum: VALUE_2", value2.getText());
    assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
  }
View Full Code Here

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("option[@value = 'VALUE_1']");
    Node value2 = rootElement.selectSingleNode("option[@value = 'VALUE_2']");
    assertEquals("TestEnum: VALUE_1", value1.getText());
    assertEquals("TestEnum: VALUE_2", value2.getText());
    assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
  }

  public void testWithoutItemsEnumParentWithExplicitLabelsAndValues() throws Exception {
    BeanWithEnum testBean = new BeanWithEnum();
    testBean.setTestEnum(TestEnum.VALUE_2);
View Full Code Here

    SAXReader reader = new SAXReader();
    Document document = reader.read(new StringReader(output));
    Element rootElement = document.getRootElement();

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_1']");
    Node value2 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_2']");
    assertEquals("Label: VALUE_1", value1.getText());
    assertEquals("Label: VALUE_2", value2.getText());
    assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
  }
View Full Code Here

    Document document = reader.read(new StringReader(output));
    Element rootElement = document.getRootElement();

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_1']");
    Node value2 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_2']");
    assertEquals("Label: VALUE_1", value1.getText());
    assertEquals("Label: VALUE_2", value2.getText());
    assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
  }
View Full Code Here

    assertEquals(2, rootElement.elements().size());
    Node value1 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_1']");
    Node value2 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_2']");
    assertEquals("Label: VALUE_1", value1.getText());
    assertEquals("Label: VALUE_2", value2.getText());
    assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
  }

  @Override
  protected void extendRequest(MockHttpServletRequest request) {
    TestBean bean = new TestBean();
View Full Code Here

            assertNotNull(d);
            final Element root = d.getRootElement();
            assertEquals("project", root.getName());
            assertEquals(1, root.selectNodes("/project/*").size());
            assertEquals(1, root.selectNodes("node").size());
            assertEquals("test1name", root.selectSingleNode("node/@name").getStringValue());
            assertEquals("test1", root.selectSingleNode("node/@hostname").getStringValue());
            assertEquals("", root.selectSingleNode("node/@tags").getStringValue());
            assertEquals("", root.selectSingleNode("node/@description").getStringValue());
            assertEquals("", root.selectSingleNode("node/@osArch").getStringValue());
            assertEquals("", root.selectSingleNode("node/@osFamily").getStringValue());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.