422 }
423
424 /**
425 * toArray(a) contains all elements in FIFO order
426 */
427 public void testToArray2() {
428 ConcurrentLinkedQueue<Integer> q = populatedQueue(SIZE);
429 Integer[] ints = new Integer[SIZE];
430 Integer[] array = q.toArray(ints);
431 assertSame(ints, array);
432 for (int i = 0; i < ints.length; i++)
433 assertSame(ints[i], q.poll());
434 }
435
436 /**
437 * toArray(null) throws NullPointerException
438 */
439 public void testToArray_NullArg() {
440 ConcurrentLinkedQueue q = populatedQueue(SIZE);
441 try {
442 q.toArray(null);
443 shouldThrow();
444 } catch (NullPointerException success) {}
445 }
446
447 /**
448 * toArray(incompatible array type) throws ArrayStoreException
449 */
450 public void testToArray1_BadArg() {
451 ConcurrentLinkedQueue q = populatedQueue(SIZE);
452 try {
453 q.toArray(new String[10]);
454 shouldThrow();
455 } catch (ArrayStoreException success) {}
456 }
457
458 /**
459 * iterator iterates through all elements
460 */
461 public void testIterator() {
462 ConcurrentLinkedQueue q = populatedQueue(SIZE);
|
422 }
423
424 /**
425 * toArray(a) contains all elements in FIFO order
426 */
427 public void testToArray2() {
428 ConcurrentLinkedQueue<Integer> q = populatedQueue(SIZE);
429 Integer[] ints = new Integer[SIZE];
430 Integer[] array = q.toArray(ints);
431 assertSame(ints, array);
432 for (int i = 0; i < ints.length; i++)
433 assertSame(ints[i], q.poll());
434 }
435
436 /**
437 * toArray(null) throws NullPointerException
438 */
439 public void testToArray_NullArg() {
440 ConcurrentLinkedQueue q = populatedQueue(SIZE);
441 try {
442 q.toArray((Object[])null);
443 shouldThrow();
444 } catch (NullPointerException success) {}
445 }
446
447 /**
448 * toArray(incompatible array type) throws ArrayStoreException
449 */
450 public void testToArray1_BadArg() {
451 ConcurrentLinkedQueue q = populatedQueue(SIZE);
452 try {
453 q.toArray(new String[10]);
454 shouldThrow();
455 } catch (ArrayStoreException success) {}
456 }
457
458 /**
459 * iterator iterates through all elements
460 */
461 public void testIterator() {
462 ConcurrentLinkedQueue q = populatedQueue(SIZE);
|