Class FutureTaskTest

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

public class FutureTaskTest
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
FutureTaskTest()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testCancelAfterRun()
          cancel of a completed task fails
 void testCancelBeforeRun()
          Cancelling before running succeeds
 void testCancelBeforeRun2()
          Cancel(true) before run succeeds
 void testCancelInterrupt()
          cancel(true) interrupts a running task
 void testCancelNoInterrupt()
          cancel(false) does not interrupt a running task
 void testConstructor()
          Creating a future with a null callable throws NPE
 void testConstructor2()
          creating a future with null runnable fails
 void testGet_Cancellation()
          Cancelling a task causes get in another thread to throw CancellationException
 void testGet_ExecutionException()
          A runtime exception in task causes get to throw ExecutionException
 void testGet_InterruptedException()
          Interrupting a waiting get causes it to throw InterruptedException
 void testGet_TimeoutException()
          A timed out timed get throws TimeoutException
 void testGetRun()
          run in one thread causes get in another thread to retrieve value
 void testGetSet()
          set in one thread causes get in another thread to retrieve value
 void testIsDone()
          isDone is true when a task completes
 void testResetAfterCancel()
          runAndReset after cancellation fails
 void testRunAndReset()
          runAndReset of a non-cancelled task succeeds
 void testSet()
          setting value causes get to return it
 void testSetException()
          setException causes get to throw ExecutionException
 void testTimedGet_Cancellation()
          Cancelling a task causes timed get in another thread to throw CancellationException
 void testTimedGet_ExecutionException2()
          A runtime exception in task causes timed get to throw ExecutionException
 void testTimedGet_InterruptedException2()
          Interrupting a waiting timed get causes it to throw InterruptedException
 void testTimedGetRun()
          run in one thread causes timed get in another thread to retrieve value
 void testTimedGetSet()
          set in one thread causes timed get in another thread to retrieve value
 
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

FutureTaskTest

public FutureTaskTest()
Method Detail

main

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

suite

public static junit.framework.Test suite()

testConstructor

public void testConstructor()
Creating a future with a null callable throws NPE


testConstructor2

public void testConstructor2()
creating a future with null runnable fails


testIsDone

public void testIsDone()
isDone is true when a task completes


testRunAndReset

public void testRunAndReset()
runAndReset of a non-cancelled task succeeds


testResetAfterCancel

public void testResetAfterCancel()
runAndReset after cancellation fails


testSet

public void testSet()
             throws java.lang.Exception
setting value causes get to return it

Throws:
java.lang.Exception

testSetException

public void testSetException()
                      throws java.lang.Exception
setException causes get to throw ExecutionException

Throws:
java.lang.Exception

testCancelBeforeRun

public void testCancelBeforeRun()
Cancelling before running succeeds


testCancelBeforeRun2

public void testCancelBeforeRun2()
Cancel(true) before run succeeds


testCancelAfterRun

public void testCancelAfterRun()
cancel of a completed task fails


testCancelInterrupt

public void testCancelInterrupt()
                         throws java.lang.InterruptedException
cancel(true) interrupts a running task

Throws:
java.lang.InterruptedException

testCancelNoInterrupt

public void testCancelNoInterrupt()
                           throws java.lang.InterruptedException
cancel(false) does not interrupt a running task

Throws:
java.lang.InterruptedException

testGetRun

public void testGetRun()
                throws java.lang.InterruptedException
run in one thread causes get in another thread to retrieve value

Throws:
java.lang.InterruptedException

testGetSet

public void testGetSet()
                throws java.lang.InterruptedException
set in one thread causes get in another thread to retrieve value

Throws:
java.lang.InterruptedException

testTimedGetRun

public void testTimedGetRun()
                     throws java.lang.InterruptedException
run in one thread causes timed get in another thread to retrieve value

Throws:
java.lang.InterruptedException

testTimedGetSet

public void testTimedGetSet()
                     throws java.lang.InterruptedException
set in one thread causes timed get in another thread to retrieve value

Throws:
java.lang.InterruptedException

testTimedGet_Cancellation

public void testTimedGet_Cancellation()
                               throws java.lang.InterruptedException
Cancelling a task causes timed get in another thread to throw CancellationException

Throws:
java.lang.InterruptedException

testGet_Cancellation

public void testGet_Cancellation()
                          throws java.lang.InterruptedException
Cancelling a task causes get in another thread to throw CancellationException

Throws:
java.lang.InterruptedException

testGet_ExecutionException

public void testGet_ExecutionException()
                                throws java.lang.InterruptedException
A runtime exception in task causes get to throw ExecutionException

Throws:
java.lang.InterruptedException

testTimedGet_ExecutionException2

public void testTimedGet_ExecutionException2()
                                      throws java.lang.Exception
A runtime exception in task causes timed get to throw ExecutionException

Throws:
java.lang.Exception

testGet_InterruptedException

public void testGet_InterruptedException()
                                  throws java.lang.InterruptedException
Interrupting a waiting get causes it to throw InterruptedException

Throws:
java.lang.InterruptedException

testTimedGet_InterruptedException2

public void testTimedGet_InterruptedException2()
                                        throws java.lang.InterruptedException
Interrupting a waiting timed get causes it to throw InterruptedException

Throws:
java.lang.InterruptedException

testGet_TimeoutException

public void testGet_TimeoutException()
                              throws java.lang.Exception
A timed out timed get throws TimeoutException

Throws:
java.lang.Exception