--- jsr166/src/test/tck/ReentrantReadWriteLockTest.java 2011/05/13 21:48:59 1.61 +++ jsr166/src/test/tck/ReentrantReadWriteLockTest.java 2011/05/21 06:24:33 1.63 @@ -80,7 +80,7 @@ public class ReentrantReadWriteLockTest long startTime = System.nanoTime(); while (!lock.hasQueuedThread(t)) { if (millisElapsedSince(startTime) > LONG_DELAY_MS) - throw new AssertionError("timed out"); + throw new AssertionFailedError("timed out"); Thread.yield(); } assertTrue(t.isAlive()); @@ -145,7 +145,7 @@ public class ReentrantReadWriteLockTest lock.writeLock().unlock(); } - enum AwaitMethod { await, awaitNanos, awaitUntil }; + enum AwaitMethod { await, awaitTimed, awaitNanos, awaitUntil }; /** * Awaits condition using the specified AwaitMethod. @@ -156,6 +156,9 @@ public class ReentrantReadWriteLockTest case await: c.await(); break; + case awaitTimed: + assertTrue(c.await(2 * LONG_DELAY_MS, MILLISECONDS)); + break; case awaitNanos: long nanosRemaining = c.awaitNanos(MILLISECONDS.toNanos(2 * LONG_DELAY_MS)); assertTrue(nanosRemaining > 0); @@ -866,28 +869,15 @@ public class ReentrantReadWriteLockTest public void testAwait_IMSE(boolean fair) { final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair); final Condition c = lock.writeLock().newCondition(); - long startTime = System.nanoTime(); - try { - try { - c.await(); - shouldThrow(); - } catch (IllegalMonitorStateException success) {} - try { - c.await(LONG_DELAY_MS, MILLISECONDS); - shouldThrow(); - } catch (IllegalMonitorStateException success) {} + for (AwaitMethod awaitMethod : AwaitMethod.values()) { + long startTime = System.nanoTime(); try { - c.awaitNanos(MILLISECONDS.toNanos(LONG_DELAY_MS)); + await(c, awaitMethod); shouldThrow(); - } catch (IllegalMonitorStateException success) {} - try { - c.awaitUninterruptibly(); - shouldThrow(); - } catch (IllegalMonitorStateException success) {} - } catch (InterruptedException ie) { - threadUnexpectedException(ie); + } catch (IllegalMonitorStateException success) { + } catch (InterruptedException e) { threadUnexpectedException(e); } + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } - assertTrue(millisElapsedSince(startTime) < MEDIUM_DELAY_MS); } /** @@ -1047,6 +1037,8 @@ public class ReentrantReadWriteLockTest */ public void testInterruptible_await() { testInterruptible(false, AwaitMethod.await); } public void testInterruptible_await_fair() { testInterruptible(true, AwaitMethod.await); } + public void testInterruptible_awaitTimed() { testInterruptible(false, AwaitMethod.awaitTimed); } + public void testInterruptible_awaitTimed_fair() { testInterruptible(true, AwaitMethod.awaitTimed); } public void testInterruptible_awaitNanos() { testInterruptible(false, AwaitMethod.awaitNanos); } public void testInterruptible_awaitNanos_fair() { testInterruptible(true, AwaitMethod.awaitNanos); } public void testInterruptible_awaitUntil() { testInterruptible(false, AwaitMethod.awaitUntil); } @@ -1084,6 +1076,8 @@ public class ReentrantReadWriteLockTest */ public void testSignalAll_await() { testSignalAll(false, AwaitMethod.await); } public void testSignalAll_await_fair() { testSignalAll(true, AwaitMethod.await); } + public void testSignalAll_awaitTimed() { testSignalAll(false, AwaitMethod.awaitTimed); } + public void testSignalAll_awaitTimed_fair() { testSignalAll(true, AwaitMethod.awaitTimed); } public void testSignalAll_awaitNanos() { testSignalAll(false, AwaitMethod.awaitNanos); } public void testSignalAll_awaitNanos_fair() { testSignalAll(true, AwaitMethod.awaitNanos); } public void testSignalAll_awaitUntil() { testSignalAll(false, AwaitMethod.awaitUntil); }