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.18 by dl, Sat Jan 10 01:41:59 2004 UTC vs.
Revision 1.19 by dl, Sun Jan 25 13:25:28 2004 UTC

# Line 877 | Line 877 | public class ReentrantReadWriteLockTest
877      }
878  
879      /**
880 +     * hasQueuedThread(null) throws NPE
881 +     */
882 +    public void testHasQueuedThreadNPE() {
883 +        final ReentrantReadWriteLock sync = new ReentrantReadWriteLock();
884 +        try {
885 +            sync.hasQueuedThread(null);
886 +            shouldThrow();
887 +        } catch (NullPointerException success) {
888 +        }
889 +    }
890 +
891 +    /**
892 +     * hasQueuedThread reports whether a thread is queued.
893 +     */
894 +    public void testHasQueuedThread() {
895 +        final ReentrantReadWriteLock sync = new ReentrantReadWriteLock();
896 +        Thread t1 = new Thread(new InterruptedLockRunnable(sync));
897 +        Thread t2 = new Thread(new InterruptibleLockRunnable(sync));
898 +        try {
899 +            assertFalse(sync.hasQueuedThread(t1));
900 +            assertFalse(sync.hasQueuedThread(t2));
901 +            sync.writeLock().lock();
902 +            t1.start();
903 +            Thread.sleep(SHORT_DELAY_MS);
904 +            assertTrue(sync.hasQueuedThread(t1));
905 +            t2.start();
906 +            Thread.sleep(SHORT_DELAY_MS);
907 +            assertTrue(sync.hasQueuedThread(t1));
908 +            assertTrue(sync.hasQueuedThread(t2));
909 +            t1.interrupt();
910 +            Thread.sleep(SHORT_DELAY_MS);
911 +            assertFalse(sync.hasQueuedThread(t1));
912 +            assertTrue(sync.hasQueuedThread(t2));
913 +            sync.writeLock().unlock();
914 +            Thread.sleep(SHORT_DELAY_MS);
915 +            assertFalse(sync.hasQueuedThread(t1));
916 +            Thread.sleep(SHORT_DELAY_MS);
917 +            assertFalse(sync.hasQueuedThread(t2));
918 +            t1.join();
919 +            t2.join();
920 +        } catch(Exception e){
921 +            unexpectedException();
922 +        }
923 +    }
924 +
925 +
926 +    /**
927       * getQueueLength reports number of waiting threads
928       */
929      public void testGetQueueLength() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines