Java Code Examples for java.util.concurrent.LinkedBlockingDeque#toArray()

The following examples show how to use java.util.concurrent.LinkedBlockingDeque#toArray() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * toArray contains all elements in FIFO order
 */
public void testToArray() throws InterruptedException {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    Object[] o = q.toArray();
    for (int i = 0; i < o.length; i++)
        assertSame(o[i], q.poll());
}
 
Example 2
/**
 * toArray(a) contains all elements in FIFO order
 */
public void testToArray2() {
    LinkedBlockingDeque<Integer> q = populatedDeque(SIZE);
    Integer[] ints = new Integer[SIZE];
    Integer[] array = q.toArray(ints);
    assertSame(ints, array);
    for (int i = 0; i < ints.length; i++)
        assertSame(ints[i], q.remove());
}
 
Example 3
/**
 * toArray(incompatible array type) throws ArrayStoreException
 */
public void testToArray1_BadArg() {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    try {
        q.toArray(new String[10]);
        shouldThrow();
    } catch (ArrayStoreException success) {}
}
 
Example 4
Source Project: j2objc   File: LinkedBlockingDequeTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * toArray contains all elements in FIFO order
 */
public void testToArray() throws InterruptedException {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    Object[] o = q.toArray();
    for (int i = 0; i < o.length; i++)
        assertSame(o[i], q.poll());
}
 
Example 5
Source Project: j2objc   File: LinkedBlockingDequeTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * toArray(a) contains all elements in FIFO order
 */
public void testToArray2() {
    LinkedBlockingDeque<Integer> q = populatedDeque(SIZE);
    Integer[] ints = new Integer[SIZE];
    Integer[] array = q.toArray(ints);
    assertSame(ints, array);
    for (int i = 0; i < ints.length; i++)
        assertSame(ints[i], q.remove());
}
 
Example 6
Source Project: j2objc   File: LinkedBlockingDequeTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * toArray(incompatible array type) throws ArrayStoreException
 */
public void testToArray1_BadArg() {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    try {
        q.toArray(new String[10]);
        shouldThrow();
    } catch (ArrayStoreException success) {}
}