@@ -0,0 +1,3263 @@
+/*%0A * Copyright 2017 Viktor Csomor%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage net.viktorc.pp4j.impl;%0A%0Aimport java.io.IOException;%0Aimport java.io.Serializable;%0Aimport java.util.Optional;%0Aimport java.util.concurrent.atomic.AtomicInteger;%0Aimport net.viktorc.pp4j.api.Submission;%0Aimport net.viktorc.pp4j.impl.JavaProcess.Response;%0Aimport net.viktorc.pp4j.impl.JavaProcess.ResponseType;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0A/**%0A * A unit test class for %7B@link JavaProcessManager%7D.%0A *%0A * @author Viktor Csomor%0A */%0Apublic class JavaProcessManagerTest extends TestCase %7B%0A%0A  @Test%0A  public void testIsStartedUpReturnsFalseIfLineNotDecodeable() %7B%0A    JavaProcessManager%3C?%3E javaProcessManager = new JavaProcessManager%3C%3E(new ProcessBuilder(%22%22), null, null, null);%0A    Assert.assertFalse(javaProcessManager.isStartedUp(%22%22, false));%0A  %7D%0A%0A  @Test%0A  public void testIsStartedUpReturnsFalseIfLineFromStdErr() throws IOException %7B%0A    JavaProcessManager%3C?%3E javaProcessManager = new JavaProcessManager%3C%3E(new ProcessBuilder(%22%22), null, null, null);%0A    Response response = new Response(ResponseType.STARTUP_SUCCESS);%0A    String line = JavaObjectCodec.getInstance().encode(response);%0A    Assert.assertFalse(javaProcessManager.isStartedUp(line, true));%0A  %7D%0A%0A  @Test%0A  public void testIsStartedUpOnlyReturnsTrueIfResponseStartupSuccess() throws IOException %7B%0A    JavaProcessManager%3C?%3E javaProcessManager = new JavaProcessManager%3C%3E(new ProcessBuilder(%22%22), null, null, null);%0A    JavaObjectCodec codec = JavaObjectCodec.getInstance();%0A    Assert.assertFalse(javaProcessManager.isStartedUp(codec.encode(new Response(ResponseType.TASK_SUCCESS)), false));%0A    Assert.assertFalse(javaProcessManager.isStartedUp(codec.encode(new Response(ResponseType.TASK_FAILURE)), false));%0A    Assert.assertFalse(javaProcessManager.isStartedUp(codec.encode(new Response(ResponseType.PROCESS_FAILURE)), false));%0A    Assert.assertTrue(javaProcessManager.isStartedUp(codec.encode(new Response(ResponseType.STARTUP_SUCCESS)), false));%0A  %7D%0A%0A  @Test%0A  public void testTerminationSubmissionIncludesWrapUpTask() %7B%0A    AtomicInteger atomicInteger = new AtomicInteger(0);%0A    JavaProcessManager%3C?%3E javaProcessManager = new JavaProcessManager%3C%3E(new ProcessBuilder(%22%22), null,%0A        (Runnable & Serializable) atomicInteger::incrementAndGet, null);%0A    Optional%3CSubmission%3C?%3E%3E optionalSubmission = javaProcessManager.getTerminationSubmission();%0A    Assert.assertTrue(optionalSubmission.isPresent());%0A    Submission%3C?%3E submission = optionalSubmission.get();%0A    Assert.assertTrue(submission instanceof JavaSubmission);%0A    JavaSubmission%3C?%3E javaSubmission = (JavaSubmission%3C?%3E) submission;%0A    javaSubmission.getTask().run();%0A    Assert.assertEquals(1, atomicInteger.get());%0A  %7D%0A%0A%7D%0A

Add unit tests for JavaProcessManager