DefaultCommandRunner implements CommandRunner { public String runCommandAndCaptureOutput(String... command) { return runCommandAndCaptureOutput(new File("/"), command); } private  DefaultCommandRunner(); int runCommand(String... command); int runCommand(Boolean inheritIo, String... command); int runCommand(File directoryForRunning, String... command); int runCommand(Boolean inheritIo, File directoryForRunning, String... command); String runCommandAndCaptureOutput(String... command); String runCommandAndCaptureOutput(File directoryForRunning, String... command); static final DefaultCommandRunner INSTANCE; }
@Test public void test_large_output() throws Exception { final File tmp = File.createTempFile("carnotzet-test", null); tmp.deleteOnExit(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 10000; i++){ sb.append("This line is repeated a lot\n"); } String expected = sb.toString(); FileUtils.write(tmp, expected); String actual = new SimpleTimeLimiter().callWithTimeout( () -> DefaultCommandRunner.INSTANCE.runCommandAndCaptureOutput("cat", tmp.getAbsolutePath()), 2, TimeUnit.SECONDS, true); Assert.assertThat(actual, Is.is(expected.trim())); }