Example #1
0
 @Override
 protected String run(final String... args) throws IOException {
   try {
     final ArrayOutput ao = new ArrayOutput();
     System.setOut(new PrintStream(ao));
     System.setErr(NULL);
     new BaseX(args);
     return ao.toString();
   } finally {
     System.setOut(OUT);
     System.setErr(ERR);
   }
 }
Example #2
0
  /**
   * Runs a request with the specified arguments and server arguments.
   *
   * @param args command-line arguments
   * @param sargs server arguments
   * @return result
   * @throws IOException I/O exception
   */
  private static String run(final String[] args, final String[] sargs) throws IOException {
    final BaseXServer server = createServer(sargs);
    final ArrayOutput ao = new ArrayOutput();
    System.setOut(new PrintStream(ao));
    System.setErr(NULL);

    final StringList sl = new StringList();
    sl.add("-p9999").add("-U" + Text.S_ADMIN).add("-P" + Text.S_ADMIN).add(args);
    try {
      new BaseXClient(sl.finish());
      return ao.toString();
    } finally {
      System.setErr(ERR);
      stopServer(server);
    }
  }
Example #3
0
 /**
  * Runs the specified command.
  *
  * @param c command
  * @return string result
  * @throws HTTPException HTTP exception
  */
 final String run(final Command c) throws HTTPException {
   final ArrayOutput ao = new ArrayOutput();
   run(c, ao);
   return ao.toString();
 }
Example #4
0
 /**
  * Executes the command and returns the result as string. If an exception occurs, a {@link
  * BaseXException} is thrown.
  *
  * @param ctx database context
  * @return string result
  * @throws BaseXException command exception
  */
 public final String execute(final Context ctx) throws BaseXException {
   final ArrayOutput ao = new ArrayOutput();
   execute(ctx, ao);
   return ao.toString();
 }