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.46 by jsr166, Mon May 29 22:44:26 2017 UTC vs.
Revision 1.50 by jsr166, Wed Jan 27 01:57:24 2021 UTC

# Line 47 | Line 47 | public class AbstractExecutorServiceTest
47          public void shutdown() { shutdown = true; }
48          public List<Runnable> shutdownNow() {
49              shutdown = true;
50 <            return Collections.EMPTY_LIST;
50 >            return Collections.emptyList();
51          }
52          public boolean isShutdown() { return shutdown; }
53          public boolean isTerminated() { return isShutdown(); }
# Line 111 | Line 111 | public class AbstractExecutorServiceTest
111          Runnable r = new CheckedRunnable() {
112              public void realRun() throws Exception {
113                  ExecutorService e = new DirectExecutorService();
114 <                Future future = e.submit(Executors.callable(new PrivilegedAction() {
114 >                Future<?> future = e.submit(Executors.callable(new PrivilegedAction<Object>() {
115                      public Object run() {
116                          return TEST_STRING;
117                      }}));
# Line 132 | Line 132 | public class AbstractExecutorServiceTest
132          Runnable r = new CheckedRunnable() {
133              public void realRun() throws Exception {
134                  ExecutorService e = new DirectExecutorService();
135 <                Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
135 >                Future<?> future = e.submit(Executors.callable(new PrivilegedExceptionAction<Object>() {
136                      public Object run() {
137                          return TEST_STRING;
138                      }}));
# Line 150 | Line 150 | public class AbstractExecutorServiceTest
150          Runnable r = new CheckedRunnable() {
151              public void realRun() throws Exception {
152                  ExecutorService e = new DirectExecutorService();
153 <                Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
153 >                Future<?> future = e.submit(Executors.callable(new PrivilegedExceptionAction<Object>() {
154                      public Object run() throws Exception {
155                          throw new IndexOutOfBoundsException();
156                      }}));
# Line 166 | Line 166 | public class AbstractExecutorServiceTest
166      }
167  
168      /**
169 <     * execute(null runnable) throws NPE
169 >     * Submitting null tasks throws NullPointerException
170       */
171 <    public void testExecuteNullRunnable() {
172 <        ExecutorService e = new DirectExecutorService();
173 <        try {
174 <            e.submit((Runnable) null);
175 <            shouldThrow();
176 <        } catch (NullPointerException success) {}
177 <    }
178 <
179 <    /**
180 <     * submit(null callable) throws NPE
181 <     */
182 <    public void testSubmitNullCallable() {
183 <        ExecutorService e = new DirectExecutorService();
184 <        try {
185 <            e.submit((Callable) null);
186 <            shouldThrow();
187 <        } catch (NullPointerException success) {}
171 >    public void testNullTaskSubmission() {
172 >        final ExecutorService e = new DirectExecutorService();
173 >        try (PoolCleaner cleaner = cleaner(e)) {
174 >            assertNullTaskSubmissionThrowsNullPointerException(e);
175 >        }
176      }
177  
178      /**
# Line 193 | Line 181 | public class AbstractExecutorServiceTest
181      public void testInterruptedSubmit() throws InterruptedException {
182          final CountDownLatch submitted    = new CountDownLatch(1);
183          final CountDownLatch quittingTime = new CountDownLatch(1);
184 <        final Callable<Void> awaiter = new CheckedCallable<Void>() {
184 >        final Callable<Void> awaiter = new CheckedCallable<>() {
185              public Void realCall() throws InterruptedException {
186                  assertTrue(quittingTime.await(2*LONG_DELAY_MS, MILLISECONDS));
187                  return null;
# Line 225 | Line 213 | public class AbstractExecutorServiceTest
213                                     60, TimeUnit.SECONDS,
214                                     new ArrayBlockingQueue<Runnable>(10));
215          try (PoolCleaner cleaner = cleaner(p)) {
216 <            Callable c = new Callable() {
216 >            Callable<Object> c = new Callable<>() {
217                  public Object call() { throw new ArithmeticException(); }};
218              try {
219                  p.submit(c).get();
# Line 596 | Line 584 | public class AbstractExecutorServiceTest
584                      e.invokeAll(tasks, timeout, MILLISECONDS);
585                  assertEquals(tasks.size(), futures.size());
586                  assertTrue(millisElapsedSince(startTime) >= timeout);
587 <                for (Future future : futures)
587 >                for (Future<?> future : futures)
588                      assertTrue(future.isDone());
589                  try {
590                      assertEquals("0", futures.get(0).get());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines