Examples of XPathGetter


Examples of ch.inftec.ju.util.xml.XPathGetter

    DbDataUtil du = new DbDataUtil(this.em);
    Document doc = du.buildExport()
      .addTablesByDataSet(JuUrl.resource("ch/inftec/ju/testing/db/DbDataUtilTest_testingEntity.xml"), false)
      .writeToXmlDocument();
   
    XPathGetter xg = new XPathGetter(doc);
    logger.debug("Exported XML\n" + XmlUtils.toString(doc, false, true));
   
    Assert.assertEquals(1, xg.getArray("//TestingEntity").length);
    Assert.assertEquals("Export Test", xg.getSingle("//TestingEntity/@name"));
  }
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

    // Export table with camel case
    Document doc = du.buildExport()
      .addTableSorted("TestingEntity")
      .writeToXmlDocument();
   
    XPathGetter xg = new XPathGetter(doc);
    logger.debug("Exported XML\n" + XmlUtils.toString(doc, false, true));
   
    Assert.assertEquals(3, xg.getArray("//TestingEntity").length);
    Assert.assertEquals("1", xg.getSingle("//TestingEntity[1]/@id"));
    Assert.assertEquals("2", xg.getSingle("//TestingEntity[2]/@id"));
    Assert.assertEquals("3", xg.getSingle("//TestingEntity[3]/@id"));
  }
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

    // Export table with camel case
    Document doc = du.buildExport()
      .addTablesByDataSet(JuUrl.resource("ch/inftec/ju/testing/db/DbDataUtilTest_testingEntity.xml"), true)
      .writeToXmlDocument();
   
    XPathGetter xg = new XPathGetter(doc);
    logger.debug("Exported XML\n" + XmlUtils.toString(doc, false, true));
   
    Assert.assertEquals(3, xg.getArray("//TestingEntity").length);
    Assert.assertEquals("1", xg.getSingle("//TestingEntity[1]/@id"));
    Assert.assertEquals("2", xg.getSingle("//TestingEntity[2]/@id"));
    Assert.assertEquals("3", xg.getSingle("//TestingEntity[3]/@id"));
  }
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

  }

  @Test
  public void testGreetingWithoutPom() throws Exception {
    // lookupMojo needs the actual version as it seems to use the Maven local repo to lookup stuff...
    String version = new XPathGetter(XmlUtils.loadXml(JuUrl.toUrl(JuUrl.existingFile("pom.xml")))).getSingle("project/parent/version");
   
    // Default value setting will not work when using explicit (or no) PlexusConfiguration
    PlexusConfiguration config = new DefaultPlexusConfiguration("configuration");
    config.addChild("greeting", "NoPomWorld");
    GreetMojo greetMojo = (GreetMojo) this.lookupMojo("ch.inftec.ju", "ju-maven-plugin", version, "greet", config);
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

     * @param resourcePath Resource path to dataset XML
     * @return ExportBuilder to allow for chaining
     */
    public ExportBuilder setTableNamesCasingByDataSet(String resourcePath) {
      try {
        this.exportItems.setCasedTableNames(new XPathGetter(XmlUtils.loadXml(
            JuUrl.resource().relativeTo(DbDataUtil.class).get(resourcePath))).getNodeNames("dataset/*"));
      } catch (Exception ex) {
        throw new JuDbException("Couldn't load table names data set " + resourcePath, ex);
      }
      return this;
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

     * @param sortedByPrimaryKey If true, the entries will be sorted by primary key
     * @return ExportBuilder to allow for chaining
     */
    public ExportBuilder addTablesByDataSet(URL resourceUrl, boolean sortedByPrimaryKey) {
      try {
        Set<String> tableNames = JuCollectionUtils.asSameOrderSet(new XPathGetter(XmlUtils.loadXml(resourceUrl)).getNodeNames("dataset/*"));
        for (String tableName : tableNames) {
          if (sortedByPrimaryKey) {
            this.addTableSorted(tableName);
          } else {
            this.addTable(tableName);
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

   */
  public final void init(EntityManager em, Document doc) {
    this.em = em;
    this.emUtil = new JuEmUtil(em);
   
    if (doc != null) this.xg = new XPathGetter(doc);
  }
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

      URL persistenceXmlUrl = DbConnectionFactoryLoader.class.getResource(resourceXmlPath);
     
      DbConnectionFactoryImpl factory = new DbConnectionFactoryImpl(resourceXmlPath);
     
      Document doc = XmlUtils.loadXml(persistenceXmlUrl, null);
      XPathGetter xg = new XPathGetter(doc);
     
      for (XPathGetter xgConn : xg.getGetters("persistence/persistence-unit")) {
        String name = xgConn.getSingle("@name");
        String flagString = xgConn.getSingle("properties/property[@name='ch.inftec.ju.flags']/@value");
        String schemaName = xgConn.getSingle("properties/property[@name='ch.inftec.ju.schemaName']/@value");
       
        String flags[] = flagString != null
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

    // Whole table to XML Document
    Document doc = this.createDbDataUtil().buildExport()
      .addTable("Team", null)
      .writeToXmlDocument();
   
    XPathGetter xg = new XPathGetter(doc);
    Assert.assertEquals(2, xg.getSingleLong("count(//Team)").intValue());
  }
View Full Code Here

Examples of ch.inftec.ju.util.xml.XPathGetter

   
    Document doc = this.createDbDataUtil().buildExport()
      .addTable("TestingEntity", "SELECT * FROM TESTINGENTITY WHERE ID=2")
      .writeToXmlDocument();
   
    XPathGetter xg = new XPathGetter(doc);
    Assert.assertEquals(1, xg.getSingleLong("count(//TestingEntity)").intValue());
    Assert.assertEquals(2, xg.getSingleLong("//TestingEntity/@id").intValue());
  }
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.