@Override
  protected void parseArguments(final String[] args) throws IOException {
    final Args arg = new Args(args, this, SERVERINFO, Util.info(CONSOLE, SERVERMODE));

    commands = new StringList();
    boolean daemon = false;
    while (arg.more()) {
      if (arg.dash()) {
        switch (arg.next()) {
          case 'c': // send database commands
            commands.add(arg.string());
            break;
          case 'd': // activate debug mode
            context.mprop.set(MainProp.DEBUG, true);
            break;
          case 'D': // hidden flag: daemon mode
            daemon = true;
            break;
          case 'e': // parse event port
            context.mprop.set(MainProp.EVENTPORT, arg.number());
            break;
          case 'i': // activate interactive mode
            console = true;
            break;
          case 'p': // parse server port
            context.mprop.set(MainProp.SERVERPORT, arg.number());
            break;
          case 'S': // set service flag
            service = !daemon;
            break;
          case 'z': // suppress logging
            quiet = true;
            break;
          default:
            arg.usage();
        }
      } else {
        if (arg.string().equalsIgnoreCase("stop")) {
          stopped = true;
        } else {
          arg.usage();
        }
      }
    }
  }
Exemple #2
0
  /**
   * Runs the test suite.
   *
   * @param args command-line arguments
   * @throws Exception exception
   */
  void run(final String[] args) throws Exception {
    final Args arg =
        new Args(
            args,
            this,
            " Test Suite [options] [pat]"
                + NL
                + " [pat] perform only tests with the specified pattern"
                + NL
                + " -c     print compilation steps"
                + NL
                + " -h     show this help"
                + NL
                + " -m     minimum conformance"
                + NL
                + " -g     <test-group> test group to test"
                + NL
                + " -C     run tests depending on current time"
                + NL
                + " -p     change path"
                + NL
                + " -r     create report"
                + NL
                + " -t[ms] list slowest queries"
                + NL
                + " -v     verbose output");

    while (arg.more()) {
      if (arg.dash()) {
        final char c = arg.next();
        if (c == 'r') {
          reporting = true;
          currTime = true;
        } else if (c == 'C') {
          currTime = true;
        } else if (c == 'c') {
          compile = true;
        } else if (c == 'm') {
          minimum = true;
        } else if (c == 'g') {
          group = arg.string();
        } else if (c == 'p') {
          path = arg.string() + "/";
        } else if (c == 't') {
          timer = arg.num();
        } else if (c == 'v') {
          verbose = true;
        } else {
          arg.check(false);
        }
      } else {
        single = arg.string();
        maxout = Integer.MAX_VALUE;
      }
    }
    if (!arg.finish()) return;

    queries = path + "Queries/XQuery/";
    expected = path + "ExpectedTestResults/";
    results = path + "ReportingResults/Results/";
    report = path + "ReportingResults/";
    sources = path + "TestSources/";

    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    final String dat = sdf.format(Calendar.getInstance().getTime());

    final Performance perf = new Performance();
    context.prop.set(Prop.CHOP, false);

    // new Check(path + input).execute(context);
    data = CreateDB.xml(new IOFile(path + input), context);

    final Nodes root = new Nodes(0, data);
    Util.outln(NL + Util.name(this) + " Test Suite " + text("/*:test-suite/@version", root));

    Util.outln(NL + "Caching Sources...");
    for (final int s : nodes("//*:source", root).list) {
      final Nodes srcRoot = new Nodes(s, data);
      final String val = (path + text("@FileName", srcRoot)).replace('\\', '/');
      srcs.put(text("@ID", srcRoot), val);
    }

    Util.outln("Caching Modules...");
    for (final int s : nodes("//*:module", root).list) {
      final Nodes srcRoot = new Nodes(s, data);
      final String val = (path + text("@FileName", srcRoot)).replace('\\', '/');
      mods.put(text("@ID", srcRoot), val);
    }

    Util.outln("Caching Collections...");
    for (final int c : nodes("//*:collection", root).list) {
      final Nodes nodes = new Nodes(c, data);
      final String cname = text("@ID", nodes);

      final TokenList dl = new TokenList();
      final Nodes doc = nodes("*:input-document", nodes);
      for (int d = 0; d < doc.size(); ++d) {
        dl.add(token(sources + string(data.atom(doc.list[d])) + IO.XMLSUFFIX));
      }
      colls.put(cname, dl.toArray());
    }
    init(root);

    if (reporting) {
      Util.outln("Delete old results...");
      delete(new File[] {new File(results)});
    }

    if (verbose) Util.outln();
    final Nodes nodes =
        minimum
            ? nodes("//*:test-group[starts-with(@name, 'Minim')]//*:test-case", root)
            : group != null
                ? nodes("//*:test-group[@name eq '" + group + "']//*:test-case", root)
                : nodes("//*:test-case", root);

    long total = nodes.size();
    Util.out("Parsing " + total + " Queries");
    for (int t = 0; t < total; ++t) {
      if (!parse(new Nodes(nodes.list[t], data))) break;
      if (!verbose && t % 500 == 0) Util.out(".");
    }
    Util.outln();
    total = ok + ok2 + err + err2;

    final String time = perf.getTimer();
    Util.outln("Writing log file..." + NL);
    BufferedWriter bw =
        new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path + pathlog), UTF8));
    bw.write("TEST RESULTS ==================================================");
    bw.write(NL + NL + "Total #Queries: " + total + NL);
    bw.write("Correct / Empty Results: " + ok + " / " + ok2 + NL);
    bw.write("Conformance (w/Empty Results): ");
    bw.write(pc(ok, total) + " / " + pc(ok + ok2, total) + NL);
    bw.write("Wrong Results / Errors: " + err + " / " + err2 + NL);
    bw.write("WRONG =========================================================");
    bw.write(NL + NL + logErr + NL);
    bw.write("WRONG (ERRORS) ================================================");
    bw.write(NL + NL + logErr2 + NL);
    bw.write("CORRECT? (EMPTY) ==============================================");
    bw.write(NL + NL + logOK2 + NL);
    bw.write("CORRECT =======================================================");
    bw.write(NL + NL + logOK + NL);
    bw.write("===============================================================");
    bw.close();

    bw = new BufferedWriter(new FileWriter(path + pathhis, true));
    bw.write(dat + "\t" + ok + "\t" + ok2 + "\t" + err + "\t" + err2 + NL);
    bw.close();

    if (reporting) {
      bw =
          new BufferedWriter(
              new OutputStreamWriter(new FileOutputStream(report + NAME + IO.XMLSUFFIX), UTF8));
      write(bw, report + NAME + "Pre" + IO.XMLSUFFIX);
      bw.write(logReport.toString());
      write(bw, report + NAME + "Pos" + IO.XMLSUFFIX);
      bw.close();
    }

    Util.outln("Total #Queries: " + total);
    Util.outln("Correct / Empty results: " + ok + " / " + ok2);
    Util.out("Conformance (w/empty results): ");
    Util.outln(pc(ok, total) + " / " + pc(ok + ok2, total));
    Util.outln("Total Time: " + time);

    context.close();
  }
Exemple #3
0
 @Override
 public boolean parseArguments(final String[] args) {
   final Args arg = new Args(args, this, JAXRXINFO, Util.info(CONSOLE, JAXRX));
   boolean daemon = false;
   final StringBuilder serial = new StringBuilder();
   while (arg.more()) {
     if (arg.dash()) {
       final char c = arg.next();
       if (c == 'D') {
         // hidden flag: daemon mode
         daemon = true;
       } else if (c == 'j') {
         // parse JAX-RX server port
         context.prop.set(Prop.JAXRXPORT, arg.num());
       } else if (c == 'p') {
         // parse server port
         set(BXJaxRx.SERVERPORT, arg.num(), true);
       } else if (c == 'P') {
         // specify password
         pass = arg.string();
       } else if (c == 's') {
         // set service flag
         service = !daemon;
       } else if (c == 'S') {
         // set/add serialization parameter
         if (serial.length() != 0) serial.append(',');
         serial.append(arg);
         set(BXJaxRx.SERIALIZER, serial, true);
       } else if (c == 'U') {
         // specify user name
         user = arg.string();
       } else if (c == 'z') {
         // suppress logging
         quiet = true;
       } else {
         arg.check(false);
       }
     } else {
       arg.check(false);
       if (arg.string().equalsIgnoreCase("stop")) {
         stop(context.prop.num(Prop.SERVERPORT));
         return false;
       }
     }
   }
   return arg.finish();
 }