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

Comparing jsr166/src/test/tck/ReentrantReadWriteLockTest.java (file contents):
Revision 1.62 by jsr166, Sun May 15 17:30:21 2011 UTC vs.
Revision 1.63 by jsr166, Sat May 21 06:24:33 2011 UTC

# Line 145 | Line 145 | public class ReentrantReadWriteLockTest
145          lock.writeLock().unlock();
146      }
147  
148 <    enum AwaitMethod { await, awaitNanos, awaitUntil };
148 >    enum AwaitMethod { await, awaitTimed, awaitNanos, awaitUntil };
149  
150      /**
151       * Awaits condition using the specified AwaitMethod.
# Line 156 | Line 156 | public class ReentrantReadWriteLockTest
156          case await:
157              c.await();
158              break;
159 +        case awaitTimed:
160 +            assertTrue(c.await(2 * LONG_DELAY_MS, MILLISECONDS));
161 +            break;
162          case awaitNanos:
163              long nanosRemaining = c.awaitNanos(MILLISECONDS.toNanos(2 * LONG_DELAY_MS));
164              assertTrue(nanosRemaining > 0);
# Line 866 | Line 869 | public class ReentrantReadWriteLockTest
869      public void testAwait_IMSE(boolean fair) {
870          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
871          final Condition c = lock.writeLock().newCondition();
872 <        long startTime = System.nanoTime();
873 <        try {
871 <            try {
872 <                c.await();
873 <                shouldThrow();
874 <            } catch (IllegalMonitorStateException success) {}
875 <            try {
876 <                c.await(LONG_DELAY_MS, MILLISECONDS);
877 <                shouldThrow();
878 <            } catch (IllegalMonitorStateException success) {}
879 <            try {
880 <                c.awaitNanos(MILLISECONDS.toNanos(LONG_DELAY_MS));
881 <                shouldThrow();
882 <            } catch (IllegalMonitorStateException success) {}
872 >        for (AwaitMethod awaitMethod : AwaitMethod.values()) {
873 >            long startTime = System.nanoTime();
874              try {
875 <                c.awaitUninterruptibly();
875 >                await(c, awaitMethod);
876                  shouldThrow();
877 <            } catch (IllegalMonitorStateException success) {}
878 <        } catch (InterruptedException ie) {
879 <            threadUnexpectedException(ie);
877 >            } catch (IllegalMonitorStateException success) {
878 >            } catch (InterruptedException e) { threadUnexpectedException(e); }
879 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
880          }
890        assertTrue(millisElapsedSince(startTime) < MEDIUM_DELAY_MS);
881      }
882  
883      /**
# Line 1047 | Line 1037 | public class ReentrantReadWriteLockTest
1037       */
1038      public void testInterruptible_await()           { testInterruptible(false, AwaitMethod.await); }
1039      public void testInterruptible_await_fair()      { testInterruptible(true,  AwaitMethod.await); }
1040 +    public void testInterruptible_awaitTimed()      { testInterruptible(false, AwaitMethod.awaitTimed); }
1041 +    public void testInterruptible_awaitTimed_fair() { testInterruptible(true,  AwaitMethod.awaitTimed); }
1042      public void testInterruptible_awaitNanos()      { testInterruptible(false, AwaitMethod.awaitNanos); }
1043      public void testInterruptible_awaitNanos_fair() { testInterruptible(true,  AwaitMethod.awaitNanos); }
1044      public void testInterruptible_awaitUntil()      { testInterruptible(false, AwaitMethod.awaitUntil); }
# Line 1084 | Line 1076 | public class ReentrantReadWriteLockTest
1076       */
1077      public void testSignalAll_await()           { testSignalAll(false, AwaitMethod.await); }
1078      public void testSignalAll_await_fair()      { testSignalAll(true,  AwaitMethod.await); }
1079 +    public void testSignalAll_awaitTimed()      { testSignalAll(false, AwaitMethod.awaitTimed); }
1080 +    public void testSignalAll_awaitTimed_fair() { testSignalAll(true,  AwaitMethod.awaitTimed); }
1081      public void testSignalAll_awaitNanos()      { testSignalAll(false, AwaitMethod.awaitNanos); }
1082      public void testSignalAll_awaitNanos_fair() { testSignalAll(true,  AwaitMethod.awaitNanos); }
1083      public void testSignalAll_awaitUntil()      { testSignalAll(false, AwaitMethod.awaitUntil); }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines