@Test public void testRedirectLastWins() throws Exception { launcher.redirectError(ProcessBuilder.Redirect.PIPE) .redirectError(ProcessBuilder.Redirect.INHERIT); assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.INHERIT); launcher.redirectOutput(ProcessBuilder.Redirect.PIPE) .redirectOutput(ProcessBuilder.Redirect.INHERIT); assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.INHERIT); }
@Test public void testRedirectsSimple() throws Exception { launcher.redirectError(ProcessBuilder.Redirect.PIPE); assertNotNull(launcher.errorStream); assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.PIPE); launcher.redirectOutput(ProcessBuilder.Redirect.PIPE); assertNotNull(launcher.outputStream); assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.PIPE); }
@Test(expected = IllegalArgumentException.class) public void testBadLogRedirect() throws Exception { File out = Files.createTempFile("stdout", "txt").toFile(); out.deleteOnExit(); new SparkLauncher() .redirectError() .redirectOutput(out) .redirectToLog("foo") .launch() .waitFor(); }
@Test public void testNoRedirectToLog() throws Exception { assumeFalse(isWindows()); Path out = Files.createTempFile("stdout", "txt"); Path err = Files.createTempFile("stderr", "txt"); out.toFile().deleteOnExit(); err.toFile().deleteOnExit(); ChildProcAppHandle handle = (ChildProcAppHandle) new TestSparkLauncher() .redirectError(err.toFile()) .redirectOutput(out.toFile()) .startApplication(); waitFor(handle); assertTrue(MESSAGES.isEmpty()); assertEquals(Arrays.asList("error"), Files.lines(err).collect(Collectors.toList())); assertEquals(Arrays.asList("output"), Files.lines(out).collect(Collectors.toList())); }
@Test public void testRedirectLastWins() throws Exception { SparkLauncher launcher = new SparkLauncher(); launcher.redirectError(ProcessBuilder.Redirect.PIPE) .redirectError(ProcessBuilder.Redirect.INHERIT); assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.INHERIT); launcher.redirectOutput(ProcessBuilder.Redirect.PIPE) .redirectOutput(ProcessBuilder.Redirect.INHERIT); assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.INHERIT); }
@Test public void testProcMonitorWithOutputRedirection() throws Exception { assumeFalse(isWindows()); File err = Files.createTempFile("out", "txt").toFile(); err.deleteOnExit(); SparkAppHandle handle = new TestSparkLauncher() .redirectError() .redirectOutput(err) .startApplication(); waitFor(handle); assertEquals(SparkAppHandle.State.LOST, handle.getState()); }
@Test public void testRedirectsSimple() throws Exception { SparkLauncher launcher = new SparkLauncher(); launcher.redirectError(ProcessBuilder.Redirect.PIPE); assertNotNull(launcher.errorStream); assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.PIPE); launcher.redirectOutput(ProcessBuilder.Redirect.PIPE); assertNotNull(launcher.outputStream); assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.PIPE); }