Beispiel #1
0
  @Before
  public void clearGrammarCache() {
    LOG.info("Clearing grammar cache");
    ResourceSet results = null;
    try {
      results = executeQuery("validation:clear-grammar-cache()");
      String r = (String) results.getResource(0).getContent();
      System.out.println(r);

    } catch (Exception e) {
      LOG.error(e);
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
Beispiel #2
0
  private void executeAndEvaluate(String query, String expectedValue) {

    LOG.info("Query=" + query);
    LOG.info("ExpectedValue=" + query);

    try {
      ResourceSet results = executeQuery(query);
      assertEquals(1, results.getSize());

      String r = (String) results.getResource(0).getContent();
      LOG.info(r);

      assertXpathEvaluatesTo(expectedValue, "//status/text()", r);

    } catch (Exception ex) {
      LOG.error(ex);
      fail(ex.getMessage());
    }
  }
Beispiel #3
0
  @BeforeClass
  public static void prepareResources() throws Exception {

    // Switch off validation
    Collection conf = createCollection(rootCollection, "system/config/db/parse");
    storeResource(conf, "collection.xconf", noValidation.getBytes());

    // Create filter
    FilenameFilter filter =
        new FilenameFilter() {

          public boolean accept(File dir, String name) {
            return (name.endsWith(".xsd"));
          }
        };

    Collection schemasCollection = createCollection(rootCollection, "parse/schemas");
    File schemas = new File("samples/validation/parse/schemas");

    for (File file : schemas.listFiles(filter)) {
      LOG.info("Storing " + file.getAbsolutePath());
      byte[] data = readFile(schemas, file.getName());
      storeResource(schemasCollection, file.getName(), data);
    }

    File catalog = new File("samples/validation/parse");
    Collection parseCollection = createCollection(rootCollection, "parse");
    byte[] data = readFile(catalog, "catalog.xml");
    storeResource(parseCollection, "catalog.xml", data);

    File instance = new File("samples/validation/parse/instance");
    Collection instanceCollection = createCollection(rootCollection, "parse/instance");

    byte[] valid = readFile(instance, "valid.xml");
    storeResource(instanceCollection, "valid.xml", valid);

    byte[] invalid = readFile(instance, "invalid.xml");
    storeResource(instanceCollection, "invalid.xml", invalid);
  }