Search in sources :

Example 1 with OutputInterpreter

use of com.cloud.utils.script.OutputInterpreter in project cloudstack by apache.

the class ScriptTest method executeWithOutputInterpreter.

@Test
public void executeWithOutputInterpreter() {
    Assume.assumeTrue(SystemUtils.IS_OS_LINUX);
    Script script = new Script("/bin/bash");
    script.add("-c");
    script.add("echo 'hello world!'");
    String value = script.execute(new OutputInterpreter() {

        @Override
        public String interpret(BufferedReader reader) throws IOException {
            throw new IllegalArgumentException();
        }
    });
    // it is a stack trace in this case as string
    Assert.assertNotNull(value);
}
Also used : Script(com.cloud.utils.script.Script) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) OutputInterpreter(com.cloud.utils.script.OutputInterpreter) Test(org.junit.Test)

Aggregations

OutputInterpreter (com.cloud.utils.script.OutputInterpreter)1 Script (com.cloud.utils.script.Script)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 Test (org.junit.Test)1