added a test for Mutex properties of the locking system

This commit is contained in:
Aidan Hahn 2019-05-23 19:31:03 -07:00
parent f14265fe5b
commit 8a513164ab
No known key found for this signature in database
GPG key ID: 327711E983899316
4 changed files with 86 additions and 13 deletions

View file

@ -0,0 +1,41 @@
/*
* ProcessManagerTestImplementation
*
* v1.0
*
* May 23, 2019
*/
package JobServ;
import java.util.concurrent.TimeoutException;
/*
* ProcessManagerTestImplementation
* inherits ProcessManager and adds useful functions for testing
*/
class ProcessManagerTestImplementation extends ProcessManager {
public void longCallHoldsLock() {
try {
super.getLock();
System.err.println("[1] Long Call Has Lock");
// hold lock for 7 seconds, more than double normal timeout.
Thread.sleep(4000);
super.releaseLock();
} catch (TimeoutException e) {
System.err.println("[!!] Long Call wasnt able to grab lock!");
return;
} catch (InterruptedException e) {
super.releaseLock();
System.err.println("[3] Released lock: interrupted");
return;
}
}
}