Package net.openhft.chronicle.sandbox.queue

Examples of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue


    /**
     * Returns a new queue of given size containing consecutive
     * Integers 0 ... n.
     */
    private BlockingQueue populatedQueue(int n) {
        BlockingQueue q = new LocalConcurrentBlockingObjectQueue(n);
        assertTrue(q.isEmpty());
        for (int i = 0; i < n; i++)
            assertTrue(q.offer(new Integer(i)));
        assertFalse(q.isEmpty());
        assertEquals(0, q.remainingCapacity());
        assertEquals(n, q.size());
        return q;
    }
View Full Code Here


     * A new queue has the indicated capacity
     */

    @Test
    public void testConstructor1() {
        assertEquals(SIZE, new LocalConcurrentBlockingObjectQueue(SIZE).remainingCapacity());
    }
View Full Code Here

     * Constructor throws IAE if capacity argument nonpositive
     */
    @Test
    public void testConstructor2() {
        try {
            new LocalConcurrentBlockingObjectQueue(0);
            shouldThrow();
        } catch (IllegalArgumentException success) {
        }
    }
View Full Code Here

     */
    @Ignore
    @Test
    public void testConstructor3() {
        try {
            new LocalConcurrentBlockingObjectQueue(1, true, null);
            shouldThrow();
        } catch (NullPointerException success) {
        }
    }
View Full Code Here

    @Ignore
    @Test
    public void testConstructor4() {
        Collection<Integer> elements = Arrays.asList(new Integer[SIZE]);
        try {
            new LocalConcurrentBlockingObjectQueue(SIZE, false, elements);
            shouldThrow();
        } catch (NullPointerException success) {
        }
    }
View Full Code Here

        Integer[] ints = new Integer[SIZE];
        for (int i = 0; i < SIZE - 1; ++i)
            ints[i] = i;
        Collection<Integer> elements = Arrays.asList(ints);
        try {
            new LocalConcurrentBlockingObjectQueue(SIZE, false, Arrays.asList(ints));
            shouldThrow();
        } catch (NullPointerException success) {
        }
    }
View Full Code Here

        Integer[] ints = new Integer[SIZE];
        for (int i = 0; i < SIZE; ++i)
            ints[i] = i;
        Collection<Integer> elements = Arrays.asList(ints);
        try {
            new LocalConcurrentBlockingObjectQueue(SIZE - 1, false, elements);
            shouldThrow();
        } catch (IllegalArgumentException success) {
        }
    }
View Full Code Here

    public void testConstructor7() {
        Integer[] ints = new Integer[SIZE];
        for (int i = 0; i < SIZE; ++i)
            ints[i] = i;
        Collection<Integer> elements = Arrays.asList(ints);
        BlockingQueue q = new LocalConcurrentBlockingObjectQueue(SIZE, true, elements);
        for (int i = 0; i < SIZE; ++i)
            assertEquals(ints[i], q.poll());
    }
View Full Code Here

    /**
     * Queue transitions from empty to full when elements added
     */
    @Test
    public void testEmptyFull() {
        BlockingQueue q = new LocalConcurrentBlockingObjectQueue(2);
        assertTrue(q.isEmpty());
        assertEquals(2, q.remainingCapacity());
        q.add(one);
        assertFalse(q.isEmpty());
        q.add(two);
        assertFalse(q.isEmpty());
        assertEquals(0, q.remainingCapacity());
        assertFalse(q.offer(three));
    }
View Full Code Here

    /**
     * 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));
    }
View Full Code Here

TOP

Related Classes of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.