Class SynchronousQueueTest

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

public class SynchronousQueueTest
extends JSR166TestCase


Nested Class Summary
static class SynchronousQueueTest.Fair
           
static class SynchronousQueueTest.NonFair
           
 
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
SynchronousQueueTest()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testAdd()
          add throws ISE if no active taker
 void testAddAll1()
          addAll(null) throws NPE
 void testAddAll2()
          addAll of a collection with null elements throws NPE
 void testAddAll4()
          addAll throws ISE if no active taker
 void testAddAllSelf()
          addAll(this) throws IAE
 void testAddNull()
          add(null) throws NPE
 void testBlockingPut()
          put blocks interruptibly if no active taker
 void testClear()
          clear ensures isEmpty
 void testContains()
          contains returns false
 void testContainsAll()
          containsAll returns false unless empty
 void testDrainTo()
          drainTo(c) of empty queue doesn't transfer elements
 void testDrainToN()
          drainTo(c, n) empties up to n 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 queue, unblocking a waiting put.
 void testElement()
          element() throws NSEE if no active putter
 void testEmptyFull()
          A non-fair SynchronousQueue is both empty and full
 void testEmptyFull(java.util.concurrent.SynchronousQueue q)
          Any SynchronousQueue is both empty and full
 void testFairBlockingPut()
          put blocks interruptibly if no active taker
 void testFairEmptyFull()
          A fair SynchronousQueue is both empty and full
 void testFairInterruptedTimedPoll()
          Interrupted timed poll throws InterruptedException instead of returning timeout status
 void testFairPutWithTake()
          put blocks waiting for take
 void testFairTakeFromEmpty()
          take blocks interruptibly when empty
 void testFairTimedOffer()
          timed offer times out if elements not taken
 void testFairTimedPollWithOffer()
          timed poll before a delayed offer times out, returning null; after offer succeeds; on interruption throws
 void testInterruptedTimedPoll()
          Interrupted timed poll throws InterruptedException instead of returning timeout status
 void testInterruptedTimedPoll(java.util.concurrent.SynchronousQueue q)
          Interrupted timed poll throws InterruptedException instead of returning timeout status
 void testIterator()
          iterator does not traverse any elements
 void testIteratorRemove()
          iterator remove throws ISE
 void testOffer()
          offer fails if no active taker
 void testOfferInExecutor()
          offer transfers elements across Executor tasks
 void testOfferNull()
          offer(null) throws NPE
 void testPeek()
          peek() returns null if no active putter
 void testPoll()
          poll return null if no active putter
 void testPollInExecutor()
          poll retrieves elements across Executor threads
 void testPutNull()
          put(null) throws NPE
 void testPutWithTake()
          put blocks waiting for take
 void testRemove()
          remove() throws NSEE if no active putter
 void testRemoveAll()
          removeAll returns false
 void testRemoveElement()
          remove(x) returns false
 void testRetainAll()
          retainAll returns false
 void testSerialization()
          a deserialized serialized queue is usable
 void testTimedOffer()
          timed offer times out if elements not taken
 void testTimedOffer(java.util.concurrent.SynchronousQueue q)
          timed offer times out if elements not taken
 void testTimedPoll()
          timed poll with nonzero timeout times out if no active putter
 void testTimedPoll0()
          timed poll with zero timeout times out if no active putter
 void testToArray_BadArg()
          toArray(null) throws NPE
 void testToArray()
          toArray is empty
 void testToArray2()
          toArray(a) is nulled at position 0
 void testToString()
          toString returns a non-null string
 
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

SynchronousQueueTest

public SynchronousQueueTest()
Method Detail

main

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

suite

public static junit.framework.Test suite()

testEmptyFull

public void testEmptyFull(java.util.concurrent.SynchronousQueue q)
Any SynchronousQueue is both empty and full


testEmptyFull

public void testEmptyFull()
A non-fair SynchronousQueue is both empty and full


testFairEmptyFull

public void testFairEmptyFull()
A fair SynchronousQueue is both empty and full


testOfferNull

public void testOfferNull()
offer(null) throws NPE


testAddNull

public void testAddNull()
add(null) throws NPE


testOffer

public void testOffer()
offer fails if no active taker


testAdd

public void testAdd()
add throws ISE if no active taker


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


testAddAll4

public void testAddAll4()
addAll throws ISE if no active taker


testPutNull

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

Throws:
java.lang.InterruptedException

testBlockingPut

public void testBlockingPut()
                     throws java.lang.InterruptedException
put blocks interruptibly if no active taker

Throws:
java.lang.InterruptedException

testPutWithTake

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

Throws:
java.lang.InterruptedException

testTimedOffer

public void testTimedOffer(java.util.concurrent.SynchronousQueue q)
                    throws java.lang.InterruptedException
timed offer times out if elements not taken

Throws:
java.lang.InterruptedException

testTimedOffer

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

Throws:
java.lang.InterruptedException

testFairTimedOffer

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

Throws:
java.lang.InterruptedException

testFairBlockingPut

public void testFairBlockingPut()
                         throws java.lang.InterruptedException
put blocks interruptibly if no active taker

Throws:
java.lang.InterruptedException

testFairPutWithTake

public void testFairPutWithTake()
                         throws java.lang.InterruptedException
put blocks waiting for take

Throws:
java.lang.InterruptedException

testFairTakeFromEmpty

public void testFairTakeFromEmpty()
                           throws java.lang.InterruptedException
take blocks interruptibly when empty

Throws:
java.lang.InterruptedException

testPoll

public void testPoll()
poll return null if no active putter


testTimedPoll0

public void testTimedPoll0()
                    throws java.lang.InterruptedException
timed poll with zero timeout times out if no active putter

Throws:
java.lang.InterruptedException

testTimedPoll

public void testTimedPoll()
                   throws java.lang.InterruptedException
timed poll with nonzero timeout times out if no active putter

Throws:
java.lang.InterruptedException

testInterruptedTimedPoll

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

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

testFairInterruptedTimedPoll

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

Throws:
java.lang.InterruptedException

testFairTimedPollWithOffer

public void testFairTimedPollWithOffer()
                                throws java.lang.InterruptedException
timed poll before a delayed offer times out, returning null; after offer succeeds; on interruption throws

Throws:
java.lang.InterruptedException

testPeek

public void testPeek()
peek() returns null if no active putter


testElement

public void testElement()
element() throws NSEE if no active putter


testRemove

public void testRemove()
remove() throws NSEE if no active putter


testRemoveElement

public void testRemoveElement()
remove(x) returns false


testContains

public void testContains()
contains returns false


testClear

public void testClear()
clear ensures isEmpty


testContainsAll

public void testContainsAll()
containsAll returns false unless empty


testRetainAll

public void testRetainAll()
retainAll returns false


testRemoveAll

public void testRemoveAll()
removeAll returns false


testToArray

public void testToArray()
toArray is empty


testToArray2

public void testToArray2()
toArray(a) is nulled at position 0


testToArray_BadArg

public void testToArray_BadArg()
toArray(null) throws NPE


testIterator

public void testIterator()
iterator does not traverse any elements


testIteratorRemove

public void testIteratorRemove()
iterator remove throws ISE


testToString

public void testToString()
toString returns a non-null string


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 queue is usable

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) of empty queue doesn't transfer elements


testDrainToWithActivePut

public void testDrainToWithActivePut()
                              throws java.lang.InterruptedException
drainTo empties queue, 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()
                  throws java.lang.InterruptedException
drainTo(c, n) empties up to n elements of queue into c

Throws:
java.lang.InterruptedException