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

Comparing jsr166/src/test/tck/ThreadPoolExecutorTest.java (file contents):
Revision 1.8 by dl, Sun Oct 5 23:00:40 2003 UTC vs.
Revision 1.11 by dl, Thu Dec 4 20:54:46 2003 UTC

# Line 177 | Line 177 | public class ThreadPoolExecutorTest exte
177          }
178      }
179  
180 +    /**
181 +     * getRejectedExecutionHandler returns handler in constructor if not set
182 +     */
183 +    public void testGetRejectedExecutionHandler() {
184 +        RejectedExecutionHandler h = new NoOpREHandler();
185 +        ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), h);
186 +        assertSame(h, p.getRejectedExecutionHandler());
187 +        p.shutdown();
188 +        joinPool(p);
189 +    }
190 +
191 +    /**
192 +     * setRejectedExecutionHandler sets the handler returned by
193 +     * getRejectedExecutionHandler
194 +     */
195 +    public void testSetRejectedExecutionHandler() {
196 +        ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
197 +        RejectedExecutionHandler h = new NoOpREHandler();
198 +        p.setRejectedExecutionHandler(h);
199 +        assertSame(h, p.getRejectedExecutionHandler());
200 +        p.shutdown();
201 +        joinPool(p);
202 +    }
203 +
204 +
205 +    /**
206 +     * setRejectedExecutionHandler(null) throws NPE
207 +     */
208 +    public void testSetRejectedExecutionHandlerNull() {
209 +        ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
210 +        try {
211 +            p.setRejectedExecutionHandler(null);
212 +            shouldThrow();
213 +        } catch (NullPointerException success) {
214 +        } finally {
215 +            joinPool(p);
216 +        }
217 +    }
218 +
219      
220      /**
221       *   getLargestPoolSize increases, but doesn't overestimate, when
# Line 293 | Line 332 | public class ThreadPoolExecutorTest exte
332      public void testGetQueue() {
333          BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
334          ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
335 <        CancellableTask[] tasks = new CancellableTask[5];
335 >        FutureTask[] tasks = new FutureTask[5];
336          for(int i = 0; i < 5; i++){
337 <            tasks[i] = new CancellableTask(new MediumPossiblyInterruptedRunnable());
337 >            tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
338              p1.execute(tasks[i]);
339          }
340          try {
# Line 318 | Line 357 | public class ThreadPoolExecutorTest exte
357      public void testRemove() {
358          BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
359          ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
360 <        CancellableTask[] tasks = new CancellableTask[5];
360 >        FutureTask[] tasks = new FutureTask[5];
361          for(int i = 0; i < 5; i++){
362 <            tasks[i] = new CancellableTask(new MediumPossiblyInterruptedRunnable());
362 >            tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
363              p1.execute(tasks[i]);
364          }
365          try {
# Line 347 | Line 386 | public class ThreadPoolExecutorTest exte
386       */
387      public void testPurge() {
388          ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
389 <        CancellableTask[] tasks = new CancellableTask[5];
389 >        FutureTask[] tasks = new FutureTask[5];
390          for(int i = 0; i < 5; i++){
391 <            tasks[i] = new CancellableTask(new MediumPossiblyInterruptedRunnable());
391 >            tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
392              p1.execute(tasks[i]);
393          }
394          tasks[4].cancel(true);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines