Search in sources :

Example 1 with ProcessManagerException

use of com.sun.appserv.test.util.process.ProcessManagerException in project Payara by payara.

the class BaseDevTest method asadminWithOutput.

/**
 * Runs the command with the args given
 * Returns the precious output strings for further processing.
 *
 * @param args
 *
 * @return true if successful
 */
public AsadminReturn asadminWithOutput(final String... args) {
    AsadminReturn ret = new AsadminReturn();
    String cmd = isWindows() ? "/bin/asadmin.bat" : "/bin/asadmin";
    List<String> command = new ArrayList<String>();
    String gf_home = System.getProperty("glassfish.home");
    command.add(gf_home + cmd);
    command.addAll(Arrays.asList(antProp("as.props").split(" ")));
    command.addAll(Arrays.asList(args));
    ProcessManager pm = new ProcessManager(command);
    // the tests may be running unattended -- don't wait forever!
    pm.setTimeoutMsec(DEFAULT_TIMEOUT_MSEC);
    pm.setEcho(false);
    int exit;
    try {
        exit = pm.execute();
    } catch (ProcessManagerException ex) {
        exit = 1;
    }
    ret.out = pm.getStdout();
    ret.err = pm.getStderr();
    ret.outAndErr = ret.out + ret.err;
    ret.returnValue = exit == 0 && validResults(ret.out, String.format("Command %s failed.", args[0]), "list-commands");
    return ret;
}
Also used : ProcessManagerException(com.sun.appserv.test.util.process.ProcessManagerException) ArrayList(java.util.ArrayList) ProcessManager(com.sun.appserv.test.util.process.ProcessManager)

Aggregations

ProcessManager (com.sun.appserv.test.util.process.ProcessManager)1 ProcessManagerException (com.sun.appserv.test.util.process.ProcessManagerException)1 ArrayList (java.util.ArrayList)1