src/test/java/org/mapdb/jsr166Tests/BlockingQueueTest.java
public void testTimedPollWithOffer() throws InterruptedException {
        final BlockingQueue q = emptyCollection();
        final CheckedBarrier barrier = new CheckedBarrier(2);
        final Object zero = makeElement(0);
        Thread t = newStartedThread(new CheckedRunnable() {
            public void realRun() throws InterruptedException {
                long startTime = System.nanoTime();
                assertNull(q.poll(timeoutMillis(), MILLISECONDS));
                assertTrue(millisElapsedSince(startTime) >= timeoutMillis());

                barrier.await();

                assertEquals(zero, q.poll(LONG_DELAY_MS, MILLISECONDS));

                Thread.currentThread().interrupt();
                try {
                    q.poll(LONG_DELAY_MS, MILLISECONDS);
                    shouldThrow();
                } catch (InterruptedException success) {}
                assertFalse(Thread.interrupted());

                barrier.await();
                try {
                    q.poll(LONG_DELAY_MS, MILLISECONDS);
                    shouldThrow();
                } catch (InterruptedException success) {}
                assertFalse(Thread.interrupted());

                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
            }});

        barrier.await();
        long startTime = System.nanoTime();
        assertTrue(q.offer(zero, LONG_DELAY_MS, MILLISECONDS));
        assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);

        barrier.await();
        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
        t.interrupt();
        awaitTermination(t);
    }
/**
     * timed poll before a delayed offer times out; after offer succeeds;
     * on interruption throws
     */
timed poll before a delayed offer times out; after offer succeeds;
on interruption throws
timed poll before a delayed offer times out ; after offer succeeds ; on interruption throws
public void testTimedPollWithOffer() throws InterruptedException {
        final BlockingQueue q = emptyCollection();
        final CheckedBarrier barrier = new CheckedBarrier(2);
        final Object zero = makeElement(0);
        Thread t = newStartedThread(new CheckedRunnable() {
            public void realRun() throws InterruptedException {
                long startTime = System.nanoTime();
                assertNull(q.poll(timeoutMillis(), MILLISECONDS));
                assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
                barrier.await();
                assertEquals(zero, q.poll(LONG_DELAY_MS, MILLISECONDS));
                Thread.currentThread().interrupt();
                try {
                    q.poll(LONG_DELAY_MS, MILLISECONDS);
                    shouldThrow();
                } catch (InterruptedException success) {}
                assertFalse(Thread.interrupted());
                barrier.await();
                try {
                    q.poll(LONG_DELAY_MS, MILLISECONDS);
                    shouldThrow();
                } catch (InterruptedException success) {}
                assertFalse(Thread.interrupted());
                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
            }});
        barrier.await();
        long startTime = System.nanoTime();
        assertTrue(q.offer(zero, LONG_DELAY_MS, MILLISECONDS));
        assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
        barrier.await();
        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
        t.interrupt();
        awaitTermination(t);
    }
public void testTimedPollWithOffer ( ) throws InterruptedException { final BlockingQueue q = emptyCollection ( ) ; final CheckedBarrier barrier = new CheckedBarrier ( 2 ) ; final Object zero = makeElement ( 0 ) ; Thread t = newStartedThread ( new CheckedRunnable ( ) { public void realRun ( ) throws InterruptedException { long startTime = System . nanoTime ( ) ; assertNull ( q . poll ( timeoutMillis ( ) , MILLISECONDS ) ) ; assertTrue ( millisElapsedSince ( startTime ) >= timeoutMillis ( ) ) ; barrier . await ( ) ; assertEquals ( zero , q . poll ( LONG_DELAY_MS , MILLISECONDS ) ) ; Thread . currentThread ( ) . interrupt ( ) ; try { q . poll ( LONG_DELAY_MS , MILLISECONDS ) ; shouldThrow ( ) ; } catch ( InterruptedException success ) { } assertFalse ( Thread . interrupted ( ) ) ; barrier . await ( ) ; try { q . poll ( LONG_DELAY_MS , MILLISECONDS ) ; shouldThrow ( ) ; } catch ( InterruptedException success ) { } assertFalse ( Thread . interrupted ( ) ) ; assertTrue ( millisElapsedSince ( startTime ) < LONG_DELAY_MS ) ; } } ) ; barrier . await ( ) ; long startTime = System . nanoTime ( ) ; assertTrue ( q . offer ( zero , LONG_DELAY_MS , MILLISECONDS ) ) ; assertTrue ( millisElapsedSince ( startTime ) < LONG_DELAY_MS ) ; barrier . await ( ) ; assertThreadBlocks ( t , Thread . State . TIMED_WAITING ) ; t . interrupt ( ) ; awaitTermination ( t ) ; }
timed poll before a delayed offer times out; after offer succeeds;
 on interruption throws
timed poll before a delayed offer times out ; after offer succeeds ; on interruption throws