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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.25 by jsr166, Mon Sep 13 20:48:58 2010 UTC vs.
Revision 1.26 by jsr166, Thu Sep 16 00:52:49 2010 UTC

# Line 161 | Line 161 | public class ForkJoinPoolTest extends JS
161      public void testDefaultInitialState() {
162          ForkJoinPool p = new ForkJoinPool(1);
163          try {
164 <            assertTrue(p.getFactory() ==
165 <                       ForkJoinPool.defaultForkJoinWorkerThreadFactory);
164 >            assertSame(ForkJoinPool.defaultForkJoinWorkerThreadFactory,
165 >                       p.getFactory());
166              assertTrue(p.isQuiescent());
167              assertFalse(p.getAsyncMode());
168 <            assertTrue(p.getActiveThreadCount() == 0);
169 <            assertTrue(p.getStealCount() == 0);
170 <            assertTrue(p.getQueuedTaskCount() == 0);
171 <            assertTrue(p.getQueuedSubmissionCount() == 0);
168 >            assertEquals(0, p.getActiveThreadCount());
169 >            assertEquals(0, p.getStealCount());
170 >            assertEquals(0, p.getQueuedTaskCount());
171 >            assertEquals(0, p.getQueuedSubmissionCount());
172              assertFalse(p.hasQueuedSubmissions());
173              assertFalse(p.isShutdown());
174              assertFalse(p.isTerminating());
# Line 205 | Line 205 | public class ForkJoinPoolTest extends JS
205      public void testGetParallelism() {
206          ForkJoinPool p = new ForkJoinPool(1);
207          try {
208 <            assertTrue(p.getParallelism() == 1);
208 >            assertEquals(1, p.getParallelism());
209          } finally {
210              joinPool(p);
211          }
# Line 217 | Line 217 | public class ForkJoinPoolTest extends JS
217      public void testGetPoolSize() {
218          ForkJoinPool p = new ForkJoinPool(1);
219          try {
220 <            assertTrue(p.getActiveThreadCount() == 0);
220 >            assertEquals(0, p.getActiveThreadCount());
221              Future<String> future = p.submit(new StringTask());
222 <            assertTrue(p.getPoolSize() == 1);
222 >            assertEquals(1, p.getPoolSize());
223          } finally {
224              joinPool(p);
225          }
# Line 233 | Line 233 | public class ForkJoinPoolTest extends JS
233       */
234      public void testSetUncaughtExceptionHandler() throws InterruptedException {
235          MyHandler eh = new MyHandler();
236 <        ForkJoinPool p = new ForkJoinPool(1, new FailingThreadFactory(), eh, false);
236 >        ForkJoinPool p = new ForkJoinPool(1, new FailingThreadFactory(),
237 >                                          eh, false);
238          try {
239 <            assert(eh == p.getUncaughtExceptionHandler());
239 >            assertSame(eh, p.getUncaughtExceptionHandler());
240              p.execute(new FailingTask());
241              Thread.sleep(MEDIUM_DELAY_MS);
242              assertTrue(eh.catches > 0);
# Line 254 | Line 255 | public class ForkJoinPoolTest extends JS
255          ForkJoinPool p = new ForkJoinPool(2);
256          try {
257              p.invoke(new FibTask(20));
258 <            assertTrue(p.getFactory() ==
259 <                       ForkJoinPool.defaultForkJoinWorkerThreadFactory);
258 >            assertSame(ForkJoinPool.defaultForkJoinWorkerThreadFactory,
259 >                       p.getFactory());
260              Thread.sleep(MEDIUM_DELAY_MS);
261              assertTrue(p.isQuiescent());
262              assertFalse(p.getAsyncMode());
263 <            assertTrue(p.getActiveThreadCount() == 0);
264 <            assertTrue(p.getQueuedTaskCount() == 0);
265 <            assertTrue(p.getQueuedSubmissionCount() == 0);
263 >            assertEquals(0, p.getActiveThreadCount());
264 >            assertEquals(0, p.getQueuedTaskCount());
265 >            assertEquals(0, p.getQueuedSubmissionCount());
266              assertFalse(p.hasQueuedSubmissions());
267              assertFalse(p.isShutdown());
268              assertFalse(p.isTerminating());
# Line 278 | Line 279 | public class ForkJoinPoolTest extends JS
279          ForkJoinPool p = new ForkJoinPool(1);
280          try {
281              ForkJoinTask<Integer> f = p.submit(new FibTask(8));
282 <            int r = f.get();
282 <            assertTrue(r == 21);
282 >            assertEquals(21, (int) f.get());
283          } finally {
284              joinPool(p);
285          }
# Line 293 | Line 293 | public class ForkJoinPoolTest extends JS
293          try {
294              p.shutdown();
295              assertTrue(p.isShutdown());
296 <            ForkJoinTask<Integer> f = p.submit(new FibTask(8));
297 <            shouldThrow();
298 <        } catch (RejectedExecutionException success) {
296 >            try {
297 >                ForkJoinTask<Integer> f = p.submit(new FibTask(8));
298 >                shouldThrow();
299 >            } catch (RejectedExecutionException success) {}
300          } finally {
301              joinPool(p);
302          }
# Line 311 | Line 312 | public class ForkJoinPoolTest extends JS
312              ManagedLocker locker = new ManagedLocker(lock);
313              ForkJoinTask<Integer> f = new LockingFibTask(30, locker, lock);
314              p.execute(f);
315 <            int r = f.get();
315 <            assertTrue(r == 832040);
315 >            assertEquals(832040, (int) f.get());
316          } finally {
317              p.shutdownNow(); // don't wait out shutdown
318          }
# Line 525 | Line 525 | public class ForkJoinPoolTest extends JS
525       */
526      public void testExecuteNullRunnable() {
527          ExecutorService e = new ForkJoinPool(1);
528 +        TrackedShortRunnable task = null;
529          try {
529            TrackedShortRunnable task = null;
530              Future<?> future = e.submit(task);
531              shouldThrow();
532          } catch (NullPointerException success) {
# Line 541 | Line 541 | public class ForkJoinPoolTest extends JS
541       */
542      public void testSubmitNullCallable() {
543          ExecutorService e = new ForkJoinPool(1);
544 +        StringTask t = null;
545          try {
545            StringTask t = null;
546              Future<String> future = e.submit(t);
547              shouldThrow();
548          } catch (NullPointerException success) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines