284 |
|
*/ |
285 |
|
public void testBlockingTake() throws InterruptedException { |
286 |
|
final LinkedTransferQueue<Integer> q = populatedQueue(SIZE); |
287 |
< |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
288 |
< |
void realRun() throws InterruptedException { |
287 |
> |
Thread t = new Thread(new CheckedRunnable() { |
288 |
> |
public void realRun() throws InterruptedException { |
289 |
|
for (int i = 0; i < SIZE; ++i) { |
290 |
< |
threadAssertEquals(i, (int) q.take()); |
290 |
> |
assertEquals(i, (int) q.take()); |
291 |
|
} |
292 |
< |
q.take(); |
292 |
> |
try { |
293 |
> |
q.take(); |
294 |
> |
shouldThrow(); |
295 |
> |
} catch (InterruptedException success) {} |
296 |
|
}}); |
297 |
< |
Thread.sleep(SMALL_DELAY_MS); |
297 |
> |
|
298 |
> |
t.start(); |
299 |
> |
Thread.sleep(SHORT_DELAY_MS); |
300 |
|
t.interrupt(); |
301 |
|
t.join(); |
302 |
|
checkEmpty(q); |
374 |
|
*/ |
375 |
|
public void testTimedPollWithOffer() throws InterruptedException { |
376 |
|
final LinkedTransferQueue q = new LinkedTransferQueue(); |
377 |
< |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
377 |
> |
Thread t = new Thread(new CheckedRunnable() { |
378 |
|
void realRun() throws InterruptedException { |
379 |
< |
threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
380 |
< |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
381 |
< |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
379 |
> |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
380 |
> |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
381 |
> |
try { |
382 |
> |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
383 |
> |
shouldThrow(); |
384 |
> |
} catch (InterruptedException success) {} |
385 |
|
}}); |
386 |
+ |
|
387 |
+ |
t.start(); |
388 |
|
Thread.sleep(SMALL_DELAY_MS); |
389 |
|
assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); |
390 |
|
t.interrupt(); |
570 |
|
* toArray(null) throws NullPointerException |
571 |
|
*/ |
572 |
|
public void testToArray_BadArg() { |
573 |
+ |
LinkedTransferQueue q = populatedQueue(SIZE); |
574 |
|
try { |
564 |
– |
LinkedTransferQueue q = populatedQueue(SIZE); |
575 |
|
Object o[] = q.toArray(null); |
576 |
|
shouldThrow(); |
577 |
|
} catch (NullPointerException success) {} |
581 |
|
* toArray(incompatible array type) throws CCE |
582 |
|
*/ |
583 |
|
public void testToArray1_BadArg() { |
584 |
+ |
LinkedTransferQueue q = populatedQueue(SIZE); |
585 |
|
try { |
575 |
– |
LinkedTransferQueue q = populatedQueue(SIZE); |
586 |
|
Object o[] = q.toArray(new String[10]); |
587 |
|
shouldThrow(); |
588 |
|
} catch (ArrayStoreException success) {} |