[cvs] / jsr166 / src / test / tck / FutureTaskTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/FutureTaskTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7, Fri Sep 26 15:33:13 2003 UTC revision 1.11, Mon Dec 29 19:05:40 2003 UTC
# Line 1  Line 1 
1  /*  /*
2   * Written by members of JCP JSR-166 Expert Group and released to the   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * public domain. Use, modify, and redistribute this code in any way   * Expert Group and released to the public domain, as explained at
4   * without acknowledgement. Other contributors include Andrew Wright,   * http://creativecommons.org/licenses/publicdomain
5   * Jeffrey Hayes, Pat Fischer, Mike Judd.   * Other contributors include Andrew Wright, Jeffrey Hayes,
6     * Pat Fisher, Mike Judd.
7   */   */
8    
9  import junit.framework.*;  import junit.framework.*;
# Line 23  Line 24 
24       */       */
25      static class PublicFutureTask extends FutureTask {      static class PublicFutureTask extends FutureTask {
26          public PublicFutureTask(Callable r) { super(r); }          public PublicFutureTask(Callable r) { super(r); }
27          public boolean reset() { return super.reset(); }          public boolean runAndReset() { return super.runAndReset(); }
         public void setCancelled() { super.setCancelled(); }  
         public void setDone() { super.setDone(); }  
28          public void set(Object x) { super.set(x); }          public void set(Object x) { super.set(x); }
29          public void setException(Throwable t) { super.setException(t); }          public void setException(Throwable t) { super.setException(t); }
30      }      }
# Line 65  Line 64 
64      }      }
65    
66      /**      /**
67       * reset of a done task succeeds and changes status to not done       * runAndReset of a non-cancelled task succeeds
68       */       */
69      public void testReset() {      public void testRunAndReset() {
70          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
71          task.run();          assertTrue(task.runAndReset());
         assertTrue(task.isDone());  
         assertTrue(task.reset());  
72          assertFalse(task.isDone());          assertFalse(task.isDone());
73      }      }
74    
75      /**      /**
76       * Resetting after cancellation fails       * runAndReset after cancellation fails
77       */       */
78      public void testResetAfterCancel() {      public void testResetAfterCancel() {
79          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
80          assertTrue(task.cancel(false));          assertTrue(task.cancel(false));
81          task.run();          assertFalse(task.runAndReset());
82          assertTrue(task.isDone());          assertTrue(task.isDone());
83          assertTrue(task.isCancelled());          assertTrue(task.isCancelled());
         assertFalse(task.reset());  
84      }      }
85    
     /**  
      * setDone of new task causes isDone to be true  
      */  
     public void testSetDone() {  
         PublicFutureTask task = new PublicFutureTask(new NoOpCallable());  
         task.setDone();  
         assertTrue(task.isDone());  
         assertFalse(task.isCancelled());  
     }  
86    
     /**  
      * setCancelled of a new task causes isCancelled to be true  
      */  
     public void testSetCancelled() {  
         PublicFutureTask task = new PublicFutureTask(new NoOpCallable());  
         assertTrue(task.cancel(false));  
         task.setCancelled();  
         assertTrue(task.isDone());  
         assertTrue(task.isCancelled());  
     }  
87    
88      /**      /**
89       * setting value gauses get to return it       * setting value causes get to return it
90       */       */
91      public void testSet() {      public void testSet() {
92          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8