43 |
|
} |
44 |
|
|
45 |
|
/** |
46 |
< |
* Initializing from null Collection throws NPE |
46 |
> |
* Initializing from null Collection throws NPE |
47 |
|
*/ |
48 |
|
public void testConstructor3() { |
49 |
|
try { |
265 |
|
} |
266 |
|
|
267 |
|
/** |
268 |
< |
* remove removes next element, or throws NSEE if empty |
268 |
> |
* remove removes next element, or throws NSEE if empty |
269 |
|
*/ |
270 |
|
public void testRemove() { |
271 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
369 |
|
} |
370 |
|
|
371 |
|
/** |
372 |
< |
* toArray contains all elements |
372 |
> |
* toArray contains all elements in FIFO order |
373 |
|
*/ |
374 |
|
public void testToArray() { |
375 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
376 |
|
Object[] o = q.toArray(); |
377 |
– |
Arrays.sort(o); |
377 |
|
for (int i = 0; i < o.length; i++) |
378 |
< |
assertEquals(o[i], q.poll()); |
378 |
> |
assertSame(o[i], q.poll()); |
379 |
|
} |
380 |
|
|
381 |
|
/** |
382 |
< |
* toArray(a) contains all elements |
382 |
> |
* toArray(a) contains all elements in FIFO order |
383 |
|
*/ |
384 |
|
public void testToArray2() { |
385 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
386 |
|
Integer[] ints = new Integer[SIZE]; |
387 |
< |
ints = (Integer[])q.toArray(ints); |
389 |
< |
Arrays.sort(ints); |
387 |
> |
assertSame(ints, q.toArray(ints)); |
388 |
|
for (int i = 0; i < ints.length; i++) |
389 |
< |
assertEquals(ints[i], q.poll()); |
389 |
> |
assertSame(ints[i], q.poll()); |
390 |
|
} |
391 |
|
|
392 |
|
/** |
393 |
< |
* toArray(null) throws NPE |
393 |
> |
* toArray(null) throws NullPointerException |
394 |
|
*/ |
395 |
< |
public void testToArray_BadArg() { |
395 |
> |
public void testToArray_NullArg() { |
396 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
397 |
|
try { |
398 |
< |
Object o[] = q.toArray(null); |
398 |
> |
q.toArray(null); |
399 |
|
shouldThrow(); |
400 |
|
} catch (NullPointerException success) {} |
401 |
|
} |
402 |
|
|
403 |
|
/** |
404 |
< |
* toArray with incompatible array type throws ArrayStoreException |
404 |
> |
* toArray(incompatible array type) throws ArrayStoreException |
405 |
|
*/ |
406 |
|
public void testToArray1_BadArg() { |
407 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |
408 |
|
try { |
409 |
< |
Object o[] = q.toArray(new String[10]); |
409 |
> |
q.toArray(new String[10]); |
410 |
|
shouldThrow(); |
411 |
|
} catch (ArrayStoreException success) {} |
412 |
|
} |
413 |
|
|
414 |
|
/** |
415 |
< |
* iterator iterates through all elements |
415 |
> |
* iterator iterates through all elements |
416 |
|
*/ |
417 |
|
public void testIterator() { |
418 |
|
ConcurrentLinkedQueue q = populatedQueue(SIZE); |