229 |
|
public void testPoll() { |
230 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
231 |
|
for (int i = 0; i < SIZE; ++i) { |
232 |
< |
assertEquals(i, ((Integer)q.poll()).intValue()); |
232 |
> |
assertEquals(i, q.poll()); |
233 |
|
} |
234 |
|
assertNull(q.poll()); |
235 |
|
} |
240 |
|
public void testPeek() { |
241 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
242 |
|
for (int i = 0; i < SIZE; ++i) { |
243 |
< |
assertEquals(i, ((Integer)q.peek()).intValue()); |
244 |
< |
q.poll(); |
243 |
> |
assertEquals(i, q.peek()); |
244 |
> |
assertEquals(i, q.poll()); |
245 |
|
assertTrue(q.peek() == null || |
246 |
< |
i != ((Integer)q.peek()).intValue()); |
246 |
> |
!q.peek().equals(i)); |
247 |
|
} |
248 |
|
assertNull(q.peek()); |
249 |
|
} |
254 |
|
public void testElement() { |
255 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
256 |
|
for (int i = 0; i < SIZE; ++i) { |
257 |
< |
assertEquals(i, ((Integer)q.element()).intValue()); |
258 |
< |
q.poll(); |
257 |
> |
assertEquals(i, q.element()); |
258 |
> |
assertEquals(i, q.poll()); |
259 |
|
} |
260 |
|
try { |
261 |
|
q.element(); |
269 |
|
public void testRemove() { |
270 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
271 |
|
for (int i = 0; i < SIZE; ++i) { |
272 |
< |
assertEquals(i, ((Integer)q.remove()).intValue()); |
272 |
> |
assertEquals(i, q.remove()); |
273 |
|
} |
274 |
|
try { |
275 |
|
q.remove(); |
394 |
|
* toArray(null) throws NPE |
395 |
|
*/ |
396 |
|
public void testToArray_BadArg() { |
397 |
+ |
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
398 |
|
try { |
398 |
– |
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
399 |
|
Object o[] = q.toArray(null); |
400 |
|
shouldThrow(); |
401 |
|
} catch (NullPointerException success) {} |
405 |
|
* toArray with incompatible array type throws ArrayStoreException |
406 |
|
*/ |
407 |
|
public void testToArray1_BadArg() { |
408 |
+ |
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
409 |
|
try { |
410 |
< |
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
410 |
< |
Object o[] = q.toArray(new String[10] ); |
410 |
> |
Object o[] = q.toArray(new String[10]); |
411 |
|
shouldThrow(); |
412 |
|
} catch (ArrayStoreException success) {} |
413 |
|
} |
437 |
|
|
438 |
|
int k = 0; |
439 |
|
for (Iterator it = q.iterator(); it.hasNext();) { |
440 |
< |
int i = ((Integer)(it.next())).intValue(); |
441 |
< |
assertEquals(++k, i); |
440 |
> |
assertEquals(++k, it.next()); |
441 |
|
} |
442 |
|
|
443 |
|
assertEquals(3, k); |