Execute { public BufferedResult toBuffer() { ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream(); Result r = this.execute(out, err); BufferedResult br = new BufferedResult(); br.exitValue = r.exitValue; br.success = r.success; br.out = out.toString(); br.err = err.toString(); return br; } Execute(String command);  Execute(String[] commandPlusArgs); Execute addEnvPaths(); Execute addAllEnv(); Execute arg(String arg); Execute input(String input); Execute env(String key, String value); Execute clearEnv(); Execute path(String possiblePath); Execute clearPath(); Result toSystemOut(); Result toFile(String outPath); Result toFile(File out); BufferedResult toBuffer();  }
@Test public void toBufferOut() { Execute e = new Execute("ls"); BufferedResult r = e.toBuffer(); assertThat(r.out.contains("README.markdown"), is(true)); assertThat(r.success, is(true)); assertThat(r.exitValue, is(0)); }
@Test public void envPathsAreTheDefault() { Execute e = new Execute("ls"); assertThat(e.toBuffer().exitValue, is(0)); }
@Test public void canTakeAbsolutePath() { Execute e = new Execute("/bin/ls"); assertThat(e.toBuffer().exitValue, is(0)); }