/* * ProcessManagerTest * * v1.0 * * May 22, 2019 */ package JobServ; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import static org.junit.Assert.assertEquals; /* * ProcessManagerTest * Class that performs positive and negative unit tests * of every public method in ProcessManager. This not * only unit tests ProcessManager but also integration * tests it with ProcessController. */ public class ProcessManagerTest { ProcessManager manager; /* * ProcessManagerTest constructor * initializes the process manager */ public ProcessManagerTest() { manager = new ProcessManager(); } /* * addProcessTest() * positive unit test for newProcess */ @Test public void addProcessesTest() { int pid1 = manager.newProcess("ping google.com"); int pid2 = manager.newProcess("ping google.com"); assertEquals(2, pid2); assertEquals(1, pid1); manager.shutdown(); } /* * getStatusTest * positive unit test for getStatus */ @Test public void getStatusTest() { int pid1 = manager.newProcess("ping google.com"); assertEquals(0, pid1); int status = manager.getProcessStatus(pid1); assertEquals(0, status); manager.shutdown(); } }