ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/FutureTaskTest.java
(Generate patch)

Comparing jsr166/src/test/tck/FutureTaskTest.java (file contents):
Revision 1.9 by dl, Mon Dec 22 16:25:38 2003 UTC vs.
Revision 1.12 by jsr166, Mon Nov 2 20:28:31 2009 UTC

# Line 1 | Line 1
1   /*
2 < * Written by members of JCP JSR-166 Expert Group and released to the
3 < * public domain. Use, modify, and redistribute this code in any way
4 < * without acknowledgement. Other contributors include Andrew Wright,
5 < * Jeffrey Hayes, Pat Fischer, Mike Judd.
2 > * Written by Doug Lea with assistance from members of JCP JSR-166
3 > * Expert Group and released to the public domain, as explained at
4 > * http://creativecommons.org/licenses/publicdomain
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9   import junit.framework.*;
# Line 12 | Line 13 | import java.util.*;
13   public class FutureTaskTest extends JSR166TestCase {
14  
15      public static void main(String[] args) {
16 <        junit.textui.TestRunner.run (suite());  
16 >        junit.textui.TestRunner.run (suite());
17      }
18      public static Test suite() {
19          return new TestSuite(FutureTaskTest.class);
# Line 85 | Line 86 | public class FutureTaskTest extends JSR1
86  
87  
88      /**
89 <     * setting value gauses get to return it
89 >     * setting value causes get to return it
90       */
91      public void testSet() {
92          PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
# Line 166 | Line 167 | public class FutureTaskTest extends JSR1
167                  } });
168          Thread t = new  Thread(task);
169          t.start();
170 <        
170 >
171          try {
172              Thread.sleep(SHORT_DELAY_MS);
173              assertTrue(task.cancel(true));
# Line 195 | Line 196 | public class FutureTaskTest extends JSR1
196                  } });
197          Thread t = new  Thread(task);
198          t.start();
199 <        
199 >
200          try {
201              Thread.sleep(SHORT_DELAY_MS);
202              assertTrue(task.cancel(false));
# Line 242 | Line 243 | public class FutureTaskTest extends JSR1
243          } catch(InterruptedException e){
244              unexpectedException();
245  
246 <        }      
246 >        }
247      }
248  
249      /**
# Line 279 | Line 280 | public class FutureTaskTest extends JSR1
280              assertFalse(ft.isCancelled());
281          } catch(InterruptedException e){
282              unexpectedException();
283 <            
284 <        }      
283 >
284 >        }
285      }
286  
287      /**
# Line 310 | Line 311 | public class FutureTaskTest extends JSR1
311                      }
312                  });
313              Thread t2 = new Thread(ft);
314 <            t1.start();
314 >            t1.start();
315              t2.start();
316              Thread.sleep(SHORT_DELAY_MS);
317              ft.cancel(true);
# Line 349 | Line 350 | public class FutureTaskTest extends JSR1
350                      }
351                  });
352              Thread t2 = new Thread(ft);
353 <            t1.start();
353 >            t1.start();
354              t2.start();
355              Thread.sleep(SHORT_DELAY_MS);
356              ft.cancel(true);
# Line 359 | Line 360 | public class FutureTaskTest extends JSR1
360              unexpectedException();
361          }
362      }
363 <    
363 >
364  
365      /**
366       * A runtime exception in task causes get to throw ExecutionException
# Line 381 | Line 382 | public class FutureTaskTest extends JSR1
382              unexpectedException();
383          }
384      }
385 <  
385 >
386      /**
387       *  A runtime exception in task causes timed get to throw ExecutionException
388       */
# Line 396 | Line 397 | public class FutureTaskTest extends JSR1
397              ft.run();
398              ft.get(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
399              shouldThrow();
400 <        } catch(ExecutionException success) {
400 >        } catch(ExecutionException success) {
401          } catch(TimeoutException success) { } // unlikely but OK
402          catch(Exception e){
403              unexpectedException();
404          }
405      }
406 <      
406 >
407  
408      /**
409       * Interrupting a waiting get causes it to throw InterruptedException
# Line 410 | Line 411 | public class FutureTaskTest extends JSR1
411      public void testGet_InterruptedException() {
412          final FutureTask ft = new FutureTask(new NoOpCallable());
413          Thread t = new Thread(new Runnable() {
414 <                public void run() {                
414 >                public void run() {
415                      try {
416                          ft.get();
417                          threadShouldThrow();
# Line 436 | Line 437 | public class FutureTaskTest extends JSR1
437      public void testTimedGet_InterruptedException2() {
438          final FutureTask ft = new FutureTask(new NoOpCallable());
439          Thread t = new Thread(new Runnable() {
440 <                public void run() {                
440 >                public void run() {
441                      try {
442                          ft.get(LONG_DELAY_MS,TimeUnit.MILLISECONDS);
443                          threadShouldThrow();
# Line 455 | Line 456 | public class FutureTaskTest extends JSR1
456              unexpectedException();
457          }
458      }
459 <    
459 >
460      /**
461       * A timed out timed get throws TimeoutException
462       */
# Line 469 | Line 470 | public class FutureTaskTest extends JSR1
470              unexpectedException();
471          }
472      }
473 <    
473 >
474   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines