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

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

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

revision 1.31, Sat May 28 22:33:35 2011 UTC revision 1.32, Sun May 29 07:01:17 2011 UTC
# Line 9  Line 9 
9  import junit.framework.*;  import junit.framework.*;
10  import java.util.*;  import java.util.*;
11  import java.util.concurrent.*;  import java.util.concurrent.*;
12    import java.util.concurrent.atomic.AtomicBoolean;
13  import static java.util.concurrent.TimeUnit.MILLISECONDS;  import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import java.math.BigInteger;  
14  import java.security.*;  import java.security.*;
15    
16  public class AbstractExecutorServiceTest extends JSR166TestCase {  public class AbstractExecutorServiceTest extends JSR166TestCase {
# Line 45  Line 45 
45       */       */
46      public void testExecuteRunnable() throws Exception {      public void testExecuteRunnable() throws Exception {
47          ExecutorService e = new DirectExecutorService();          ExecutorService e = new DirectExecutorService();
48          TrackedShortRunnable task = new TrackedShortRunnable();          final AtomicBoolean done = new AtomicBoolean(false);
49          assertFalse(task.done);          CheckedRunnable task = new CheckedRunnable() {
50                public void realRun() {
51                    done.set(true);
52                }};
53          Future<?> future = e.submit(task);          Future<?> future = e.submit(task);
54          future.get();          assertNull(future.get());
55          assertTrue(task.done);          assertNull(future.get(0, MILLISECONDS));
56            assertTrue(done.get());
57            assertTrue(future.isDone());
58            assertFalse(future.isCancelled());
59      }      }
60    
61      /**      /**
# Line 588  Line 594 
594              l.add(new StringTask());              l.add(new StringTask());
595              List<Future<String>> futures =              List<Future<String>> futures =
596                  e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS);                  e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS);
597              assertEquals(3, futures.size());              assertEquals(l.size(), futures.size());
598              Iterator<Future<String>> it = futures.iterator();              for (Future future : futures)
599              Future<String> f1 = it.next();                  assertTrue(future.isDone());
600              Future<String> f2 = it.next();              assertFalse(futures.get(0).isCancelled());
601              Future<String> f3 = it.next();              assertFalse(futures.get(1).isCancelled());
602              assertTrue(f1.isDone());              assertTrue(futures.get(2).isCancelled());
             assertFalse(f1.isCancelled());  
             assertTrue(f2.isDone());  
             assertFalse(f2.isCancelled());  
             assertTrue(f3.isDone());  
             assertTrue(f3.isCancelled());  
603          } finally {          } finally {
604              joinPool(e);              joinPool(e);
605          }          }

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8