public final void testSystemStateMethods() throws Exception { checkSystemStateMethods(0); thread1.callAndAssertReturns(enter()); checkSystemStateMethods(1); thread1.callAndAssertReturns(enter()); checkSystemStateMethods(2); thread1.callAndAssertReturns(leave()); checkSystemStateMethods(1); thread1.callAndAssertReturns(leave()); checkSystemStateMethods(0); }
public final void testTryEnter() throws Exception { thread1.callAndAssertReturns(true, tryEnter()); thread2.callAndAssertReturns(false, tryEnter()); thread1.callAndAssertReturns(true, tryEnter()); thread2.callAndAssertReturns(false, tryEnter()); thread1.callAndAssertReturns(leave()); thread2.callAndAssertReturns(false, tryEnter()); thread1.callAndAssertReturns(leave()); thread2.callAndAssertReturns(true, tryEnter()); }
public final void testTryEnterIf_initiallyFalse() throws Exception { TestGuard guard = new TestGuard(false); thread1.callAndAssertReturns(false, tryEnterIf(), guard); thread2.callAndAssertReturns(enter()); }
public final void testWaitFor_withoutEnter() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertThrows(IllegalMonitorStateException.class, waitFor(), guard); }
public final void testTryEnterIf_alreadyOccupied() throws Exception { TestGuard guard = new TestGuard(true); thread2.callAndAssertReturns(enter()); thread1.callAndAssertReturns(false, tryEnterIf(), guard); }
public final void testTryEnter() throws Exception { thread1.callAndAssertReturns(true, tryEnter()); thread2.callAndAssertReturns(false, tryEnter()); thread1.callAndAssertReturns(true, tryEnter()); thread2.callAndAssertReturns(false, tryEnter()); thread1.callAndAssertReturns(leave()); thread2.callAndAssertReturns(false, tryEnter()); thread1.callAndAssertReturns(leave()); thread2.callAndAssertReturns(true, tryEnter()); }
public final void testWaitFor_withoutEnter() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertThrows(IllegalMonitorStateException.class, waitFor(), guard); }
public final void testTryEnterIf_initiallyTrue() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertReturns(true, tryEnterIf(), guard); thread2.callAndAssertBlocks(enter()); }
public final void testSystemStateMethods() throws Exception { checkSystemStateMethods(0); thread1.callAndAssertReturns(enter()); checkSystemStateMethods(1); thread1.callAndAssertReturns(enter()); checkSystemStateMethods(2); thread1.callAndAssertReturns(leave()); checkSystemStateMethods(1); thread1.callAndAssertReturns(leave()); checkSystemStateMethods(0); }