public final void testWaitFor_withoutEnter() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertThrows(IllegalMonitorStateException.class, waitFor(), guard); }
public final void testEnterWhen_initiallyFalse() throws Exception { TestGuard guard = new TestGuard(false); thread1.callAndAssertWaits(enterWhen(), guard); monitor.enter(); guard.setSatisfied(true); monitor.leave(); thread1.assertPriorCallReturns(enterWhen()); }
public final void testTryEnterIf_alreadyOccupied() throws Exception { TestGuard guard = new TestGuard(true); thread2.callAndAssertReturns(enter()); thread1.callAndAssertReturns(false, tryEnterIf(), guard); }
public final void testTryEnterIf_initiallyFalse() throws Exception { TestGuard guard = new TestGuard(false); thread1.callAndAssertReturns(false, tryEnterIf(), guard); thread2.callAndAssertReturns(enter()); }
public final void testEnterIf_initiallyTrue() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertReturns(true, enterIf(), guard); thread2.callAndAssertBlocks(enter()); }
public void testNulls() { monitor.enter(); // Inhibit IllegalMonitorStateException new NullPointerTester() .setDefault(Monitor.Guard.class, new TestGuard(true)) .testAllPublicInstanceMethods(monitor); }
public final void testEnterIf_alreadyOccupied() throws Exception { TestGuard guard = new TestGuard(true); thread2.callAndAssertReturns(enter()); thread1.callAndAssertBlocks(enterIf(), guard); thread2.callAndAssertReturns(leave()); thread1.assertPriorCallReturns(true, enterIf()); }
public final void testEnterWhen_alreadyOccupied() throws Exception { TestGuard guard = new TestGuard(true); thread2.callAndAssertReturns(enter()); thread1.callAndAssertBlocks(enterWhen(), guard); thread2.callAndAssertReturns(leave()); thread1.assertPriorCallReturns(enterWhen()); }
public final void testWaitFor_initiallyTrue() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertReturns(enter()); thread1.callAndAssertReturns(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 testEnterIf_initiallyFalse() throws Exception { TestGuard guard = new TestGuard(false); thread1.callAndAssertReturns(false, enterIf(), guard); thread2.callAndAssertReturns(enter()); }
public final void testEnterWhen_initiallyTrue() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertReturns(enterWhen(), guard); // same as above but with the new syntax thread1.callAndAssertReturns(enterWhen(), monitor.newGuard(() -> true)); }
public final void testWaitFor_initiallyFalse() throws Exception { TestGuard guard = new TestGuard(false); thread1.callAndAssertReturns(enter()); thread1.callAndAssertWaits(waitFor(), guard); monitor.enter(); guard.setSatisfied(true); monitor.leave(); thread1.assertPriorCallReturns(waitFor()); }
public final void testWaitFor_withoutEnter() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertThrows(IllegalMonitorStateException.class, waitFor(), guard); }
public final void testWaitFor_initiallyTrue() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertReturns(enter()); thread1.callAndAssertReturns(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 testEnterIf_alreadyOccupied() throws Exception { TestGuard guard = new TestGuard(true); thread2.callAndAssertReturns(enter()); thread1.callAndAssertBlocks(enterIf(), guard); thread2.callAndAssertReturns(leave()); thread1.assertPriorCallReturns(true, enterIf()); }
public final void testEnterIf_initiallyFalse() throws Exception { TestGuard guard = new TestGuard(false); thread1.callAndAssertReturns(false, enterIf(), guard); thread2.callAndAssertReturns(enter()); }
public final void testEnterIf_initiallyTrue() throws Exception { TestGuard guard = new TestGuard(true); thread1.callAndAssertReturns(true, enterIf(), guard); thread2.callAndAssertBlocks(enter()); }
public final void testWaitFor_initiallyFalse() throws Exception { TestGuard guard = new TestGuard(false); thread1.callAndAssertReturns(enter()); thread1.callAndAssertWaits(waitFor(), guard); monitor.enter(); guard.setSatisfied(true); monitor.leave(); thread1.assertPriorCallReturns(waitFor()); }