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

Comparing jsr166/src/test/tck/ExecutorCompletionServiceTest.java (file contents):
Revision 1.9 by jsr166, Sat Nov 21 02:33:20 2009 UTC vs.
Revision 1.10 by jsr166, Sat Nov 21 06:31:05 2009 UTC

# Line 31 | Line 31 | public class ExecutorCompletionServiceTe
31          try {
32              ExecutorCompletionService ecs = new ExecutorCompletionService(null);
33              shouldThrow();
34 <        } catch (NullPointerException success) {
35 <        }
34 >        } catch (NullPointerException success) {}
35      }
36  
37      /**
# Line 43 | Line 42 | public class ExecutorCompletionServiceTe
42              ExecutorService e = Executors.newCachedThreadPool();
43              ExecutorCompletionService ecs = new ExecutorCompletionService(e, null);
44              shouldThrow();
45 <        } catch (NullPointerException success) {
47 <        }
45 >        } catch (NullPointerException success) {}
46      }
47  
48      /**
# Line 82 | Line 80 | public class ExecutorCompletionServiceTe
80      /**
81       * A taken submitted task is completed
82       */
83 <    public void testTake() {
83 >    public void testTake() throws InterruptedException {
84          ExecutorService e = Executors.newCachedThreadPool();
85          ExecutorCompletionService ecs = new ExecutorCompletionService(e);
86          try {
# Line 90 | Line 88 | public class ExecutorCompletionServiceTe
88              ecs.submit(c);
89              Future f = ecs.take();
90              assertTrue(f.isDone());
93        } catch (Exception ex) {
94            unexpectedException();
91          } finally {
92              joinPool(e);
93          }
# Line 100 | Line 96 | public class ExecutorCompletionServiceTe
96      /**
97       * Take returns the same future object returned by submit
98       */
99 <    public void testTake2() {
99 >    public void testTake2() throws InterruptedException {
100          ExecutorService e = Executors.newCachedThreadPool();
101          ExecutorCompletionService ecs = new ExecutorCompletionService(e);
102          try {
# Line 108 | Line 104 | public class ExecutorCompletionServiceTe
104              Future f1 = ecs.submit(c);
105              Future f2 = ecs.take();
106              assertSame(f1, f2);
111        } catch (Exception ex) {
112            unexpectedException();
107          } finally {
108              joinPool(e);
109          }
# Line 118 | Line 112 | public class ExecutorCompletionServiceTe
112      /**
113       * If poll returns non-null, the returned task is completed
114       */
115 <    public void testPoll1() {
115 >    public void testPoll1() throws InterruptedException {
116          ExecutorService e = Executors.newCachedThreadPool();
117          ExecutorCompletionService ecs = new ExecutorCompletionService(e);
118          try {
# Line 133 | Line 127 | public class ExecutorCompletionServiceTe
127                      break;
128                  }
129              }
136        } catch (Exception ex) {
137            unexpectedException();
130          } finally {
131              joinPool(e);
132          }
# Line 143 | Line 135 | public class ExecutorCompletionServiceTe
135      /**
136       * If timed poll returns non-null, the returned task is completed
137       */
138 <    public void testPoll2() {
138 >    public void testPoll2() throws InterruptedException {
139          ExecutorService e = Executors.newCachedThreadPool();
140          ExecutorCompletionService ecs = new ExecutorCompletionService(e);
141          try {
# Line 153 | Line 145 | public class ExecutorCompletionServiceTe
145              Future f = ecs.poll(SHORT_DELAY_MS, MILLISECONDS);
146              if (f != null)
147                  assertTrue(f.isDone());
156        } catch (Exception ex) {
157            unexpectedException();
148          } finally {
149              joinPool(e);
150          }
# Line 163 | Line 153 | public class ExecutorCompletionServiceTe
153        * Submitting to underlying AES that overrides newTaskFor(Callable)
154        * returns and eventually runs Future returned by newTaskFor.
155        */
156 <     public void testNewTaskForCallable() {
156 >     public void testNewTaskForCallable() throws InterruptedException {
157           final AtomicBoolean done = new AtomicBoolean(false);
158           class MyCallableFuture<V> extends FutureTask<V> {
159               MyCallableFuture(Callable<V> c) { super(c); }
# Line 187 | Line 177 | public class ExecutorCompletionServiceTe
177               Future f2 = ecs.take();
178               assertSame("submit and take must return same objects", f1, f2);
179               assertTrue("completed task must have set done", done.get());
190         } catch (Exception ex) {
191             unexpectedException();
180           } finally {
181               joinPool(e);
182           }
# Line 198 | Line 186 | public class ExecutorCompletionServiceTe
186        * Submitting to underlying AES that overrides newTaskFor(Runnable,T)
187        * returns and eventually runs Future returned by newTaskFor.
188        */
189 <     public void testNewTaskForRunnable() {
189 >     public void testNewTaskForRunnable() throws InterruptedException {
190           final AtomicBoolean done = new AtomicBoolean(false);
191           class MyRunnableFuture<V> extends FutureTask<V> {
192               MyRunnableFuture(Runnable t, V r) { super(t, r); }
# Line 222 | Line 210 | public class ExecutorCompletionServiceTe
210               Future f2 = ecs.take();
211               assertSame("submit and take must return same objects", f1, f2);
212               assertTrue("completed task must have set done", done.get());
225         } catch (Exception ex) {
226             unexpectedException();
213           } finally {
214               joinPool(e);
215           }
216       }
217  
232
233
218   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines