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(); |
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(); |
211 |
|
public void run() { |
212 |
|
try { |
213 |
|
lock.readLock().lockInterruptibly(); |
212 |
– |
threadShouldThrow(); |
214 |
|
} catch(InterruptedException success){} |
215 |
|
} |
216 |
|
}); |
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(); |
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(); |
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(); |
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(); |
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(); |
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(); |
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(); |
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() { |