Class AbstractQueuedSynchronizerTest

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

public class AbstractQueuedSynchronizerTest
extends JSR166TestCase


Nested Class Summary
 
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
AbstractQueuedSynchronizerTest()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testAcquire()
          acquiring released sync succeeds
 void testAcquireInterruptibly1()
          acquireInterruptibly is interruptible.
 void testAcquireInterruptibly2()
          acquireInterruptibly succeeds when released, else is interruptible
 void testAcquireNanos_Timeout()
          tryAcquireNanos on an exclusively held sync times out
 void testAcquireSharedInterruptibly_InterruptedException()
          acquireSharedInterruptibly throws IE if interrupted before released
 void testAcquireSharedInterruptibly()
          acquireSharedInterruptibly returns after release, but not before
 void testAcquireSharedNanos_InterruptedException()
          acquireSharedTimed throws IE if interrupted before released
 void testAcquireSharedNanos_Timeout()
          acquireSharedTimed times out if not released before timeout
 void testAcquireSharedTimed()
          acquireSharedTimed returns after release
 void testAwait_IllegalMonitor()
          Calling await without holding sync throws IllegalMonitorStateException
 void testAwait_Interrupt()
          await is interruptible
 void testAwait_Timeout()
          Timed await without a signal times out
 void testAwait()
          await returns when signalled
 void testAwaitNanos_Interrupt()
          awaitNanos is interruptible
 void testAwaitNanos_Timeout()
          awaitNanos without a signal times out
 void testAwaitUninterruptibly()
          awaitUninterruptibly doesn't abort on interrupt
 void testAwaitUntil_Interrupt()
          awaitUntil is interruptible
 void testAwaitUntil_Timeout()
          awaitUntil without a signal times out
 void testGetExclusiveQueuedThreads()
          getExclusiveQueuedThreads includes waiting threads
 void testGetFirstQueuedThread()
          getFirstQueuedThread returns first waiting thread or null if none
 void testGetQueuedThreads()
          getQueuedThreads includes waiting threads
 void testGetSharedQueuedThreads()
          getSharedQueuedThreads does not include exclusively waiting threads
 void testGetState()
          getState is true when acquired and false when not
 void testGetStateWithReleaseShared()
          tryReleaseShared setting state changes getState
 void testGetWaitingThreads()
          getWaitingThreads returns only and all waiting threads
 void testGetWaitingThreadsIAE()
          getWaitingThreads throws IAE if not owned
 void testGetWaitingThreadsIMSE()
          getWaitingThreads throws IMSE if not synced
 void testGetWaitingThreadsNPE()
          getWaitingThreads throws NPE if null
 void testGetWaitQueueLength()
          getWaitQueueLength returns number of waiting threads
 void testGetWaitQueueLengthIAE()
          getWaitQueueLength throws IAE if not owned
 void testGetWaitQueueLengthIMSE()
          getWaitQueueLength throws IMSE if not synced
 void testGetWaitQueueLengthNPE()
          getWaitQueueLength throws NPE if null
 void testHasContended()
          hasContended reports false if no thread has ever blocked, else true
 void testhasQueuedThreads()
          hasQueuedThreads reports whether there are waiting threads
 void testHasWaiters()
          hasWaiters returns true when a thread is waiting, else false
 void testHasWaitersIAE()
          hasWaiters throws IAE if not owned
 void testHasWaitersIMSE()
          hasWaiters throws IMSE if not synced
 void testHasWaitersNPE()
          hasWaiters throws NPE if null
 void testInterruptedException2()
          tryAcquireNanos is interruptible.
 void testIsHeldExclusively()
          isHeldExclusively is false upon construction
 void testIsQueued()
          isQueued reports whether a thread is queued.
 void testIsQueuedNPE()
          isQueued(null) throws NPE
 void testOwns()
          owns is true for a condition created by sync else false
 void testReleaseShared()
          releaseShared has no effect when already signalled
 void testSerialization()
          A serialized AQS deserializes with current state
 void testSignal_IllegalMonitor()
          Calling signal without holding sync throws IllegalMonitorStateException
 void testSignalAll()
          signalAll wakes up all threads
 void testToString()
          toString indicates current state
 void testTryAcquire()
          tryAcquire on an released sync succeeds
 void testTryAcquireWhenSynced()
          TryAcquire on exclusively held sync fails
 
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

AbstractQueuedSynchronizerTest

public AbstractQueuedSynchronizerTest()
Method Detail

main

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

suite

public static junit.framework.Test suite()

testIsHeldExclusively

public void testIsHeldExclusively()
isHeldExclusively is false upon construction


testAcquire

public void testAcquire()
acquiring released sync succeeds


testTryAcquire

public void testTryAcquire()
tryAcquire on an released sync succeeds


testhasQueuedThreads

public void testhasQueuedThreads()
                          throws java.lang.InterruptedException
hasQueuedThreads reports whether there are waiting threads

Throws:
java.lang.InterruptedException

testIsQueuedNPE

public void testIsQueuedNPE()
isQueued(null) throws NPE


testIsQueued

public void testIsQueued()
                  throws java.lang.InterruptedException
isQueued reports whether a thread is queued.

Throws:
java.lang.InterruptedException

testGetFirstQueuedThread

public void testGetFirstQueuedThread()
                              throws java.lang.InterruptedException
getFirstQueuedThread returns first waiting thread or null if none

Throws:
java.lang.InterruptedException

testHasContended

public void testHasContended()
                      throws java.lang.InterruptedException
hasContended reports false if no thread has ever blocked, else true

Throws:
java.lang.InterruptedException

testGetQueuedThreads

public void testGetQueuedThreads()
                          throws java.lang.InterruptedException
getQueuedThreads includes waiting threads

Throws:
java.lang.InterruptedException

testGetExclusiveQueuedThreads

public void testGetExclusiveQueuedThreads()
                                   throws java.lang.InterruptedException
getExclusiveQueuedThreads includes waiting threads

Throws:
java.lang.InterruptedException

testGetSharedQueuedThreads

public void testGetSharedQueuedThreads()
                                throws java.lang.InterruptedException
getSharedQueuedThreads does not include exclusively waiting threads

Throws:
java.lang.InterruptedException

testInterruptedException2

public void testInterruptedException2()
                               throws java.lang.InterruptedException
tryAcquireNanos is interruptible.

Throws:
java.lang.InterruptedException

testTryAcquireWhenSynced

public void testTryAcquireWhenSynced()
                              throws java.lang.InterruptedException
TryAcquire on exclusively held sync fails

Throws:
java.lang.InterruptedException

testAcquireNanos_Timeout

public void testAcquireNanos_Timeout()
                              throws java.lang.InterruptedException
tryAcquireNanos on an exclusively held sync times out

Throws:
java.lang.InterruptedException

testGetState

public void testGetState()
                  throws java.lang.InterruptedException
getState is true when acquired and false when not

Throws:
java.lang.InterruptedException

testAcquireInterruptibly1

public void testAcquireInterruptibly1()
                               throws java.lang.InterruptedException
acquireInterruptibly is interruptible.

Throws:
java.lang.InterruptedException

testAcquireInterruptibly2

public void testAcquireInterruptibly2()
                               throws java.lang.InterruptedException
acquireInterruptibly succeeds when released, else is interruptible

Throws:
java.lang.InterruptedException

testOwns

public void testOwns()
owns is true for a condition created by sync else false


testAwait_IllegalMonitor

public void testAwait_IllegalMonitor()
                              throws java.lang.InterruptedException
Calling await without holding sync throws IllegalMonitorStateException

Throws:
java.lang.InterruptedException

testSignal_IllegalMonitor

public void testSignal_IllegalMonitor()
Calling signal without holding sync throws IllegalMonitorStateException


testAwaitNanos_Timeout

public void testAwaitNanos_Timeout()
                            throws java.lang.InterruptedException
awaitNanos without a signal times out

Throws:
java.lang.InterruptedException

testAwait_Timeout

public void testAwait_Timeout()
                       throws java.lang.InterruptedException
Timed await without a signal times out

Throws:
java.lang.InterruptedException

testAwaitUntil_Timeout

public void testAwaitUntil_Timeout()
                            throws java.lang.InterruptedException
awaitUntil without a signal times out

Throws:
java.lang.InterruptedException

testAwait

public void testAwait()
               throws java.lang.InterruptedException
await returns when signalled

Throws:
java.lang.InterruptedException

testHasWaitersNPE

public void testHasWaitersNPE()
hasWaiters throws NPE if null


testGetWaitQueueLengthNPE

public void testGetWaitQueueLengthNPE()
getWaitQueueLength throws NPE if null


testGetWaitingThreadsNPE

public void testGetWaitingThreadsNPE()
getWaitingThreads throws NPE if null


testHasWaitersIAE

public void testHasWaitersIAE()
hasWaiters throws IAE if not owned


testHasWaitersIMSE

public void testHasWaitersIMSE()
hasWaiters throws IMSE if not synced


testGetWaitQueueLengthIAE

public void testGetWaitQueueLengthIAE()
getWaitQueueLength throws IAE if not owned


testGetWaitQueueLengthIMSE

public void testGetWaitQueueLengthIMSE()
getWaitQueueLength throws IMSE if not synced


testGetWaitingThreadsIAE

public void testGetWaitingThreadsIAE()
getWaitingThreads throws IAE if not owned


testGetWaitingThreadsIMSE

public void testGetWaitingThreadsIMSE()
getWaitingThreads throws IMSE if not synced


testHasWaiters

public void testHasWaiters()
                    throws java.lang.InterruptedException
hasWaiters returns true when a thread is waiting, else false

Throws:
java.lang.InterruptedException

testGetWaitQueueLength

public void testGetWaitQueueLength()
                            throws java.lang.InterruptedException
getWaitQueueLength returns number of waiting threads

Throws:
java.lang.InterruptedException

testGetWaitingThreads

public void testGetWaitingThreads()
                           throws java.lang.InterruptedException
getWaitingThreads returns only and all waiting threads

Throws:
java.lang.InterruptedException

testAwaitUninterruptibly

public void testAwaitUninterruptibly()
                              throws java.lang.InterruptedException
awaitUninterruptibly doesn't abort on interrupt

Throws:
java.lang.InterruptedException

testAwait_Interrupt

public void testAwait_Interrupt()
                         throws java.lang.InterruptedException
await is interruptible

Throws:
java.lang.InterruptedException

testAwaitNanos_Interrupt

public void testAwaitNanos_Interrupt()
                              throws java.lang.InterruptedException
awaitNanos is interruptible

Throws:
java.lang.InterruptedException

testAwaitUntil_Interrupt

public void testAwaitUntil_Interrupt()
                              throws java.lang.InterruptedException
awaitUntil is interruptible

Throws:
java.lang.InterruptedException

testSignalAll

public void testSignalAll()
                   throws java.lang.InterruptedException
signalAll wakes up all threads

Throws:
java.lang.InterruptedException

testToString

public void testToString()
toString indicates current state


testSerialization

public void testSerialization()
                       throws java.lang.Exception
A serialized AQS deserializes with current state

Throws:
java.lang.Exception

testGetStateWithReleaseShared

public void testGetStateWithReleaseShared()
tryReleaseShared setting state changes getState


testReleaseShared

public void testReleaseShared()
releaseShared has no effect when already signalled


testAcquireSharedInterruptibly

public void testAcquireSharedInterruptibly()
                                    throws java.lang.InterruptedException
acquireSharedInterruptibly returns after release, but not before

Throws:
java.lang.InterruptedException

testAcquireSharedTimed

public void testAcquireSharedTimed()
                            throws java.lang.InterruptedException
acquireSharedTimed returns after release

Throws:
java.lang.InterruptedException

testAcquireSharedInterruptibly_InterruptedException

public void testAcquireSharedInterruptibly_InterruptedException()
                                                         throws java.lang.InterruptedException
acquireSharedInterruptibly throws IE if interrupted before released

Throws:
java.lang.InterruptedException

testAcquireSharedNanos_InterruptedException

public void testAcquireSharedNanos_InterruptedException()
                                                 throws java.lang.InterruptedException
acquireSharedTimed throws IE if interrupted before released

Throws:
java.lang.InterruptedException

testAcquireSharedNanos_Timeout

public void testAcquireSharedNanos_Timeout()
                                    throws java.lang.InterruptedException
acquireSharedTimed times out if not released before timeout

Throws:
java.lang.InterruptedException