TaskProcess implements AutoCloseable { public int start() throws TaskException { Executor executor = prepare(); return start(executor); } TaskProcess(
			CmdLineBuilder cmdLineBuilder,
			Path wrkDir,
			Map<String, String> environment,
			OutputStream stdOutOutputStream,
			OutputStream stdErrOutputStream,
			DependencyDownloader artifactDownloader); int start(); void kill(); @Override void close(); boolean isDebugListeningMode(); int getDebugPort(); boolean isSuspended(); void setTimeout(long timeout); List<String> getArgs(); String getWorkingDirectory(); Collection<BpkIdentifier> getBkpDependencies(); Collection<ArtifactIdentifier> getArtifactDependencies(); Map<String, String> getEnvironmentProperties(); static final long NO_TIMEOUT; }
@Test(expected = TaskException.class) public void testExceptionIsThrownWhenProcessEndsWithErrorExitCode() throws Exception { setUpCmdLineBuilder(sourceWithBadExitCode); Map<String, String> environment = new HashMap<>(); TaskProcess process = new TaskProcess(cmdLineBuilder, workingDirectory.toPath(), environment, fakeStdOutOutputStream, fakeStdErrOutputStream, dependencyDownloader); process.start(); }
@Test(expected = TaskException.class) public void testExceptionIsThrownWhenInvalidCommandLineProvided() throws Exception { Mockito.when(cmdLineBuilder.build()).thenReturn(new TaskCommandLine("q w e r t y")); Map<String, String> environment = new HashMap<>(); final TaskProcess process = new TaskProcess(cmdLineBuilder, wrkDirPath, environment, fakeStdOutOutputStream, fakeStdErrOutputStream, dependencyDownloader); process.start(); }
@Test public void testCorrectExitCodeIsReturned() throws Exception { setUpCmdLineBuilder(sourceDoingNothing); Map<String, String> environment = new HashMap<>(); final TaskProcess process = new TaskProcess(cmdLineBuilder, wrkDirPath, environment, fakeStdOutOutputStream, fakeStdErrOutputStream, dependencyDownloader); assertEquals(0, process.start()); }