Class LinkedTransferQueueTest

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

public class LinkedTransferQueueTest
extends JSR166TestCase


Nested Class Summary
static class LinkedTransferQueueTest.Generic
           
 
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
LinkedTransferQueueTest()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testAddAll1()
          addAll(null) throws NullPointerException
 void testAddAll2()
          addAll of a collection with null elements throws NullPointerException
 void testAddAll3()
          addAll of a collection with any null elements throws NullPointerException after possibly adding some elements
 void testAddAll5()
          Queue contains all elements, in traversal order, of successful addAll
 void testAddAllSelf()
          addAll(this) throws IllegalArgumentException
 void testAddNull()
          add(null) throws NullPointerException
 void testBlockingTake()
          take removes existing elements until empty, then blocks interruptibly
 void testClear()
          clear removes all elements
 void testConstructor1()
          Constructor builds new queue with size being zero and empty being true
 void testConstructor2()
          Initializing constructor with null collection throws NullPointerException
 void testConstructor3()
          Initializing from Collection of null elements throws NullPointerException
 void testConstructor4()
          Initializing constructor with a collection containing some null elements throws NullPointerException
 void testConstructor5()
          Queue contains all elements of the collection it is initialized by
 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 testDrainTo()
          drainTo(c) empties queue into another collection c
 void testDrainToN()
          drainTo(c, n) empties first min(n, size) elements of queue into c
 void testDrainToNull()
          drainTo(null) throws NullPointerException
 void testDrainToNullN()
          drainTo(null, n) throws NullPointerException
 void testDrainToSelf()
          drainTo(this) throws IllegalArgumentException
 void testDrainToSelfN()
          drainTo(this, n) throws IllegalArgumentException
 void testDrainToWithActivePut()
          drainTo(c) empties full queue, unblocking a waiting put.
 void testElement()
          element returns next element, or throws NoSuchElementException if empty
 void testInterruptedTimedPoll()
          Interrupted timed poll 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 testOfferInExecutor()
          offer transfers elements across Executor tasks
 void testOfferNull()
          offer(null) throws NullPointerException
 void testPeek()
          peek returns next element, or null if empty
 void testPoll()
          poll succeeds unless empty
 void testPollInExecutor()
          timed poll retrieves elements across Executor threads
 void testPut()
          all elements successfully put are contained
 void testPutNull()
          put(null) throws NullPointerException
 void testRemainingCapacity()
          remainingCapacity() always returns Integer.MAX_VALUE
 void testRemove()
          remove removes next element, or throws NoSuchElementException 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 testRemoveElementAndAdd()
          An add following remove(x) succeeds
 void testRetainAll()
          retainAll(c) retains only those elements of c and reports true if changed
 void testSerialization()
          A deserialized serialized queue has same elements in same order
 void testTake()
          take retrieves elements in FIFO order
 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 testTimedPollAfterInterrupt()
          timed poll after thread interrupted throws InterruptedException instead of returning timeout status
 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 testTransfer1()
          transfer(null) throws NullPointerException
 void testTransfer2()
          transfer waits until a poll occurs.
 void testTransfer3()
          transfer waits until a poll occurs, and then transfers in fifo order
 void testTransfer4()
          transfer waits until a poll occurs, at which point the polling thread returns the element
 void testTransfer5()
          transfer waits until a take occurs.
 void testTryTransfer1()
          tryTransfer(null) throws NullPointerException
 void testTryTransfer2()
          tryTransfer returns false and does not enqueue if there are no consumers waiting to poll or take.
 void testTryTransfer3()
          If there is a consumer waiting in timed poll, tryTransfer returns true while successfully transfering object.
 void testTryTransfer4()
          If there is a consumer waiting in take, tryTransfer returns true while successfully transfering object.
 void testTryTransfer5()
          tryTransfer waits the amount given, and throws InterruptedException when interrupted.
 void testTryTransfer6()
          tryTransfer gives up after the timeout and returns false
 void testTryTransfer7()
          tryTransfer waits for any elements previously in to be removed before transfering to a poll or take
 void testTryTransfer8()
          tryTransfer attempts to enqueue into the queue and fails returning false not enqueueing and the successive poll is null
 void testWaitingConsumer()
          timed poll() or take() increments the waiting consumer count; offer(e) decrements the waiting consumer count
 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

LinkedTransferQueueTest

public LinkedTransferQueueTest()
Method Detail

main

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

suite

public static junit.framework.Test suite()

testConstructor1

public void testConstructor1()
Constructor builds new queue with size being zero and empty being true


testConstructor2

public void testConstructor2()
Initializing constructor with null collection throws NullPointerException


testConstructor3

public void testConstructor3()
Initializing from Collection of null elements throws NullPointerException


testConstructor4

public void testConstructor4()
Initializing constructor with a collection containing some null elements throws NullPointerException


testConstructor5

public void testConstructor5()
Queue contains all elements of the collection it is initialized by


testRemainingCapacity

public void testRemainingCapacity()
remainingCapacity() always returns Integer.MAX_VALUE


testOfferNull

public void testOfferNull()
offer(null) throws NullPointerException


testAddNull

public void testAddNull()
add(null) throws NullPointerException


testAddAll1

public void testAddAll1()
addAll(null) throws NullPointerException


testAddAllSelf

public void testAddAllSelf()
addAll(this) throws IllegalArgumentException


testAddAll2

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


testAddAll3

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


testAddAll5

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


testPutNull

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

Throws:
java.lang.InterruptedException

testPut

public void testPut()
all elements successfully put are contained


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()
              throws java.lang.InterruptedException
poll succeeds unless empty

Throws:
java.lang.InterruptedException

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

testTimedPollAfterInterrupt

public void testTimedPollAfterInterrupt()
                                 throws java.lang.InterruptedException
timed poll after thread interrupted throws InterruptedException instead of returning timeout status

Throws:
java.lang.InterruptedException

testPeek

public void testPeek()
              throws java.lang.InterruptedException
peek returns next element, or null if empty

Throws:
java.lang.InterruptedException

testElement

public void testElement()
                 throws java.lang.InterruptedException
element returns next element, or throws NoSuchElementException if empty

Throws:
java.lang.InterruptedException

testRemove

public void testRemove()
                throws java.lang.InterruptedException
remove removes next element, or throws NoSuchElementException if empty

Throws:
java.lang.InterruptedException

testRemoveElement

public void testRemoveElement()
                       throws java.lang.InterruptedException
remove(x) removes x and returns true if present

Throws:
java.lang.InterruptedException

testRemoveElementAndAdd

public void testRemoveElementAndAdd()
                             throws java.lang.InterruptedException
An add following remove(x) succeeds

Throws:
java.lang.InterruptedException

testContains

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


testClear

public void testClear()
               throws java.lang.InterruptedException
clear removes all elements

Throws:
java.lang.InterruptedException

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()
toArray() contains all elements in FIFO order


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


testToString

public void testToString()
toString contains toStrings of elements


testOfferInExecutor

public void testOfferInExecutor()
offer transfers elements across Executor tasks


testPollInExecutor

public void testPollInExecutor()
timed poll retrieves elements across Executor threads


testSerialization

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

Throws:
java.lang.Exception

testDrainToNull

public void testDrainToNull()
drainTo(null) throws NullPointerException


testDrainToSelf

public void testDrainToSelf()
drainTo(this) throws IllegalArgumentException


testDrainTo

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


testDrainToWithActivePut

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

Throws:
java.lang.InterruptedException

testDrainToNullN

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


testDrainToSelfN

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


testDrainToN

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


testWaitingConsumer

public void testWaitingConsumer()
                         throws java.lang.InterruptedException
timed poll() or take() increments the waiting consumer count; offer(e) decrements the waiting consumer count

Throws:
java.lang.InterruptedException

testTransfer1

public void testTransfer1()
                   throws java.lang.InterruptedException
transfer(null) throws NullPointerException

Throws:
java.lang.InterruptedException

testTransfer2

public void testTransfer2()
                   throws java.lang.InterruptedException
transfer waits until a poll occurs. The transfered element is returned by this associated poll.

Throws:
java.lang.InterruptedException

testTransfer3

public void testTransfer3()
                   throws java.lang.InterruptedException
transfer waits until a poll occurs, and then transfers in fifo order

Throws:
java.lang.InterruptedException

testTransfer4

public void testTransfer4()
                   throws java.lang.InterruptedException
transfer waits until a poll occurs, at which point the polling thread returns the element

Throws:
java.lang.InterruptedException

testTransfer5

public void testTransfer5()
                   throws java.lang.InterruptedException
transfer waits until a take occurs. The transfered element is returned by this associated take.

Throws:
java.lang.InterruptedException

testTryTransfer1

public void testTryTransfer1()
tryTransfer(null) throws NullPointerException


testTryTransfer2

public void testTryTransfer2()
                      throws java.lang.InterruptedException
tryTransfer returns false and does not enqueue if there are no consumers waiting to poll or take.

Throws:
java.lang.InterruptedException

testTryTransfer3

public void testTryTransfer3()
                      throws java.lang.InterruptedException
If there is a consumer waiting in timed poll, tryTransfer returns true while successfully transfering object.

Throws:
java.lang.InterruptedException

testTryTransfer4

public void testTryTransfer4()
                      throws java.lang.InterruptedException
If there is a consumer waiting in take, tryTransfer returns true while successfully transfering object.

Throws:
java.lang.InterruptedException

testTryTransfer5

public void testTryTransfer5()
                      throws java.lang.InterruptedException
tryTransfer waits the amount given, and throws InterruptedException when interrupted.

Throws:
java.lang.InterruptedException

testTryTransfer6

public void testTryTransfer6()
                      throws java.lang.InterruptedException
tryTransfer gives up after the timeout and returns false

Throws:
java.lang.InterruptedException

testTryTransfer7

public void testTryTransfer7()
                      throws java.lang.InterruptedException
tryTransfer waits for any elements previously in to be removed before transfering to a poll or take

Throws:
java.lang.InterruptedException

testTryTransfer8

public void testTryTransfer8()
                      throws java.lang.InterruptedException
tryTransfer attempts to enqueue into the queue and fails returning false not enqueueing and the successive poll is null

Throws:
java.lang.InterruptedException