Class LinkedBlockingDequeTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by JSR166TestCase
              extended by LinkedBlockingDequeTest
All Implemented Interfaces:
junit.framework.Test

public class LinkedBlockingDequeTest
extends JSR166TestCase


Nested Class Summary
static class LinkedBlockingDequeTest.Bounded
           
static class LinkedBlockingDequeTest.Unbounded
           
 
Nested classes/interfaces inherited from class JSR166TestCase
JSR166TestCase.AdjustablePolicy, JSR166TestCase.CallableOne, JSR166TestCase.CheckedBarrier, JSR166TestCase.CheckedCallable<T>, JSR166TestCase.CheckedInterruptedCallable<T>, JSR166TestCase.CheckedInterruptedRunnable, JSR166TestCase.CheckedRecursiveAction, JSR166TestCase.CheckedRecursiveTask<T>, JSR166TestCase.CheckedRunnable, JSR166TestCase.LongPossiblyInterruptedRunnable, JSR166TestCase.MediumInterruptedRunnable, JSR166TestCase.MediumPossiblyInterruptedRunnable, JSR166TestCase.MediumRunnable, JSR166TestCase.NoOpCallable, JSR166TestCase.NoOpREHandler, JSR166TestCase.NoOpRunnable, JSR166TestCase.NPETask, JSR166TestCase.RunnableShouldThrow, JSR166TestCase.ShortInterruptedRunnable, JSR166TestCase.ShortRunnable, JSR166TestCase.SimpleThreadFactory, JSR166TestCase.SmallCallable, JSR166TestCase.SmallPossiblyInterruptedRunnable, JSR166TestCase.SmallRunnable, JSR166TestCase.StringTask, JSR166TestCase.ThreadShouldThrow, JSR166TestCase.TrackedCallable, JSR166TestCase.TrackedLongRunnable, JSR166TestCase.TrackedMediumRunnable, JSR166TestCase.TrackedNoOpRunnable, JSR166TestCase.TrackedRunnable, JSR166TestCase.TrackedShortRunnable, JSR166TestCase.TrackedSmallRunnable
 
Field Summary
 
Fields inherited from class JSR166TestCase
eight, expensiveTests, five, four, LONG_DELAY_MS, m1, m10, m2, m3, m4, m5, m6, MEDIUM_DELAY_MS, nine, one, seven, SHORT_DELAY_MS, six, SIZE, SMALL_DELAY_MS, TEST_STRING, three, two, zero
 
Constructor Summary
LinkedBlockingDequeTest()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testAdd()
          add succeeds if not full; throws ISE if full
 void testAddAll1()
          addAll(null) throws NPE
 void testAddAll2()
          addAll of a collection with null elements throws NPE
 void testAddAll3()
          addAll of a collection with any null elements throws NPE after possibly adding some elements
 void testAddAll4()
          addAll throws ISE if not enough room
 void testAddAll5()
          Deque contains all elements, in traversal order, of successful addAll
 void testAddAllSelf()
          addAll(this) throws IAE
 void testAddFirst()
          peekFirst returns element inserted with addFirst
 void testAddLast()
          peekLast returns element inserted with addLast
 void testAddNull()
          add(null) throws NPE
 void testBlockingPut()
          put blocks interruptibly if full
 void testBlockingPutFirst()
          putFirst blocks interruptibly if full
 void testBlockingPutLast()
          putLast blocks interruptibly if full
 void testBlockingTake()
          Take removes existing elements until empty, then blocks interruptibly
 void testBlockingTakeFirst()
          TakeFirst removes existing elements until empty, then blocks interruptibly
 void testBlockingTakeLast()
          TakeLast removes existing elements until empty, then blocks interruptibly
 void testClear()
          clear removes all elements
 void testConstructor1()
          A new deque has the indicated capacity, or Integer.MAX_VALUE if none given
 void testConstructor2()
          Constructor throws IAE if capacity argument nonpositive
 void testConstructor3()
          Initializing from null Collection throws NPE
 void testConstructor4()
          Initializing from Collection of null elements throws NPE
 void testConstructor5()
          Initializing from Collection with some null elements throws NPE
 void testConstructor6()
          Deque contains all elements of collection used to initialize
 void testContains()
          contains(x) reports true when elements added but not yet removed
 void testContainsAll()
          containsAll(c) is true when c contains a subset of elements
 void testDescendingIterator()
          Descending iterator iterates through all elements
 void testDescendingIteratorOrdering()
          Descending iterator ordering is reverse FIFO
 void testDescendingIteratorRemove()
          descendingIterator.remove removes current element
 void testDrainTo()
          drainTo(c) empties deque into another collection c
 void testDrainToN()
          drainTo(c, n) empties first min(n, size) elements of queue into c
 void testDrainToNull()
          drainTo(null) throws NPE
 void testDrainToNullN()
          drainTo(null, n) throws NPE
 void testDrainToSelf()
          drainTo(this) throws IAE
 void testDrainToSelfN()
          drainTo(this, n) throws IAE
 void testDrainToWithActivePut()
          drainTo empties full deque, unblocking a waiting put.
 void testElement()
          element returns next element, or throws NSEE if empty
 void testEmpty()
          isEmpty is true before add, false after
 void testEmptyFull()
          Deque transitions from empty to full when elements added
 void testFirstElement()
          getFirst() returns first element, or throws NSEE if empty
 void testInterruptedTimedPoll()
          Interrupted timed poll throws InterruptedException instead of returning timeout status
 void testInterruptedTimedPollFirst()
          Interrupted timed pollFirst throws InterruptedException instead of returning timeout status
 void testInterruptedTimedPollLast()
          Interrupted timed pollLast throws InterruptedException instead of returning timeout status
 void testIterator()
          iterator iterates through all elements
 void testIteratorOrdering()
          iterator ordering is FIFO
 void testIteratorRemove()
          iterator.remove removes current element
 void testLastElement()
          getLast() returns last element, or throws NSEE if empty
 void testOffer()
          Offer succeeds if not full; fails if full
 void testOfferFirst()
          OfferFirst succeeds
 void testOfferFirstNull()
          offer(null) throws NPE
 void testOfferInExecutor()
          offer transfers elements across Executor tasks
 void testOfferLast()
          OfferLast succeeds
 void testOfferNull()
          offer(null) throws NPE
 void testPeek()
          peek returns next element, or null if empty
 void testPeekFirst()
          peekFirst returns next element, or null if empty
 void testPeekLast()
          peekLast returns next element, or null if empty
 void testPoll()
          poll succeeds unless empty
 void testPollFirst()
          pollFirst succeeds unless empty
 void testPollInExecutor()
          poll retrieves elements across Executor threads
 void testPollLast()
          pollLast succeeds unless empty
 void testPop()
          pop removes next element, or throws NSEE if empty
 void testPush()
          push succeeds if not full; throws ISE if full
 void testPushNull()
          push(null) throws NPE
 void testPushWithPeek()
          peekFirst returns element inserted with push
 void testPut()
          all elements successfully put are contained
 void testPutFirst()
          all elements successfully putFirst are contained
 void testPutFirstNull()
          putFirst(null) throws NPE
 void testPutFirstWithTake()
          putFirst blocks waiting for take when full
 void testPutLast()
          all elements successfully putLast are contained
 void testPutLastNull()
          putLast(null) throws NPE
 void testPutLastWithTake()
          putLast blocks waiting for take when full
 void testPutNull()
          put(null) throws NPE
 void testPutWithTake()
          put blocks waiting for take when full
 void testRemainingCapacity()
          remainingCapacity decreases on add, increases on remove
 void testRemove()
          remove removes next element, or throws NSEE if empty
 void testRemoveAll()
          removeAll(c) removes only those elements of c and reports true if changed
 void testRemoveElement()
          remove(x) removes x and returns true if present
 void testRemoveFirst()
          removeFirst() removes first element, or throws NSEE if empty
 void testRemoveFirstOccurrence()
          removeFirstOccurrence(x) removes x and returns true if present
 void testRemoveLast()
          removeLast() removes last element, or throws NSEE if empty
 void testRemoveLastOccurrence()
          removeLastOccurrence(x) removes x and returns true if present
 void testRetainAll()
          retainAll(c) retains only those elements of c and reports true if changed
 void testSerialization()
          A deserialized serialized deque has same elements in same order
 void testSize()
          size changes when elements added and removed
 void testTake()
          take retrieves elements in FIFO order
 void testTakeFirst()
          take retrieves elements in FIFO order
 void testTakeFirstFromEmpty()
          takeFirst blocks interruptibly when empty
 void testTakeLast()
          takeLast retrieves elements in FIFO order
 void testTakeLastFromEmpty()
          takeLast blocks interruptibly when empty
 void testTimedOffer()
          timed offer times out if full and elements not taken
 void testTimedOfferFirst()
          timed offerFirst times out if full and elements not taken
 void testTimedOfferLast()
          timed offerLast times out if full and elements not taken
 void testTimedPoll()
          timed poll with nonzero timeout succeeds when non-empty, else times out
 void testTimedPoll0()
          timed poll with zero timeout succeeds when non-empty, else times out
 void testTimedPollFirst()
          timed pollFirst with nonzero timeout succeeds when non-empty, else times out
 void testTimedPollFirst0()
          timed pollFirst with zero timeout succeeds when non-empty, else times out
 void testTimedPollFirstWithOfferFirst()
          timed pollFirst before a delayed offerFirst fails; after offerFirst succeeds; on interruption throws
 void testTimedPollLast()
          timed pollLast with nonzero timeout succeeds when non-empty, else times out
 void testTimedPollLast0()
          timed pollLast with zero timeout succeeds when non-empty, else times out
 void testTimedPollWithOfferLast()
          timed poll before a delayed offerLast fails; after offerLast succeeds; on interruption throws
 void testToArray_NullArg()
          toArray(null) throws NullPointerException
 void testToArray()
          toArray contains all elements in FIFO order
 void testToArray1_BadArg()
          toArray(incompatible array type) throws ArrayStoreException
 void testToArray2()
          toArray(a) contains all elements in FIFO order
 void testToString()
          toString contains toStrings of elements
 void testWeaklyConsistentIteration()
          Modifications do not cause iterators to fail
 
Methods inherited from class JSR166TestCase
assertThreadJoinTimesOut, awaiter, checkEmpty, delay, getShortDelay, joinPool, latchAwaitingStringTask, newTestSuite, permissivePolicy, possiblyInterruptedRunnable, runTest, runTestProfiled, runWithoutPermissions, runWithPermissions, setDelays, setUp, shouldThrow, shouldThrow, tearDown, threadAssertEquals, threadAssertEquals, threadAssertFalse, threadAssertNull, threadAssertSame, threadAssertTrue, threadFail, threadRecordFailure, threadShouldThrow, threadShouldThrow, threadUnexpectedException, trackedRunnable
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkedBlockingDequeTest

public LinkedBlockingDequeTest()
Method Detail

main

public static void main(java.lang.String[] args)

suite

public static junit.framework.Test suite()

testEmpty

public void testEmpty()
isEmpty is true before add, false after


testSize

public void testSize()
size changes when elements added and removed


testOfferFirstNull

public void testOfferFirstNull()
offer(null) throws NPE


testOfferFirst

public void testOfferFirst()
OfferFirst succeeds


testOfferLast

public void testOfferLast()
OfferLast succeeds


testPollFirst

public void testPollFirst()
pollFirst succeeds unless empty


testPollLast

public void testPollLast()
pollLast succeeds unless empty


testPeekFirst

public void testPeekFirst()
peekFirst returns next element, or null if empty


testPeek

public void testPeek()
peek returns next element, or null if empty


testPeekLast

public void testPeekLast()
peekLast returns next element, or null if empty


testFirstElement

public void testFirstElement()
getFirst() returns first element, or throws NSEE if empty


testLastElement

public void testLastElement()
getLast() returns last element, or throws NSEE if empty


testRemoveFirst

public void testRemoveFirst()
removeFirst() removes first element, or throws NSEE if empty


testRemoveLast

public void testRemoveLast()
removeLast() removes last element, or throws NSEE if empty


testRemove

public void testRemove()
remove removes next element, or throws NSEE if empty


testRemoveFirstOccurrence

public void testRemoveFirstOccurrence()
removeFirstOccurrence(x) removes x and returns true if present


testRemoveLastOccurrence

public void testRemoveLastOccurrence()
removeLastOccurrence(x) removes x and returns true if present


testAddFirst

public void testAddFirst()
peekFirst returns element inserted with addFirst


testAddLast

public void testAddLast()
peekLast returns element inserted with addLast


testConstructor1

public void testConstructor1()
A new deque has the indicated capacity, or Integer.MAX_VALUE if none given


testConstructor2

public void testConstructor2()
Constructor throws IAE if capacity argument nonpositive


testConstructor3

public void testConstructor3()
Initializing from null Collection throws NPE


testConstructor4

public void testConstructor4()
Initializing from Collection of null elements throws NPE


testConstructor5

public void testConstructor5()
Initializing from Collection with some null elements throws NPE


testConstructor6

public void testConstructor6()
Deque contains all elements of collection used to initialize


testEmptyFull

public void testEmptyFull()
Deque transitions from empty to full when elements added


testRemainingCapacity

public void testRemainingCapacity()
remainingCapacity decreases on add, increases on remove


testOfferNull

public void testOfferNull()
offer(null) throws NPE


testAddNull

public void testAddNull()
add(null) throws NPE


testPushNull

public void testPushNull()
push(null) throws NPE


testPush

public void testPush()
push succeeds if not full; throws ISE if full


testPushWithPeek

public void testPushWithPeek()
peekFirst returns element inserted with push


testPop

public void testPop()
pop removes next element, or throws NSEE if empty


testOffer

public void testOffer()
Offer succeeds if not full; fails if full


testAdd

public void testAdd()
add succeeds if not full; throws ISE if full


testAddAll1

public void testAddAll1()
addAll(null) throws NPE


testAddAllSelf

public void testAddAllSelf()
addAll(this) throws IAE


testAddAll2

public void testAddAll2()
addAll of a collection with null elements throws NPE


testAddAll3

public void testAddAll3()
addAll of a collection with any null elements throws NPE after possibly adding some elements


testAddAll4

public void testAddAll4()
addAll throws ISE if not enough room


testAddAll5

public void testAddAll5()
Deque contains all elements, in traversal order, of successful addAll


testPutNull

public void testPutNull()
                 throws java.lang.InterruptedException
put(null) throws NPE

Throws:
java.lang.InterruptedException

testPut

public void testPut()
             throws java.lang.InterruptedException
all elements successfully put are contained

Throws:
java.lang.InterruptedException

testBlockingPut

public void testBlockingPut()
                     throws java.lang.InterruptedException
put blocks interruptibly if full

Throws:
java.lang.InterruptedException

testPutWithTake

public void testPutWithTake()
                     throws java.lang.InterruptedException
put blocks waiting for take when full

Throws:
java.lang.InterruptedException

testTimedOffer

public void testTimedOffer()
                    throws java.lang.InterruptedException
timed offer times out if full and elements not taken

Throws:
java.lang.InterruptedException

testTake

public void testTake()
              throws java.lang.InterruptedException
take retrieves elements in FIFO order

Throws:
java.lang.InterruptedException

testBlockingTake

public void testBlockingTake()
                      throws java.lang.InterruptedException
Take removes existing elements until empty, then blocks interruptibly

Throws:
java.lang.InterruptedException

testPoll

public void testPoll()
poll succeeds unless empty


testTimedPoll0

public void testTimedPoll0()
                    throws java.lang.InterruptedException
timed poll with zero timeout succeeds when non-empty, else times out

Throws:
java.lang.InterruptedException

testTimedPoll

public void testTimedPoll()
                   throws java.lang.InterruptedException
timed poll with nonzero timeout succeeds when non-empty, else times out

Throws:
java.lang.InterruptedException

testInterruptedTimedPoll

public void testInterruptedTimedPoll()
                              throws java.lang.InterruptedException
Interrupted timed poll throws InterruptedException instead of returning timeout status

Throws:
java.lang.InterruptedException

testPutFirstNull

public void testPutFirstNull()
                      throws java.lang.InterruptedException
putFirst(null) throws NPE

Throws:
java.lang.InterruptedException

testPutFirst

public void testPutFirst()
                  throws java.lang.InterruptedException
all elements successfully putFirst are contained

Throws:
java.lang.InterruptedException

testBlockingPutFirst

public void testBlockingPutFirst()
                          throws java.lang.InterruptedException
putFirst blocks interruptibly if full

Throws:
java.lang.InterruptedException

testPutFirstWithTake

public void testPutFirstWithTake()
                          throws java.lang.InterruptedException
putFirst blocks waiting for take when full

Throws:
java.lang.InterruptedException

testTimedOfferFirst

public void testTimedOfferFirst()
                         throws java.lang.InterruptedException
timed offerFirst times out if full and elements not taken

Throws:
java.lang.InterruptedException

testTakeFirst

public void testTakeFirst()
                   throws java.lang.InterruptedException
take retrieves elements in FIFO order

Throws:
java.lang.InterruptedException

testTakeFirstFromEmpty

public void testTakeFirstFromEmpty()
                            throws java.lang.InterruptedException
takeFirst blocks interruptibly when empty

Throws:
java.lang.InterruptedException

testBlockingTakeFirst

public void testBlockingTakeFirst()
                           throws java.lang.InterruptedException
TakeFirst removes existing elements until empty, then blocks interruptibly

Throws:
java.lang.InterruptedException

testTimedPollFirst0

public void testTimedPollFirst0()
                         throws java.lang.InterruptedException
timed pollFirst with zero timeout succeeds when non-empty, else times out

Throws:
java.lang.InterruptedException

testTimedPollFirst

public void testTimedPollFirst()
                        throws java.lang.InterruptedException
timed pollFirst with nonzero timeout succeeds when non-empty, else times out

Throws:
java.lang.InterruptedException

testInterruptedTimedPollFirst

public void testInterruptedTimedPollFirst()
                                   throws java.lang.InterruptedException
Interrupted timed pollFirst throws InterruptedException instead of returning timeout status

Throws:
java.lang.InterruptedException

testTimedPollFirstWithOfferFirst

public void testTimedPollFirstWithOfferFirst()
                                      throws java.lang.InterruptedException
timed pollFirst before a delayed offerFirst fails; after offerFirst succeeds; on interruption throws

Throws:
java.lang.InterruptedException

testPutLastNull

public void testPutLastNull()
                     throws java.lang.InterruptedException
putLast(null) throws NPE

Throws:
java.lang.InterruptedException

testPutLast

public void testPutLast()
                 throws java.lang.InterruptedException
all elements successfully putLast are contained

Throws:
java.lang.InterruptedException

testBlockingPutLast

public void testBlockingPutLast()
                         throws java.lang.InterruptedException
putLast blocks interruptibly if full

Throws:
java.lang.InterruptedException

testPutLastWithTake

public void testPutLastWithTake()
                         throws java.lang.InterruptedException
putLast blocks waiting for take when full

Throws:
java.lang.InterruptedException

testTimedOfferLast

public void testTimedOfferLast()
                        throws java.lang.InterruptedException
timed offerLast times out if full and elements not taken

Throws:
java.lang.InterruptedException

testTakeLast

public void testTakeLast()
                  throws java.lang.InterruptedException
takeLast retrieves elements in FIFO order

Throws:
java.lang.InterruptedException

testTakeLastFromEmpty

public void testTakeLastFromEmpty()
                           throws java.lang.InterruptedException
takeLast blocks interruptibly when empty

Throws:
java.lang.InterruptedException

testBlockingTakeLast

public void testBlockingTakeLast()
                          throws java.lang.InterruptedException
TakeLast removes existing elements until empty, then blocks interruptibly

Throws:
java.lang.InterruptedException

testTimedPollLast0

public void testTimedPollLast0()
                        throws java.lang.InterruptedException
timed pollLast with zero timeout succeeds when non-empty, else times out

Throws:
java.lang.InterruptedException

testTimedPollLast

public void testTimedPollLast()
                       throws java.lang.InterruptedException
timed pollLast with nonzero timeout succeeds when non-empty, else times out

Throws:
java.lang.InterruptedException

testInterruptedTimedPollLast

public void testInterruptedTimedPollLast()
                                  throws java.lang.InterruptedException
Interrupted timed pollLast throws InterruptedException instead of returning timeout status

Throws:
java.lang.InterruptedException

testTimedPollWithOfferLast

public void testTimedPollWithOfferLast()
                                throws java.lang.InterruptedException
timed poll before a delayed offerLast fails; after offerLast succeeds; on interruption throws

Throws:
java.lang.InterruptedException

testElement

public void testElement()
element returns next element, or throws NSEE if empty


testRemoveElement

public void testRemoveElement()
remove(x) removes x and returns true if present


testContains

public void testContains()
contains(x) reports true when elements added but not yet removed


testClear

public void testClear()
clear removes all elements


testContainsAll

public void testContainsAll()
containsAll(c) is true when c contains a subset of elements


testRetainAll

public void testRetainAll()
retainAll(c) retains only those elements of c and reports true if changed


testRemoveAll

public void testRemoveAll()
removeAll(c) removes only those elements of c and reports true if changed


testToArray

public void testToArray()
                 throws java.lang.InterruptedException
toArray contains all elements in FIFO order

Throws:
java.lang.InterruptedException

testToArray2

public void testToArray2()
toArray(a) contains all elements in FIFO order


testToArray_NullArg

public void testToArray_NullArg()
toArray(null) throws NullPointerException


testToArray1_BadArg

public void testToArray1_BadArg()
toArray(incompatible array type) throws ArrayStoreException


testIterator

public void testIterator()
                  throws java.lang.InterruptedException
iterator iterates through all elements

Throws:
java.lang.InterruptedException

testIteratorRemove

public void testIteratorRemove()
iterator.remove removes current element


testIteratorOrdering

public void testIteratorOrdering()
iterator ordering is FIFO


testWeaklyConsistentIteration

public void testWeaklyConsistentIteration()
Modifications do not cause iterators to fail


testDescendingIterator

public void testDescendingIterator()
Descending iterator iterates through all elements


testDescendingIteratorOrdering

public void testDescendingIteratorOrdering()
Descending iterator ordering is reverse FIFO


testDescendingIteratorRemove

public void testDescendingIteratorRemove()
descendingIterator.remove removes current element


testToString

public void testToString()
toString contains toStrings of elements


testOfferInExecutor

public void testOfferInExecutor()
offer transfers elements across Executor tasks


testPollInExecutor

public void testPollInExecutor()
poll retrieves elements across Executor threads


testSerialization

public void testSerialization()
                       throws java.lang.Exception
A deserialized serialized deque has same elements in same order

Throws:
java.lang.Exception

testDrainToNull

public void testDrainToNull()
drainTo(null) throws NPE


testDrainToSelf

public void testDrainToSelf()
drainTo(this) throws IAE


testDrainTo

public void testDrainTo()
drainTo(c) empties deque into another collection c


testDrainToWithActivePut

public void testDrainToWithActivePut()
                              throws java.lang.InterruptedException
drainTo empties full deque, unblocking a waiting put.

Throws:
java.lang.InterruptedException

testDrainToNullN

public void testDrainToNullN()
drainTo(null, n) throws NPE


testDrainToSelfN

public void testDrainToSelfN()
drainTo(this, n) throws IAE


testDrainToN

public void testDrainToN()
drainTo(c, n) empties first min(n, size) elements of queue into c