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

Comparing jsr166/src/test/tck/AbstractExecutorServiceTest.java (file contents):
Revision 1.19 by jsr166, Fri Nov 20 05:25:10 2009 UTC vs.
Revision 1.20 by jsr166, Sat Nov 21 02:33:20 2009 UTC

# Line 10 | Line 10
10   import junit.framework.*;
11   import java.util.*;
12   import java.util.concurrent.*;
13 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
14   import java.math.BigInteger;
15   import java.security.*;
16  
# Line 487 | Line 488 | public class AbstractExecutorServiceTest
488      public void testTimedInvokeAny1() throws Exception {
489          ExecutorService e = new DirectExecutorService();
490          try {
491 <            e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
491 >            e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
492              shouldThrow();
493          } catch (NullPointerException success) {
494          } finally {
# Line 517 | Line 518 | public class AbstractExecutorServiceTest
518      public void testTimedInvokeAny2() throws Exception {
519          ExecutorService e = new DirectExecutorService();
520          try {
521 <            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
521 >            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
522              shouldThrow();
523          } catch (IllegalArgumentException success) {
524          } finally {
# Line 537 | Line 538 | public class AbstractExecutorServiceTest
538              l.add(new Callable<Integer>() {
539                        public Integer call() { return 5/0; }});
540              l.add(null);
541 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
541 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
542              shouldThrow();
543          } catch (NullPointerException success) {
544          } finally {
# Line 554 | Line 555 | public class AbstractExecutorServiceTest
555          try {
556              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
557              l.add(new NPETask());
558 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
558 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
559              shouldThrow();
560          } catch (ExecutionException success) {
561              assertTrue(success.getCause() instanceof NullPointerException);
# Line 572 | Line 573 | public class AbstractExecutorServiceTest
573              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
574              l.add(new StringTask());
575              l.add(new StringTask());
576 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
576 >            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
577              assertSame(TEST_STRING, result);
578          } finally {
579              joinPool(e);
# Line 585 | Line 586 | public class AbstractExecutorServiceTest
586      public void testTimedInvokeAll1() throws InterruptedException {
587          ExecutorService e = new DirectExecutorService();
588          try {
589 <            e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
589 >            e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
590              shouldThrow();
591          } catch (NullPointerException success) {
592          } finally {
# Line 615 | Line 616 | public class AbstractExecutorServiceTest
616      public void testTimedInvokeAll2() throws InterruptedException {
617          ExecutorService e = new DirectExecutorService();
618          try {
619 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
619 >            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
620              assertTrue(r.isEmpty());
621          } finally {
622              joinPool(e);
# Line 631 | Line 632 | public class AbstractExecutorServiceTest
632              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
633              l.add(new StringTask());
634              l.add(null);
635 <            e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
635 >            e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
636              shouldThrow();
637          } catch (NullPointerException success) {
638          } finally {
# Line 647 | Line 648 | public class AbstractExecutorServiceTest
648          try {
649              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
650              l.add(new NPETask());
651 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
651 >            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
652              assertEquals(1, result.size());
653              for (Future<String> future : result) {
654                  try {
# Line 670 | Line 671 | public class AbstractExecutorServiceTest
671              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
672              l.add(new StringTask());
673              l.add(new StringTask());
674 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
674 >            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
675              assertEquals(2, result.size());
676              for (Future<String> future : result)
677                  assertSame(TEST_STRING, future.get());
# Line 689 | Line 690 | public class AbstractExecutorServiceTest
690              l.add(new StringTask());
691              l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
692              l.add(new StringTask());
693 <            List<Future<String>> result = e.invokeAll(l, SMALL_DELAY_MS, TimeUnit.MILLISECONDS);
693 >            List<Future<String>> result = e.invokeAll(l, SMALL_DELAY_MS, MILLISECONDS);
694              assertEquals(3, result.size());
695              Iterator<Future<String>> it = result.iterator();
696              Future<String> f1 = it.next();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines