109 |
|
* Create a queue of given size containing consecutive |
110 |
|
* PDelays 0 ... n. |
111 |
|
*/ |
112 |
< |
private DelayQueue populatedQueue(int n) { |
113 |
< |
DelayQueue q = new DelayQueue(); |
112 |
> |
private DelayQueue<PDelay> populatedQueue(int n) { |
113 |
> |
DelayQueue<PDelay> q = new DelayQueue<PDelay>(); |
114 |
|
assertTrue(q.isEmpty()); |
115 |
|
for (int i = n-1; i >= 0; i-=2) |
116 |
|
assertTrue(q.offer(new PDelay(i))); |
402 |
|
try { |
403 |
|
q.take(); |
404 |
|
shouldThrow(); |
405 |
< |
} catch (InterruptedException expected) {} |
405 |
> |
} catch (InterruptedException success) {} |
406 |
|
assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS); |
407 |
|
}}); |
408 |
|
threadStarted.await(); |
676 |
|
Object[] o = q.toArray(); |
677 |
|
Arrays.sort(o); |
678 |
|
for (int i = 0; i < o.length; i++) |
679 |
< |
assertEquals(o[i], q.take()); |
679 |
> |
assertSame(o[i], q.take()); |
680 |
|
} |
681 |
|
|
682 |
|
/** |
683 |
|
* toArray(a) contains all elements |
684 |
|
*/ |
685 |
< |
public void testToArray2() throws InterruptedException { |
686 |
< |
DelayQueue q = populatedQueue(SIZE); |
685 |
> |
public void testToArray2() { |
686 |
> |
DelayQueue<PDelay> q = populatedQueue(SIZE); |
687 |
|
PDelay[] ints = new PDelay[SIZE]; |
688 |
< |
ints = (PDelay[])q.toArray(ints); |
688 |
> |
PDelay[] array = q.toArray(ints); |
689 |
> |
assertSame(ints, array); |
690 |
|
Arrays.sort(ints); |
691 |
|
for (int i = 0; i < ints.length; i++) |
692 |
< |
assertEquals(ints[i], q.take()); |
692 |
> |
assertSame(ints[i], q.remove()); |
693 |
|
} |
694 |
|
|
695 |
|
|