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.13 by dl, Sun Dec 28 21:56:18 2003 UTC vs.
Revision 1.16 by dl, Wed Jan 7 01:02:17 2004 UTC

# Line 156 | Line 156 | public class ReentrantReadWriteLockTest
156       */
157      public void testWriteLockInterruptibly_Interrupted() {
158          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
159        lock.writeLock().lock();
159          Thread t = new Thread(new Runnable() {
160                  public void run() {
161                      try {
162                          lock.writeLock().lockInterruptibly();
163 <                        threadShouldThrow();
163 >                        lock.writeLock().unlock();
164 >                        lock.writeLock().lockInterruptibly();
165 >                        lock.writeLock().unlock();
166                      } catch(InterruptedException success){}
167                  }
168              });
169          try {
170 +            lock.writeLock().lock();
171              t.start();
172              t.interrupt();
173              lock.writeLock().unlock();
# Line 176 | Line 178 | public class ReentrantReadWriteLockTest
178      }
179  
180      /**
181 <     * timed write-trylock is interruptible
181 >     * timed write-tryLock is interruptible
182       */
183      public void testWriteTryLock_Interrupted() {
184          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 209 | Line 211 | public class ReentrantReadWriteLockTest
211                  public void run() {
212                      try {
213                          lock.readLock().lockInterruptibly();
212                        threadShouldThrow();
214                      } catch(InterruptedException success){}
215                  }
216              });
# Line 224 | Line 225 | public class ReentrantReadWriteLockTest
225      }
226  
227      /**
228 <     * timed read-trylock is interruptible
228 >     * timed read-tryLock is interruptible
229       */
230      public void testReadTryLock_Interrupted() {
231          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 248 | Line 249 | public class ReentrantReadWriteLockTest
249  
250      
251      /**
252 <     * write-trylock fails if locked
252 >     * write-tryLock fails if locked
253       */
254      public void testWriteTryLockWhenLocked() {
255          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 268 | Line 269 | public class ReentrantReadWriteLockTest
269      }
270  
271      /**
272 <     * read-trylock fails if locked
272 >     * read-tryLock fails if locked
273       */
274      public void testReadTryLockWhenLocked() {
275          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 378 | Line 379 | public class ReentrantReadWriteLockTest
379  
380  
381      /**
382 <     * Read trylock succeeds if readlocked but not writelocked
382 >     * Read tryLock succeeds if readlocked but not writelocked
383       */
384      public void testTryLockWhenReadLocked() {
385          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 401 | Line 402 | public class ReentrantReadWriteLockTest
402      
403  
404      /**
405 <     * write trylock fails when readlocked
405 >     * write tryLock fails when readlocked
406       */
407      public void testWriteTryLockWhenReadLocked() {
408          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 423 | Line 424 | public class ReentrantReadWriteLockTest
424      
425  
426      /**
427 <     * write timed trylock times out if locked
427 >     * write timed tryLock times out if locked
428       */
429      public void testWriteTryLock_Timeout() {
430          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 447 | Line 448 | public class ReentrantReadWriteLockTest
448      }
449  
450      /**
451 <     * read timed trylock times out if write-locked
451 >     * read timed tryLock times out if write-locked
452       */
453      public void testReadTryLock_Timeout() {
454          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 938 | Line 939 | public class ReentrantReadWriteLockTest
939      }
940  
941      /**
942 +     * hasWaiters throws NPE if null
943 +     */
944 +    public void testHasWaitersNPE() {
945 +        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
946 +        try {
947 +            lock.hasWaiters(null);
948 +            shouldThrow();
949 +        } catch (NullPointerException success) {
950 +        } catch (Exception ex) {
951 +            unexpectedException();
952 +        }
953 +    }
954 +
955 +    /**
956 +     * getWaitQueueLength throws NPE if null
957 +     */
958 +    public void testGetWaitQueueLengthNPE() {
959 +        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
960 +        try {
961 +            lock.getWaitQueueLength(null);
962 +            shouldThrow();
963 +        } catch (NullPointerException success) {
964 +        } catch (Exception ex) {
965 +            unexpectedException();
966 +        }
967 +    }
968 +
969 +
970 +    /**
971 +     * getWaitingThreads throws NPE if null
972 +     */
973 +    public void testGetWaitingThreadsNPE() {
974 +        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
975 +        try {
976 +            lock.getWaitingThreads(null);
977 +            shouldThrow();
978 +        } catch (NullPointerException success) {
979 +        } catch (Exception ex) {
980 +            unexpectedException();
981 +        }
982 +    }
983 +
984 +    /**
985       * hasWaiters throws IAE if not owned
986       */
987      public void testHasWaitersIAE() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines