[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.9, Mon Dec 22 16:25:38 2003 UTC
# Line 23  Line 23 
23       */       */
24      static class PublicFutureTask extends FutureTask {      static class PublicFutureTask extends FutureTask {
25          public PublicFutureTask(Callable r) { super(r); }          public PublicFutureTask(Callable r) { super(r); }
26          public boolean reset() { return super.reset(); }          public boolean runAndReset() { return super.runAndReset(); }
         public void setCancelled() { super.setCancelled(); }  
         public void setDone() { super.setDone(); }  
27          public void set(Object x) { super.set(x); }          public void set(Object x) { super.set(x); }
28          public void setException(Throwable t) { super.setException(t); }          public void setException(Throwable t) { super.setException(t); }
29      }      }
# Line 65  Line 63 
63      }      }
64    
65      /**      /**
66       * reset of a done task succeeds and changes status to not done       * runAndReset of a non-cancelled task succeeds
67       */       */
68      public void testReset() {      public void testRunAndReset() {
69          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
70          task.run();          assertTrue(task.runAndReset());
         assertTrue(task.isDone());  
         assertTrue(task.reset());  
71          assertFalse(task.isDone());          assertFalse(task.isDone());
72      }      }
73    
74      /**      /**
75       * Resetting after cancellation fails       * runAndReset after cancellation fails
76       */       */
77      public void testResetAfterCancel() {      public void testResetAfterCancel() {
78          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
79          assertTrue(task.cancel(false));          assertTrue(task.cancel(false));
80          task.run();          assertFalse(task.runAndReset());
81          assertTrue(task.isDone());          assertTrue(task.isDone());
82          assertTrue(task.isCancelled());          assertTrue(task.isCancelled());
         assertFalse(task.reset());  
83      }      }
84    
     /**  
      * 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());  
     }  
85    
     /**  
      * 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());  
     }  
86    
87      /**      /**
88       * setting value gauses get to return it       * setting value gauses get to return it

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

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8