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

Comparing jsr166/src/test/tck/CyclicBarrierTest.java (file contents):
Revision 1.4 by dl, Thu Sep 25 11:02:41 2003 UTC vs.
Revision 1.5 by dl, Sun Oct 5 23:00:40 2003 UTC

# Line 52 | Line 52 | public class CyclicBarrierTest extends J
52      }
53  
54      /**
55 <     * A 1-party barrier triggers properly
55 >     * A 1-party barrier triggers after single await
56       */
57      public void testSingleParty() {
58          try {
# Line 88 | Line 88 | public class CyclicBarrierTest extends J
88      }
89  
90      /**
91 <     * A 2-party/thread barrier triggers properly
91 >     * A 2-party/thread barrier triggers after both threads invoke await
92       */
93      public void testTwoParties() {
94          final CyclicBarrier b = new CyclicBarrier(2);
# Line 219 | Line 219 | public class CyclicBarrierTest extends J
219          } catch(InterruptedException e){
220              unexpectedException();
221          }
222 +    }
223 +
224 +    /**
225 +     * A timeout in one party causes others waiting in timed await to
226 +     * throw BrokenBarrierException
227 +     */
228 +    public void testAwait4_Timeout_BrokenBarrier() {
229 +      final CyclicBarrier c = new CyclicBarrier(3);
230 +        Thread t1 = new Thread(new Runnable() {
231 +                public void run() {
232 +                    try {
233 +                        c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
234 +                        threadShouldThrow();
235 +                    } catch(TimeoutException success){
236 +                    } catch(Exception b){
237 +                        threadUnexpectedException();
238 +                    }
239 +                }
240 +            });
241 +        Thread t2 = new Thread(new Runnable() {
242 +                public void run() {
243 +                    try {
244 +                        c.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
245 +                        threadShouldThrow();                        
246 +                    } catch(BrokenBarrierException success){
247 +                    } catch(Exception i){
248 +                        threadUnexpectedException();
249 +                    }
250 +                }
251 +            });
252 +        try {
253 +            t1.start();
254 +            t2.start();
255 +            t1.join();
256 +            t2.join();
257 +        } catch(InterruptedException e){
258 +            unexpectedException();
259 +        }
260 +    }
261 +
262 +    /**
263 +     * A timeout in one party causes others waiting in await to
264 +     * throw BrokenBarrierException
265 +     */
266 +    public void testAwait5_Timeout_BrokenBarrier() {
267 +      final CyclicBarrier c = new CyclicBarrier(3);
268 +        Thread t1 = new Thread(new Runnable() {
269 +                public void run() {
270 +                    try {
271 +                        c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
272 +                        threadShouldThrow();
273 +                    } catch(TimeoutException success){
274 +                    } catch(Exception b){
275 +                        threadUnexpectedException();
276 +                    }
277 +                }
278 +            });
279 +        Thread t2 = new Thread(new Runnable() {
280 +                public void run() {
281 +                    try {
282 +                        c.await();
283 +                        threadShouldThrow();                        
284 +                    } catch(BrokenBarrierException success){
285 +                    } catch(Exception i){
286 +                        threadUnexpectedException();
287 +                    }
288 +                }
289 +            });
290 +        try {
291 +            t1.start();
292 +            t2.start();
293 +            t1.join();
294 +            t2.join();
295 +        } catch(InterruptedException e){
296 +            unexpectedException();
297 +        }
298      }
299      
300      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines