[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.6, Thu Sep 25 11:02:41 2003 UTC revision 1.8, Mon Dec 22 00:48:55 2003 UTC
# Line 21  Line 21 
21      /**      /**
22       * Subclass to expose protected methods       * Subclass to expose protected methods
23       */       */
24      static class MyFutureTask extends FutureTask {      static class PublicFutureTask extends FutureTask {
25          public MyFutureTask(Callable r) { super(r); }          public PublicFutureTask(Callable r) { super(r); }
26          public boolean reset() { return super.reset(); }          public boolean reset() { return super.reset(); }
27          public void setCancelled() { super.setCancelled(); }          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 68  Line 67 
67       * reset of a done task succeeds and changes status to not done       * reset of a done task succeeds and changes status to not done
68       */       */
69      public void testReset() {      public void testReset() {
70          MyFutureTask task = new MyFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
71          task.run();          task.run();
72          assertTrue(task.isDone());          assertTrue(task.isDone());
73          assertTrue(task.reset());          assertTrue(task.reset());
# Line 79  Line 78 
78       * Resetting after cancellation fails       * Resetting after cancellation fails
79       */       */
80      public void testResetAfterCancel() {      public void testResetAfterCancel() {
81          MyFutureTask task = new MyFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
82          assertTrue(task.cancel(false));          assertTrue(task.cancel(false));
83          task.run();          task.run();
84          assertTrue(task.isDone());          assertTrue(task.isDone());
# Line 87  Line 86 
86          assertFalse(task.reset());          assertFalse(task.reset());
87      }      }
88    
     /**  
      * setDone of new task causes isDone to be true  
      */  
     public void testSetDone() {  
         MyFutureTask task = new MyFutureTask(new NoOpCallable());  
         task.setDone();  
         assertTrue(task.isDone());  
         assertFalse(task.isCancelled());  
     }  
89    
90      /**      /**
91       * setCancelled of a new task causes isCancelled to be true       * setCancelled of a new task causes isCancelled to be true
92       */       */
93      public void testSetCancelled() {      public void testSetCancelled() {
94          MyFutureTask task = new MyFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
95          assertTrue(task.cancel(false));          assertTrue(task.cancel(false));
96          task.setCancelled();          task.setCancelled();
97          assertTrue(task.isDone());          assertTrue(task.isDone());
# Line 112  Line 102 
102       * setting value gauses get to return it       * setting value gauses get to return it
103       */       */
104      public void testSet() {      public void testSet() {
105          MyFutureTask task = new MyFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
106          task.set(one);          task.set(one);
107          try {          try {
108              assertEquals(task.get(), one);              assertEquals(task.get(), one);
# Line 127  Line 117 
117       */       */
118      public void testSetException() {      public void testSetException() {
119          Exception nse = new NoSuchElementException();          Exception nse = new NoSuchElementException();
120          MyFutureTask task = new MyFutureTask(new NoOpCallable());          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
121          task.setException(nse);          task.setException(nse);
122          try {          try {
123              Object x = task.get();              Object x = task.get();

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.8

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8