added unit tst for getProcessStatus(), fixed scoping issue in processmanager

This commit is contained in:
Aidan Hahn 2019-05-23 01:26:28 -07:00
parent 9754f23fd8
commit d9beaff898
No known key found for this signature in database
GPG key ID: 327711E983899316
2 changed files with 20 additions and 5 deletions

View file

@ -264,7 +264,7 @@ class ProcessManager {
* (AKA when user hits control c in the shell) * (AKA when user hits control c in the shell)
* releases resources held in the processController objects * releases resources held in the processController objects
*/ */
private void shutdown() { public void shutdown() {
this.processQueueMutex = true; this.processQueueMutex = true;
Iterator<HashMap.Entry<Integer, ProcessController>> iterator = this.processMap.entrySet().iterator(); Iterator<HashMap.Entry<Integer, ProcessController>> iterator = this.processMap.entrySet().iterator();

View file

@ -38,12 +38,27 @@ public class ProcessManagerTest {
*/ */
@Test @Test
public void addProcessesTest() { public void addProcessesTest() {
int pid1 = manager.newProcess("ping google"); 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); assertEquals(0, pid1);
int pid2 = manager.newProcess("ping google"); int status = manager.getProcessStatus(pid1);
assertEquals(1, pid2); assertEquals(0, status);
}
manager.shutdown();
}
} }