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.63 by jsr166, Sat May 21 06:24:33 2011 UTC vs.
Revision 1.64 by jsr166, Tue May 24 23:40:14 2011 UTC

# Line 507 | Line 507 | public class ReentrantReadWriteLockTest
507  
508      /**
509       * A thread that tries to acquire a fair read lock (non-reentrantly)
510 <     * will block if there is a waiting writer thread.
510 >     * will block if there is a waiting writer thread
511       */
512      public void testReaderWriterReaderFairFifo() {
513          final PublicReentrantReadWriteLock lock =
# Line 584 | Line 584 | public class ReentrantReadWriteLockTest
584      }
585  
586      /**
587 <     * Read trylock succeeds (barging) even in the presence of waiting readers and/or writers.
587 >     * Read trylock succeeds (barging) even in the presence of waiting
588 >     * readers and/or writers
589       */
590      public void testReadTryLockBarging()      { testReadTryLockBarging(false); }
591      public void testReadTryLockBarging_fair() { testReadTryLockBarging(true); }
# Line 1111 | Line 1112 | public class ReentrantReadWriteLockTest
1112      }
1113  
1114      /**
1115 <     * signal wakes up waiting threads in FIFO order.
1115 >     * signal wakes up waiting threads in FIFO order
1116       */
1117      public void testSignalWakesFifo()      { testSignalWakesFifo(false); }
1118      public void testSignalWakesFifo_fair() { testSignalWakesFifo(true); }
# Line 1272 | Line 1273 | public class ReentrantReadWriteLockTest
1273      }
1274  
1275      /**
1276 <     * hasQueuedThread reports whether a thread is queued.
1276 >     * hasQueuedThread reports whether a thread is queued
1277       */
1278      public void testHasQueuedThread()      { testHasQueuedThread(false); }
1279      public void testHasQueuedThread_fair() { testHasQueuedThread(true); }
# Line 1613 | Line 1614 | public class ReentrantReadWriteLockTest
1614      public void testToString_fair() { testToString(true); }
1615      public void testToString(boolean fair) {
1616          ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
1617 <        String us = lock.toString();
1618 <        assertTrue(us.indexOf("Write locks = 0") >= 0);
1619 <        assertTrue(us.indexOf("Read locks = 0") >= 0);
1620 <        lock.writeLock().lock();
1621 <        String ws = lock.toString();
1621 <        assertTrue(ws.indexOf("Write locks = 1") >= 0);
1622 <        assertTrue(ws.indexOf("Read locks = 0") >= 0);
1617 >        assertTrue(lock.toString().contains("Write locks = 0"));
1618 >        assertTrue(lock.toString().contains("Read locks = 0"));
1619 >        lock.writeLock().lock();
1620 >        assertTrue(lock.toString().contains("Write locks = 1"));
1621 >        assertTrue(lock.toString().contains("Read locks = 0"));
1622          lock.writeLock().unlock();
1623          lock.readLock().lock();
1624          lock.readLock().lock();
1625 <        String rs = lock.toString();
1626 <        assertTrue(rs.indexOf("Write locks = 0") >= 0);
1628 <        assertTrue(rs.indexOf("Read locks = 2") >= 0);
1625 >        assertTrue(lock.toString().contains("Write locks = 0"));
1626 >        assertTrue(lock.toString().contains("Read locks = 2"));
1627      }
1628  
1629      /**
# Line 1635 | Line 1633 | public class ReentrantReadWriteLockTest
1633      public void testReadLockToString_fair() { testReadLockToString(true); }
1634      public void testReadLockToString(boolean fair) {
1635          ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
1636 <        String us = lock.readLock().toString();
1639 <        assertTrue(us.indexOf("Read locks = 0") >= 0);
1636 >        assertTrue(lock.readLock().toString().contains("Read locks = 0"));
1637          lock.readLock().lock();
1638          lock.readLock().lock();
1639 <        String rs = lock.readLock().toString();
1643 <        assertTrue(rs.indexOf("Read locks = 2") >= 0);
1639 >        assertTrue(lock.readLock().toString().contains("Read locks = 2"));
1640      }
1641  
1642      /**
# Line 1650 | Line 1646 | public class ReentrantReadWriteLockTest
1646      public void testWriteLockToString_fair() { testWriteLockToString(true); }
1647      public void testWriteLockToString(boolean fair) {
1648          ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
1649 <        String us = lock.writeLock().toString();
1654 <        assertTrue(us.indexOf("Unlocked") >= 0);
1649 >        assertTrue(lock.writeLock().toString().contains("Unlocked"));
1650          lock.writeLock().lock();
1651 <        String ls = lock.writeLock().toString();
1652 <        assertTrue(ls.indexOf("Locked") >= 0);
1651 >        assertTrue(lock.writeLock().toString().contains("Locked"));
1652 >        lock.writeLock().unlock();
1653 >        assertTrue(lock.writeLock().toString().contains("Unlocked"));
1654      }
1655  
1656   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines