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

The following examples show how to use java.util.concurrent.LinkedBlockingDeque#toArray() . 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
Source File: LinkedBlockingDequeTest.java    From openjdk-jdk9 with GNU General Public License v2.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 2
Source File: LinkedBlockingDequeTest.java    From openjdk-jdk9 with GNU General Public License v2.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 3
Source File: LinkedBlockingDequeTest.java    From openjdk-jdk9 with GNU General Public License v2.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) {}
}
 
Example 4
Source File: LinkedBlockingDequeTest.java    From j2objc with 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 File: LinkedBlockingDequeTest.java    From j2objc with 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 File: LinkedBlockingDequeTest.java    From j2objc with 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) {}
}