502 |
|
public void testPeek() { |
503 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
504 |
|
for (int i = 0; i < SIZE; ++i) { |
505 |
< |
assertEquals(i, ((Integer)q.peek()).intValue()); |
506 |
< |
q.poll(); |
505 |
> |
assertEquals(i, q.peek()); |
506 |
> |
assertEquals(i, q.poll()); |
507 |
|
assertTrue(q.peek() == null || |
508 |
< |
i != ((Integer)q.peek()).intValue()); |
508 |
> |
!q.peek().equals(i)); |
509 |
|
} |
510 |
|
assertNull(q.peek()); |
511 |
|
} |
516 |
|
public void testElement() { |
517 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
518 |
|
for (int i = 0; i < SIZE; ++i) { |
519 |
< |
assertEquals(i, ((Integer)q.element()).intValue()); |
520 |
< |
q.poll(); |
519 |
> |
assertEquals(i, q.element()); |
520 |
> |
assertEquals(i, q.poll()); |
521 |
|
} |
522 |
|
try { |
523 |
|
q.element(); |
531 |
|
public void testRemove() { |
532 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
533 |
|
for (int i = 0; i < SIZE; ++i) { |
534 |
< |
assertEquals(i, ((Integer)q.remove()).intValue()); |
534 |
> |
assertEquals(i, q.remove()); |
535 |
|
} |
536 |
|
try { |
537 |
|
q.remove(); |
561 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
562 |
|
for (int i = 0; i < SIZE; ++i) { |
563 |
|
assertTrue(q.contains(new Integer(i))); |
564 |
< |
q.poll(); |
564 |
> |
assertEquals(i, q.poll()); |
565 |
|
assertFalse(q.contains(new Integer(i))); |
566 |
|
} |
567 |
|
} |
656 |
|
* toArray(null) throws NPE |
657 |
|
*/ |
658 |
|
public void testToArray_BadArg() { |
659 |
+ |
ArrayBlockingQueue q = populatedQueue(SIZE); |
660 |
|
try { |
660 |
– |
ArrayBlockingQueue q = populatedQueue(SIZE); |
661 |
|
Object o[] = q.toArray(null); |
662 |
|
shouldThrow(); |
663 |
|
} catch (NullPointerException success) {} |
667 |
|
* toArray with incompatible array type throws CCE |
668 |
|
*/ |
669 |
|
public void testToArray1_BadArg() { |
670 |
+ |
ArrayBlockingQueue q = populatedQueue(SIZE); |
671 |
|
try { |
672 |
< |
ArrayBlockingQueue q = populatedQueue(SIZE); |
672 |
< |
Object o[] = q.toArray(new String[10] ); |
672 |
> |
Object o[] = q.toArray(new String[10]); |
673 |
|
shouldThrow(); |
674 |
|
} catch (ArrayStoreException success) {} |
675 |
|
} |
718 |
|
|
719 |
|
int k = 0; |
720 |
|
for (Iterator it = q.iterator(); it.hasNext();) { |
721 |
< |
int i = ((Integer)(it.next())).intValue(); |
722 |
< |
assertEquals(++k, i); |
721 |
> |
assertEquals(++k, it.next()); |
722 |
|
} |
723 |
|
assertEquals(3, k); |
724 |
|
} |