16 |
|
|
17 |
|
public class AbstractQueuedLongSynchronizerTest extends JSR166TestCase { |
18 |
|
public static void main(String[] args) { |
19 |
< |
junit.textui.TestRunner.run (suite()); |
19 |
> |
junit.textui.TestRunner.run(suite()); |
20 |
|
} |
21 |
|
public static Test suite() { |
22 |
|
return new TestSuite(AbstractQueuedLongSynchronizerTest.class); |
47 |
|
return true; |
48 |
|
} |
49 |
|
|
50 |
< |
public AbstractQueuedLongSynchronizer.ConditionObject newCondition() { return new AbstractQueuedLongSynchronizer.ConditionObject(); } |
50 |
> |
public AbstractQueuedLongSynchronizer.ConditionObject newCondition() { |
51 |
> |
return new AbstractQueuedLongSynchronizer.ConditionObject(); |
52 |
> |
} |
53 |
|
|
54 |
|
} |
55 |
|
|
350 |
|
sync.acquire(1); |
351 |
|
Thread t = new Thread(new CheckedRunnable() { |
352 |
|
public void realRun() { |
353 |
< |
threadAssertFalse(sync.tryAcquire(1)); |
353 |
> |
assertFalse(sync.tryAcquire(1)); |
354 |
|
}}); |
355 |
|
|
356 |
|
t.start(); |
477 |
|
} |
478 |
|
|
479 |
|
/** |
480 |
< |
* Timed await without a signal times out |
480 |
> |
* Timed await without a signal times out |
481 |
|
*/ |
482 |
|
public void testAwait_Timeout() throws InterruptedException { |
483 |
|
final Mutex sync = new Mutex(); |
646 |
|
Thread t = new Thread(new CheckedRunnable() { |
647 |
|
public void realRun() throws InterruptedException { |
648 |
|
sync.acquire(1); |
649 |
< |
threadAssertFalse(sync.hasWaiters(c)); |
650 |
< |
threadAssertEquals(0, sync.getWaitQueueLength(c)); |
649 |
> |
assertFalse(sync.hasWaiters(c)); |
650 |
> |
assertEquals(0, sync.getWaitQueueLength(c)); |
651 |
|
c.await(); |
652 |
|
sync.release(1); |
653 |
|
}}); |
677 |
|
Thread t1 = new Thread(new CheckedRunnable() { |
678 |
|
public void realRun() throws InterruptedException { |
679 |
|
sync.acquire(1); |
680 |
< |
threadAssertFalse(sync.hasWaiters(c)); |
681 |
< |
threadAssertEquals(0, sync.getWaitQueueLength(c)); |
680 |
> |
assertFalse(sync.hasWaiters(c)); |
681 |
> |
assertEquals(0, sync.getWaitQueueLength(c)); |
682 |
|
c.await(); |
683 |
|
sync.release(1); |
684 |
|
}}); |
686 |
|
Thread t2 = new Thread(new CheckedRunnable() { |
687 |
|
public void realRun() throws InterruptedException { |
688 |
|
sync.acquire(1); |
689 |
< |
threadAssertTrue(sync.hasWaiters(c)); |
690 |
< |
threadAssertEquals(1, sync.getWaitQueueLength(c)); |
689 |
> |
assertTrue(sync.hasWaiters(c)); |
690 |
> |
assertEquals(1, sync.getWaitQueueLength(c)); |
691 |
|
c.await(); |
692 |
|
sync.release(1); |
693 |
|
}}); |
721 |
|
Thread t1 = new Thread(new CheckedRunnable() { |
722 |
|
public void realRun() throws InterruptedException { |
723 |
|
sync.acquire(1); |
724 |
< |
threadAssertTrue(sync.getWaitingThreads(c).isEmpty()); |
724 |
> |
assertTrue(sync.getWaitingThreads(c).isEmpty()); |
725 |
|
c.await(); |
726 |
|
sync.release(1); |
727 |
|
}}); |
729 |
|
Thread t2 = new Thread(new CheckedRunnable() { |
730 |
|
public void realRun() throws InterruptedException { |
731 |
|
sync.acquire(1); |
732 |
< |
threadAssertFalse(sync.getWaitingThreads(c).isEmpty()); |
732 |
> |
assertFalse(sync.getWaitingThreads(c).isEmpty()); |
733 |
|
c.await(); |
734 |
|
sync.release(1); |
735 |
|
}}); |
936 |
|
|
937 |
|
Thread t = new Thread(new CheckedRunnable() { |
938 |
|
public void realRun() throws InterruptedException { |
939 |
< |
threadAssertFalse(l.isSignalled()); |
939 |
> |
assertFalse(l.isSignalled()); |
940 |
|
l.acquireSharedInterruptibly(0); |
941 |
< |
threadAssertTrue(l.isSignalled()); |
941 |
> |
assertTrue(l.isSignalled()); |
942 |
|
}}); |
943 |
|
|
944 |
|
t.start(); |
953 |
|
/** |
954 |
|
* acquireSharedTimed returns after release |
955 |
|
*/ |
956 |
< |
public void testAsquireSharedTimed() throws InterruptedException { |
956 |
> |
public void testAquireSharedTimed() throws InterruptedException { |
957 |
|
final BooleanLatch l = new BooleanLatch(); |
958 |
|
|
959 |
|
Thread t = new Thread(new CheckedRunnable() { |
975 |
|
/** |
976 |
|
* acquireSharedInterruptibly throws IE if interrupted before released |
977 |
|
*/ |
978 |
< |
public void testAcquireSharedInterruptibly_InterruptedException() throws InterruptedException { |
978 |
> |
public void testAcquireSharedInterruptibly_InterruptedException() |
979 |
> |
throws InterruptedException { |
980 |
|
final BooleanLatch l = new BooleanLatch(); |
981 |
|
Thread t = new Thread(new CheckedInterruptedRunnable() { |
982 |
|
public void realRun() throws InterruptedException { |
983 |
< |
threadAssertFalse(l.isSignalled()); |
983 |
> |
assertFalse(l.isSignalled()); |
984 |
|
l.acquireSharedInterruptibly(0); |
985 |
|
}}); |
986 |
|
|