366 |
|
} |
367 |
|
|
368 |
|
/** |
369 |
– |
* take blocks interruptibly when empty |
370 |
– |
*/ |
371 |
– |
public void testTakeFromEmpty() throws InterruptedException { |
372 |
– |
final PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
373 |
– |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
374 |
– |
public void realRun() throws InterruptedException { |
375 |
– |
q.take(); |
376 |
– |
}}); |
377 |
– |
|
378 |
– |
t.start(); |
379 |
– |
Thread.sleep(SHORT_DELAY_MS); |
380 |
– |
t.interrupt(); |
381 |
– |
t.join(); |
382 |
– |
} |
383 |
– |
|
384 |
– |
/** |
369 |
|
* Take removes existing elements until empty, then blocks interruptibly |
370 |
|
*/ |
371 |
|
public void testBlockingTake() throws InterruptedException { |
400 |
|
} |
401 |
|
|
402 |
|
/** |
403 |
< |
* timed pool with zero timeout succeeds when non-empty, else times out |
403 |
> |
* timed poll with zero timeout succeeds when non-empty, else times out |
404 |
|
*/ |
405 |
|
public void testTimedPoll0() throws InterruptedException { |
406 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
411 |
|
} |
412 |
|
|
413 |
|
/** |
414 |
< |
* timed pool with nonzero timeout succeeds when non-empty, else times out |
414 |
> |
* timed poll with nonzero timeout succeeds when non-empty, else times out |
415 |
|
*/ |
416 |
|
public void testTimedPoll() throws InterruptedException { |
417 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
602 |
|
} |
603 |
|
|
604 |
|
/** |
605 |
< |
* toArray(null) throws NPE |
605 |
> |
* toArray(null) throws NullPointerException |
606 |
|
*/ |
607 |
< |
public void testToArray_BadArg() { |
607 |
> |
public void testToArray_NullArg() { |
608 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
609 |
|
try { |
610 |
< |
Object o[] = q.toArray(null); |
610 |
> |
q.toArray(null); |
611 |
|
shouldThrow(); |
612 |
|
} catch (NullPointerException success) {} |
613 |
|
} |
614 |
|
|
615 |
|
/** |
616 |
< |
* toArray with incompatible array type throws CCE |
616 |
> |
* toArray(incompatible array type) throws ArrayStoreException |
617 |
|
*/ |
618 |
|
public void testToArray1_BadArg() { |
619 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
620 |
|
try { |
621 |
< |
Object o[] = q.toArray(new String[10]); |
621 |
> |
q.toArray(new String[10]); |
622 |
|
shouldThrow(); |
623 |
|
} catch (ArrayStoreException success) {} |
624 |
|
} |
806 |
|
assertTrue(q.offer(new Integer(j))); |
807 |
|
ArrayList l = new ArrayList(); |
808 |
|
q.drainTo(l, i); |
809 |
< |
int k = (i < SIZE)? i : SIZE; |
809 |
> |
int k = (i < SIZE) ? i : SIZE; |
810 |
|
assertEquals(l.size(), k); |
811 |
|
assertEquals(q.size(), SIZE-k); |
812 |
|
for (int j = 0; j < k; ++j) |