257 |
|
public void testPut() throws InterruptedException { |
258 |
|
ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); |
259 |
|
for (int i = 0; i < SIZE; ++i) { |
260 |
< |
Integer I = new Integer(i); |
261 |
< |
q.put(I); |
262 |
< |
assertTrue(q.contains(I)); |
260 |
> |
Integer x = new Integer(i); |
261 |
> |
q.put(x); |
262 |
> |
assertTrue(q.contains(x)); |
263 |
|
} |
264 |
|
assertEquals(0, q.remainingCapacity()); |
265 |
|
} |
587 |
|
assertTrue(q.removeAll(p)); |
588 |
|
assertEquals(SIZE-i, q.size()); |
589 |
|
for (int j = 0; j < i; ++j) { |
590 |
< |
Integer I = (Integer)(p.remove()); |
591 |
< |
assertFalse(q.contains(I)); |
590 |
> |
Integer x = (Integer)(p.remove()); |
591 |
> |
assertFalse(q.contains(x)); |
592 |
|
} |
593 |
|
} |
594 |
|
} |
698 |
|
public void testIterator() throws InterruptedException { |
699 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
700 |
|
Iterator it = q.iterator(); |
701 |
< |
while (it.hasNext()) { |
701 |
> |
int i; |
702 |
> |
for (i = 0; it.hasNext(); i++) |
703 |
> |
assertTrue(q.contains(it.next())); |
704 |
> |
assertEquals(i, SIZE); |
705 |
> |
assertIteratorExhausted(it); |
706 |
> |
|
707 |
> |
it = q.iterator(); |
708 |
> |
for (i = 0; it.hasNext(); i++) |
709 |
|
assertEquals(it.next(), q.take()); |
710 |
< |
} |
710 |
> |
assertEquals(i, SIZE); |
711 |
> |
assertIteratorExhausted(it); |
712 |
> |
} |
713 |
> |
|
714 |
> |
/** |
715 |
> |
* iterator of empty collection has no elements |
716 |
> |
*/ |
717 |
> |
public void testEmptyIterator() { |
718 |
> |
assertIteratorExhausted(new ArrayBlockingQueue(SIZE).iterator()); |
719 |
|
} |
720 |
|
|
721 |
|
/** |
909 |
|
assertEquals(SIZE-k, q.size()); |
910 |
|
for (int j = 0; j < k; ++j) |
911 |
|
assertEquals(l.get(j), new Integer(j)); |
912 |
< |
while (q.poll() != null) ; |
912 |
> |
do {} while (q.poll() != null); |
913 |
|
} |
914 |
|
} |
915 |
|
|