Package org.dom4j

Examples of org.dom4j.XPath


    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];
      assertNull(element.attributeValue("resource"));
View Full Code Here


   
    SAXReader xmlReader =  this.getSAXReader();
   
    Document document = xmlReader.read(new File(getOutputDir(), "org/hibernate/tool/hbm2x/Product.hbm.xml"));
   
    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/version");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one version element", 1, list.size());     
  }
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();
   
    Document document;
    try {
      document = xmlReader.read(outputXml);
      XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/idbag");
      List list = xpath.selectNodes(document);
      assertEquals("Expected to get one idbag element", 1, list.size());
      Element node = (Element) list.get(0);
      assertEquals(node.attribute( "table" ).getText(),"`UserGroups`");
      assertEquals(node.attribute( "name" ).getText(),"groups");
      assertEquals(node.attribute( "lazy" ).getText(),"false");
View Full Code Here

    File outputXml = new File(getOutputDir(),  getBaseForMappings() + "User2.hbm.xml");
    SAXReader xmlReader =  this.getSAXReader();
   
    Document document = xmlReader.read(outputXml)
   
    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/idbag/collection-id");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one collection-id element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "column" ).getText(),"userGroupId");
    assertEquals(node.attribute( "type" ).getText(),"long");
 
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();

    Document document;
    try {
        document = xmlReader.read(outputXml);
        XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class");
        List list = xpath.selectNodes(document);
        assertEquals("Expected to get one class element", 1, list.size());
        Element node = (Element) list.get(0);
        assertNotNull("Abstract attrinute was not exported.", node.attribute( "abstract" ));
        assertEquals(node.attribute( "abstract" ).getText(),"true");
      } catch (DocumentException e) {
View Full Code Here

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

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

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/dynamic-component");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one dynamic-component element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "name" ).getText(),"dynaBean");

  }
View Full Code Here

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/list");
    Element node = (Element) xpath.selectNodes(document).get(1); //second list
    List list = node.elements("composite-element");
    assertEquals("Expected to get one composite-element element", 1, list.size());
    node = (Element) list.get(0);
    assertEquals("Expected to get two property element", 2, node.elements("property").size());
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/many-to-many");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one many-to-many element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "entity-name" ).getText(),"org.hibernate.tool.hbm2x.hbm2hbmxml.Group");


    xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set");
    list = xpath.selectNodes(document);
    assertEquals("Expected to get one set element", 1, list.size());
    node = (Element) list.get(0);
    assertEquals(node.attribute( "table" ).getText(),"UserGroup");

View Full Code Here

        File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Group.hbm.xml");
         SAXReader xmlReader =  this.getSAXReader();

        Document document = xmlReader.read(outputXml);

        XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class");
         List list = xpath.selectNodes(document);
        assertEquals("Expected to get one class element", 1, list.size());
         Element node = (Element) list.get(0);

        assertEquals(node.attribute( "table" ).getText(),"`Group`");

        xpath = DocumentHelper.createXPath("//hibernate-mapping/class/composite-id");
        list = xpath.selectNodes(document);
        assertEquals("Expected to get one composite-id element", 1, list.size());


        xpath = DocumentHelper.createXPath("//hibernate-mapping/class/composite-id/key-property");
         list = xpath.selectNodes(document);
        assertEquals("Expected to get two key-property elements", 2, list.size());
         node = (Element) list.get(0);
        assertEquals(node.attribute( "name" ).getText(),"name");
        node = (Element) list.get(1);
        assertEquals(node.attribute( "name" ).getText(),"org");
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.