/** toArray(a) contains all elements */ public void testToArray2() { DelayQueue<PDelay> q = populatedQueue(SIZE); PDelay[] ints = new PDelay[SIZE]; PDelay[] array = q.toArray(ints); assertSame(ints, array); Arrays.sort(ints); for (int i = 0; i < ints.length; i++) assertSame(ints[i], q.remove()); }
/** toArray(incompatible array type) throws ArrayStoreException */ public void testToArray1_BadArg() { DelayQueue q = populatedQueue(SIZE); try { q.toArray(new String[10]); shouldThrow(); } catch (ArrayStoreException success) { } }
/** toArray contains all elements */ public void testToArray() throws InterruptedException { DelayQueue q = populatedQueue(SIZE); Object[] o = q.toArray(); Arrays.sort(o); for (int i = 0; i < o.length; i++) assertSame(o[i], q.take()); }