ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AbstractQueuedLongSynchronizerTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AbstractQueuedLongSynchronizerTest.java (file contents):
Revision 1.14 by jsr166, Mon Nov 30 08:31:09 2009 UTC vs.
Revision 1.19 by jsr166, Mon Oct 11 06:36:20 2010 UTC

# Line 16 | Line 16 | import java.io.*;
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);
# Line 47 | Line 47 | public class AbstractQueuedLongSynchroni
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  
# Line 330 | Line 332 | public class AbstractQueuedLongSynchroni
332          sync.acquire(1);
333          Thread t = new Thread(new CheckedInterruptedRunnable() {
334              public void realRun() throws InterruptedException {
335 <                sync.tryAcquireNanos(1, MEDIUM_DELAY_MS * 1000L * 1000L);
335 >                sync.tryAcquireNanos(1, MILLISECONDS.toNanos(MEDIUM_DELAY_MS));
336              }});
337  
338          t.start();
# Line 348 | Line 350 | public class AbstractQueuedLongSynchroni
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();
# Line 364 | Line 366 | public class AbstractQueuedLongSynchroni
366          sync.acquire(1);
367          Thread t = new Thread(new CheckedRunnable() {
368              public void realRun() throws InterruptedException {
369 <                threadAssertFalse(sync.tryAcquireNanos(1, SHORT_DELAY_MS * 1000L * 1000L));
369 >                long nanos = MILLISECONDS.toNanos(SHORT_DELAY_MS);
370 >                assertFalse(sync.tryAcquireNanos(1, nanos));
371              }});
372  
373          t.start();
# Line 474 | Line 477 | public class AbstractQueuedLongSynchroni
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();
# Line 643 | Line 646 | public class AbstractQueuedLongSynchroni
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              }});
# Line 674 | Line 677 | public class AbstractQueuedLongSynchroni
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              }});
# Line 683 | Line 686 | public class AbstractQueuedLongSynchroni
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              }});
# Line 718 | Line 721 | public class AbstractQueuedLongSynchroni
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              }});
# Line 726 | Line 729 | public class AbstractQueuedLongSynchroni
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              }});
# Line 808 | Line 811 | public class AbstractQueuedLongSynchroni
811          Thread t = new Thread(new CheckedInterruptedRunnable() {
812              public void realRun() throws InterruptedException {
813                  sync.acquire(1);
814 <                c.awaitNanos(LONG_DELAY_MS * 1000L * 1000L);
814 >                c.awaitNanos(MILLISECONDS.toNanos(LONG_DELAY_MS));
815              }});
816  
817          t.start();
# Line 933 | Line 936 | public class AbstractQueuedLongSynchroni
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();
# Line 950 | Line 953 | public class AbstractQueuedLongSynchroni
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() {
960              public void realRun() throws InterruptedException {
961 <                threadAssertFalse(l.isSignalled());
962 <                threadAssertTrue(l.tryAcquireSharedNanos(0, MEDIUM_DELAY_MS * 1000L * 1000L));
963 <                threadAssertTrue(l.isSignalled());
961 >                assertFalse(l.isSignalled());
962 >                long nanos = MILLISECONDS.toNanos(MEDIUM_DELAY_MS);
963 >                assertTrue(l.tryAcquireSharedNanos(0, nanos));
964 >                assertTrue(l.isSignalled());
965              }});
966  
967          t.start();
# Line 971 | Line 975 | public class AbstractQueuedLongSynchroni
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  
# Line 992 | Line 997 | public class AbstractQueuedLongSynchroni
997          final BooleanLatch l = new BooleanLatch();
998          Thread t = new Thread(new CheckedInterruptedRunnable() {
999              public void realRun() throws InterruptedException {
1000 <                threadAssertFalse(l.isSignalled());
1001 <                l.tryAcquireSharedNanos(0, SMALL_DELAY_MS * 1000L * 1000L);
1000 >                assertFalse(l.isSignalled());
1001 >                long nanos = MILLISECONDS.toNanos(SMALL_DELAY_MS);
1002 >                l.tryAcquireSharedNanos(0, nanos);
1003              }});
1004  
1005          t.start();
# Line 1010 | Line 1016 | public class AbstractQueuedLongSynchroni
1016          final BooleanLatch l = new BooleanLatch();
1017          Thread t = new Thread(new CheckedRunnable() {
1018              public void realRun() throws InterruptedException {
1019 <                threadAssertFalse(l.isSignalled());
1020 <                threadAssertFalse(l.tryAcquireSharedNanos(0, SMALL_DELAY_MS * 1000L * 1000L));
1019 >                assertFalse(l.isSignalled());
1020 >                long nanos = MILLISECONDS.toNanos(SMALL_DELAY_MS);
1021 >                assertFalse(l.tryAcquireSharedNanos(0, nanos));
1022              }});
1023  
1024          t.start();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines