Package org.dom4j

Examples of org.dom4j.XPath


    SAXReader xmlReader =  this.getSAXReader();
   
    Document document;
    try {
      document = xmlReader.read(outputXml);
      XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/properties");
      List list = xpath.selectNodes(document);
      assertEquals("Expected to get one properties element", 1, list.size());
      Element node = (Element) list.get(0);
      assertEquals(node.attribute( "name" ).getText(),"emergencyContact");
     
      assertNotNull(findFirstString("name", new File(getOutputDir(), "properties/PPerson.java" )));
View Full Code Here


    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/property");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one property element", 2, list.size());
    Element statusElement = (Element) list.get(0);
    Element nameElement = (Element) list.get(1);
    if(!statusElement.attribute( "name" ).getText().equals("status")) {
      Element temp = nameElement;
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();

    Document document;
    try {
        document = xmlReader.read(outputXml);
        XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/joined-subclass/comment");
        List list = xpath.selectNodes(document);
        assertEquals("Expected to get one comment element", 1, list.size());
      } catch (DocumentException e) {
        fail("Can't parse file " + outputXml.getAbsolutePath());
      }
    }
View Full Code Here

    assertFileAndExists(outputXml);

    SAXReader xmlReader =  this.getSAXReader();

    Document document = xmlReader.read(outputXml);
    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/discriminator");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one discriminator element", 1, list.size());
     
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "type" ).getText(), "string");
View Full Code Here

    }
 
  public void testOneToOne() throws DocumentException {
    Document document = getXMLDocument(getBaseForMappings() + "Person.hbm.xml");   
 
    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/one-to-one");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one-to-one element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "name" ).getText(),"address");
    assertEquals(node.attribute( "constrained" ).getText(),"false");
   
    document = getXMLDocument(getBaseForMappings() + "Address.hbm.xml");
   
    xpath = DocumentHelper.createXPath("//hibernate-mapping/class/one-to-one");
    list = xpath.selectNodes(document);
    assertEquals("Expected to get one set element", 1, list.size());
    node = (Element) list.get(0);
    assertEquals(node.attribute( "name" ).getText(),"person");
    assertEquals(node.attribute( "constrained" ).getText(),"true");
    assertEquals(node.attribute( "access" ).getText(), "field");
View Full Code Here

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/list");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get two list element", 2, list.size());
    Element node = (Element) list.get(1); //second list
    assertEquals("fooComponents", node.attribute( "name" ).getText());
    assertEquals("true", node.attribute( "lazy" ).getText());
    assertEquals("all", node.attribute( "cascade" ).getText());
View Full Code Here

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/array");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one array element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals("proxyArray", node.attribute( "name" ).getText());
    assertEquals("org.hibernate.tool.hbm2x.hbm2hbmxml.GlarchProxy", node.attribute( "element-class" ).getText());
   
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();
   
    Document document = xmlReader.read(outputXml);   
 
    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/meta");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one meta element", 2, list.size());
    Node node = (Node) list.get(0);
    assertEquals(node.getText(),"Basic");
   
    xpath = DocumentHelper.createXPath("//hibernate-mapping/class/id/meta");
    list = xpath.selectNodes(document);
    assertEquals("Expected to get one meta element", 1, list.size());
    node = (Node) list.get(0);
    assertEquals(node.getText(),"basicId")
   
    xpath = DocumentHelper.createXPath("//hibernate-mapping/class/property/meta");
    list = xpath.selectNodes(document);
    assertEquals("Expected to get one meta element", 1, list.size());
    node = (Node) list.get(0);
    assertEquals(node.getText(),"description");
   
    xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/meta");
    list = xpath.selectNodes(document);
    assertEquals("Expected to get one meta element", 1, list.size());
    node = (Node) list.get(0);
    assertEquals(node.getText(),"anotherone");
   
  }
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();
   
    Document document = xmlReader.read(outputXml);   
 
    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one set element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals("delete, update", node.attributeValue("cascade"));
   
  }
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();
   
    Document document = xmlReader.read(new File(getOutputDir(), "hibernate.cfg.xml"));
   
    // Validate the Generator and it has no arguments
    XPath xpath = DocumentHelper.createXPath("//hibernate-configuration/session-factory/mapping");
    Element[] elements = (Element[]) xpath.selectNodes(document).toArray(new Element[0]);
    assertEquals(2,elements.length);
   
    for (int i = 0; i < elements.length; i++) {
      Element element = elements[i];
      assertNotNull(element.attributeValue("resource"));
View Full Code Here

TOP

Related Classes of org.dom4j.XPath

Copyright © 2018 www.massapicom. 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.