Search in sources :

Example 11 with LocalConcurrentBlockingObjectQueue

use of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue in project HugeCollections-OLD by peter-lawrey.

the class LocalJSR166TestCase method testToArray2.

/**
     * toArray(a) contains all elements in FIFO order
     */
@Ignore
@Test
public void testToArray2() {
    BlockingQueue q = new LocalConcurrentBlockingObjectQueue(SIZE);
    for (int i = 0; i < SIZE; i++) {
        checkToArray2(q);
        q.add(i);
    }
    // Provoke wraparound
    for (int i = 0; i < SIZE; i++) {
        checkToArray2(q);
        assertEquals(i, q.poll());
        checkToArray2(q);
        q.add(SIZE + i);
    }
    for (int i = 0; i < SIZE; i++) {
        checkToArray2(q);
        assertEquals(SIZE + i, q.poll());
    }
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) LocalConcurrentBlockingObjectQueue(net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with LocalConcurrentBlockingObjectQueue

use of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue in project HugeCollections-OLD by peter-lawrey.

the class LocalJSR166TestCase method testIteratorRemove.

/**
     * iterator.remove removes current element
     */
@Ignore
@Test
public void testIteratorRemove() {
    final BlockingQueue q = new LocalConcurrentBlockingObjectQueue(3);
    q.add(two);
    q.add(one);
    q.add(three);
    Iterator it = q.iterator();
    it.next();
    it.remove();
    it = q.iterator();
    assertSame(it.next(), one);
    assertSame(it.next(), three);
    assertFalse(it.hasNext());
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) LocalConcurrentBlockingObjectQueue(net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with LocalConcurrentBlockingObjectQueue

use of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue in project HugeCollections-OLD by peter-lawrey.

the class LocalJSR166TestCase method testAddAll4.

/**
     * addAll throws ISE if not enough room
     */
@Test
public void testAddAll4() {
    try {
        BlockingQueue q = new LocalConcurrentBlockingObjectQueue(1);
        Integer[] ints = new Integer[SIZE];
        for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(i);
        q.addAll(Arrays.asList(ints));
        shouldThrow();
    } catch (IllegalStateException success) {
    }
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) LocalConcurrentBlockingObjectQueue(net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue) Test(org.junit.Test)

Example 14 with LocalConcurrentBlockingObjectQueue

use of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue in project HugeCollections-OLD by peter-lawrey.

the class LocalJSR166TestCase method testOffer.

/**
     * Offer succeeds if not full; fails if full
     */
@Test
public void testOffer() {
    BlockingQueue q = new LocalConcurrentBlockingObjectQueue(1);
    assertTrue(q.offer(zero));
    assertFalse(q.offer(one));
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) LocalConcurrentBlockingObjectQueue(net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue) Test(org.junit.Test)

Example 15 with LocalConcurrentBlockingObjectQueue

use of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue in project HugeCollections-OLD by peter-lawrey.

the class LocalJSR166TestCase method testAddAll5.

/**
     * Queue contains all elements, in traversal order, of successful addAll
     */
@Test
public void testAddAll5() {
    Integer[] empty = new Integer[0];
    Integer[] ints = new Integer[SIZE];
    for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(i);
    BlockingQueue q = new LocalConcurrentBlockingObjectQueue(SIZE);
    assertFalse(q.addAll(Arrays.asList(empty)));
    assertTrue(q.addAll(Arrays.asList(ints)));
    for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], q.poll());
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) LocalConcurrentBlockingObjectQueue(net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue) Test(org.junit.Test)

Aggregations

BlockingQueue (java.util.concurrent.BlockingQueue)21 LocalConcurrentBlockingObjectQueue (net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue)21 Test (org.junit.Test)20 Ignore (org.junit.Ignore)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 ExecutorService (java.util.concurrent.ExecutorService)2