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

Comparing jsr166/src/test/tck/ExecutorsTest.java (file contents):
Revision 1.49 by jsr166, Mon May 29 22:44:26 2017 UTC vs.
Revision 1.51 by jsr166, Mon Dec 16 22:55:54 2019 UTC

# Line 63 | Line 63 | public class ExecutorsTest extends JSR16
63       */
64      public void testNewCachedThreadPool3() {
65          try {
66 <            ExecutorService e = Executors.newCachedThreadPool(null);
66 >            ExecutorService unused = Executors.newCachedThreadPool(null);
67              shouldThrow();
68          } catch (NullPointerException success) {}
69      }
# Line 97 | Line 97 | public class ExecutorsTest extends JSR16
97       */
98      public void testNewSingleThreadExecutor3() {
99          try {
100 <            ExecutorService e = Executors.newSingleThreadExecutor(null);
100 >            ExecutorService unused = Executors.newSingleThreadExecutor(null);
101              shouldThrow();
102          } catch (NullPointerException success) {}
103      }
# Line 145 | Line 145 | public class ExecutorsTest extends JSR16
145       */
146      public void testNewFixedThreadPool3() {
147          try {
148 <            ExecutorService e = Executors.newFixedThreadPool(2, null);
148 >            ExecutorService unused = Executors.newFixedThreadPool(2, null);
149              shouldThrow();
150          } catch (NullPointerException success) {}
151      }
# Line 155 | Line 155 | public class ExecutorsTest extends JSR16
155       */
156      public void testNewFixedThreadPool4() {
157          try {
158 <            ExecutorService e = Executors.newFixedThreadPool(0);
158 >            ExecutorService unused = Executors.newFixedThreadPool(0);
159              shouldThrow();
160          } catch (IllegalArgumentException success) {}
161      }
# Line 177 | Line 177 | public class ExecutorsTest extends JSR16
177       */
178      public void testUnconfigurableExecutorServiceNPE() {
179          try {
180 <            ExecutorService e = Executors.unconfigurableExecutorService(null);
180 >            ExecutorService unused =
181 >                Executors.unconfigurableExecutorService(null);
182              shouldThrow();
183          } catch (NullPointerException success) {}
184      }
# Line 187 | Line 188 | public class ExecutorsTest extends JSR16
188       */
189      public void testUnconfigurableScheduledExecutorServiceNPE() {
190          try {
191 <            ExecutorService e = Executors.unconfigurableScheduledExecutorService(null);
191 >            ExecutorService unused =
192 >                Executors.unconfigurableScheduledExecutorService(null);
193              shouldThrow();
194          } catch (NullPointerException success) {}
195      }
# Line 551 | Line 553 | public class ExecutorsTest extends JSR16
553       */
554      public void testCallableNPE1() {
555          try {
556 <            Callable c = Executors.callable((Runnable) null);
556 >            Callable unused = Executors.callable((Runnable) null);
557              shouldThrow();
558          } catch (NullPointerException success) {}
559      }
# Line 561 | Line 563 | public class ExecutorsTest extends JSR16
563       */
564      public void testCallableNPE2() {
565          try {
566 <            Callable c = Executors.callable((Runnable) null, one);
566 >            Callable unused = Executors.callable((Runnable) null, one);
567              shouldThrow();
568          } catch (NullPointerException success) {}
569      }
# Line 571 | Line 573 | public class ExecutorsTest extends JSR16
573       */
574      public void testCallableNPE3() {
575          try {
576 <            Callable c = Executors.callable((PrivilegedAction) null);
576 >            Callable unused = Executors.callable((PrivilegedAction) null);
577              shouldThrow();
578          } catch (NullPointerException success) {}
579      }
# Line 581 | Line 583 | public class ExecutorsTest extends JSR16
583       */
584      public void testCallableNPE4() {
585          try {
586 <            Callable c = Executors.callable((PrivilegedExceptionAction) null);
586 >            Callable unused = Executors.callable((PrivilegedExceptionAction) null);
587              shouldThrow();
588          } catch (NullPointerException success) {}
589      }
590  
591 +    /**
592 +     * callable(runnable, x).toString() contains toString of wrapped task
593 +     */
594 +    public void testCallable_withResult_toString() {
595 +        if (testImplementationDetails) {
596 +            Runnable r = () -> {};
597 +            Callable<String> c = Executors.callable(r, "");
598 +            assertEquals(
599 +                identityString(c) + "[Wrapped task = " + r.toString() + "]",
600 +                c.toString());
601 +        }
602 +    }
603 +
604 +    /**
605 +     * callable(runnable).toString() contains toString of wrapped task
606 +     */
607 +    public void testCallable_toString() {
608 +        if (testImplementationDetails) {
609 +            Runnable r = () -> {};
610 +            Callable<Object> c = Executors.callable(r);
611 +            assertEquals(
612 +                identityString(c) + "[Wrapped task = " + r.toString() + "]",
613 +                c.toString());
614 +        }
615 +    }
616 +
617 +    /**
618 +     * privilegedCallable(callable).toString() contains toString of wrapped task
619 +     */
620 +    public void testPrivilegedCallable_toString() {
621 +        if (testImplementationDetails) {
622 +            Callable<String> c = () -> "";
623 +            Callable<String> priv = Executors.privilegedCallable(c);
624 +            assertEquals(
625 +                identityString(priv) + "[Wrapped task = " + c.toString() + "]",
626 +                priv.toString());
627 +        }
628 +    }
629 +
630 +    /**
631 +     * privilegedCallableUsingCurrentClassLoader(callable).toString()
632 +     * contains toString of wrapped task
633 +     */
634 +    public void testPrivilegedCallableUsingCurrentClassLoader_toString() {
635 +        if (testImplementationDetails) {
636 +            Callable<String> c = () -> "";
637 +            Callable<String> priv = Executors.privilegedCallableUsingCurrentClassLoader(c);
638 +            assertEquals(
639 +                identityString(priv) + "[Wrapped task = " + c.toString() + "]",
640 +                priv.toString());
641 +        }
642 +    }
643   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines