Package org.apache.jorphan.exec

Examples of org.apache.jorphan.exec.SystemCommand


        results.setSamplerData("Working Directory:"+directory.getAbsolutePath()+
                "\nEnvironment:"+env+
                "\nExecuting:" + cmdLine.toString());

        SystemCommand nativeCommand = null;
        try {
            nativeCommand = new SystemCommand(directory, getTimeout(), POLL_INTERVAL, env, getStdin(), getStdout(), getStderr());
            results.sampleStart();
            int returnCode = nativeCommand.run(cmds);
            results.sampleEnd();
            results.setResponseCode(Integer.toString(returnCode)); // TODO is this the best way to do this?
            if(log.isDebugEnabled()) {
                log.debug("Ran :"+cmdLine + " using working directory:"+directory.getAbsolutePath()+
                        " with execution environment:"+nativeCommand.getExecutionEnvironment()+ " => " + returnCode);
            }

            if (checkReturnCode && (returnCode != expectedReturnCode)) {
                results.setSuccessful(false);
                results.setResponseMessage("Uexpected return code.  Expected ["+expectedReturnCode+"]. Actual ["+returnCode+"].");
            } else {
                results.setSuccessful(true);
                results.setResponseMessage("OK");
            }
        } catch (IOException ioe) {
            results.sampleEnd();
            results.setSuccessful(false);
            // results.setResponseCode("???"); TODO what code should be set here?
            results.setResponseMessage("Exception occured whilst executing System Call: " + ioe);
        } catch (InterruptedException ie) {
            results.sampleEnd();
            results.setSuccessful(false);
            // results.setResponseCode("???"); TODO what code should be set here?
            results.setResponseMessage("System Sampler Interupted whilst executing System Call: " + ie);
        }

        if (nativeCommand != null) {
            results.setResponseData(nativeCommand.getOutResult().getBytes()); // default charset is deliberate here
        }
           
        return results;
    }
View Full Code Here

TOP

Related Classes of org.apache.jorphan.exec.SystemCommand

Copyright © 2018 www.massapicom. 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.