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.17 by dl, Thu Jan 8 01:29:46 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 185 | Line 187 | public class ReentrantReadWriteLockTest
187                  public void run() {
188                      try {
189                          lock.writeLock().tryLock(1000,TimeUnit.MILLISECONDS);
188                        threadShouldThrow();
190                      } catch(InterruptedException success){}
191                  }
192              });
# Line 209 | Line 210 | public class ReentrantReadWriteLockTest
210                  public void run() {
211                      try {
212                          lock.readLock().lockInterruptibly();
212                        threadShouldThrow();
213                      } catch(InterruptedException success){}
214                  }
215              });
# Line 224 | Line 224 | public class ReentrantReadWriteLockTest
224      }
225  
226      /**
227 <     * timed read-trylock is interruptible
227 >     * timed read-tryLock is interruptible
228       */
229      public void testReadTryLock_Interrupted() {
230          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 248 | Line 248 | public class ReentrantReadWriteLockTest
248  
249      
250      /**
251 <     * write-trylock fails if locked
251 >     * write-tryLock fails if locked
252       */
253      public void testWriteTryLockWhenLocked() {
254          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 268 | Line 268 | public class ReentrantReadWriteLockTest
268      }
269  
270      /**
271 <     * read-trylock fails if locked
271 >     * read-tryLock fails if locked
272       */
273      public void testReadTryLockWhenLocked() {
274          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 378 | Line 378 | public class ReentrantReadWriteLockTest
378  
379  
380      /**
381 <     * Read trylock succeeds if readlocked but not writelocked
381 >     * Read tryLock succeeds if readlocked but not writelocked
382       */
383      public void testTryLockWhenReadLocked() {
384          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 401 | Line 401 | public class ReentrantReadWriteLockTest
401      
402  
403      /**
404 <     * write trylock fails when readlocked
404 >     * write tryLock fails when readlocked
405       */
406      public void testWriteTryLockWhenReadLocked() {
407          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 423 | Line 423 | public class ReentrantReadWriteLockTest
423      
424  
425      /**
426 <     * write timed trylock times out if locked
426 >     * write timed tryLock times out if locked
427       */
428      public void testWriteTryLock_Timeout() {
429          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 447 | Line 447 | public class ReentrantReadWriteLockTest
447      }
448  
449      /**
450 <     * read timed trylock times out if write-locked
450 >     * read timed tryLock times out if write-locked
451       */
452      public void testReadTryLock_Timeout() {
453          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
# Line 938 | Line 938 | public class ReentrantReadWriteLockTest
938      }
939  
940      /**
941 +     * hasWaiters throws NPE if null
942 +     */
943 +    public void testHasWaitersNPE() {
944 +        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
945 +        try {
946 +            lock.hasWaiters(null);
947 +            shouldThrow();
948 +        } catch (NullPointerException success) {
949 +        } catch (Exception ex) {
950 +            unexpectedException();
951 +        }
952 +    }
953 +
954 +    /**
955 +     * getWaitQueueLength throws NPE if null
956 +     */
957 +    public void testGetWaitQueueLengthNPE() {
958 +        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
959 +        try {
960 +            lock.getWaitQueueLength(null);
961 +            shouldThrow();
962 +        } catch (NullPointerException success) {
963 +        } catch (Exception ex) {
964 +            unexpectedException();
965 +        }
966 +    }
967 +
968 +
969 +    /**
970 +     * getWaitingThreads throws NPE if null
971 +     */
972 +    public void testGetWaitingThreadsNPE() {
973 +        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
974 +        try {
975 +            lock.getWaitingThreads(null);
976 +            shouldThrow();
977 +        } catch (NullPointerException success) {
978 +        } catch (Exception ex) {
979 +            unexpectedException();
980 +        }
981 +    }
982 +
983 +    /**
984       * hasWaiters throws IAE if not owned
985       */
986      public void testHasWaitersIAE() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines