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

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8