added a test for Mutex properties of the locking system
This commit is contained in:
parent
f14265fe5b
commit
8a513164ab
4 changed files with 86 additions and 13 deletions
41
src/test/java/JobServ/ProcessManagerTestImplementation.java
Normal file
41
src/test/java/JobServ/ProcessManagerTestImplementation.java
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue