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

Comparing jsr166/src/test/tck/PhaserTest.java (file contents):
Revision 1.5 by jsr166, Mon Aug 3 20:33:57 2009 UTC vs.
Revision 1.6 by jsr166, Mon Aug 3 22:06:50 2009 UTC

# Line 40 | Line 40 | public class PhaserTest extends JSR166Te
40      public void testConstructor2() {
41          try {
42              new Phaser(-1);
43 <            this.shouldThrow();
43 >            shouldThrow();
44          } catch (IllegalArgumentException success) {
45          }
46      }
# Line 230 | Line 230 | public class PhaserTest extends JSR166Te
230              Phaser phaser = new Phaser();
231              phaser.arriveAndDeregister();
232              shouldThrow();
233
233          } catch (IllegalStateException success) {
234          }
235      }
# Line 325 | Line 324 | public class PhaserTest extends JSR166Te
324       * phaser
325       */
326      public void testAwaitAdvance2() {
327 <        try {
328 <            Phaser phaser = new Phaser();
330 <            phaser.awaitAdvance(-1);
331 <        } catch (Exception failure) {
332 <            this.unexpectedException();
333 <        }
327 >        Phaser phaser = new Phaser();
328 >        phaser.awaitAdvance(-1);
329      }
330  
331      /**
332       * awaitAdvance while waiting does not abort on interrupt.
333       */
334 <    public void testAwaitAdvance3() {
334 >    public void testAwaitAdvance3() throws InterruptedException {
335          final Phaser phaser = new Phaser();
336  
337          Thread th1 = new Thread(new CheckedRunnable() {
# Line 347 | Line 342 | public class PhaserTest extends JSR166Te
342              }});
343          phaser.register();
344          th1.start();
345 <        try {
346 <            Thread.sleep(SHORT_DELAY_MS);
347 <            th1.interrupt();
348 <            Thread.sleep(LONG_DELAY_MS);
354 <            phaser.arrive();
355 <        } catch (InterruptedException failure) {
356 <            threadUnexpectedException(failure);
357 <        }
345 >        Thread.sleep(SHORT_DELAY_MS);
346 >        th1.interrupt();
347 >        Thread.sleep(LONG_DELAY_MS);
348 >        phaser.arrive();
349          assertFalse(th1.isInterrupted());
350      }
351  
# Line 395 | Line 386 | public class PhaserTest extends JSR166Te
386                  void realRun() {
387                      getRunnable(SHORT_DELAY_MS).run();
388                      phaser.arrive();
389 <                }
399 <                }).start();
389 >                }}).start();
390              phase = phaser.awaitAdvance(phaser.arrive());
391              threadAssertEquals(phase, phaser.getPhase());
392          }
# Line 457 | Line 447 | public class PhaserTest extends JSR166Te
447      /**
448       * Interrupted arriveAndAwaitAdvance does not throw InterruptedException
449       */
450 <    public void testArriveAndAwaitAdvance2() {
450 >    public void testArriveAndAwaitAdvance2() throws InterruptedException {
451          final Phaser phaser = new Phaser(2);
452          Thread th = new Thread(new CheckedRunnable() {
453              void realRun() {
454                  phaser.arriveAndAwaitAdvance();
455              }});
456  
457 <        try {
458 <            th.start();
459 <            Thread.sleep(LONG_DELAY_MS);
460 <            th.interrupt();
461 <            Thread.sleep(LONG_DELAY_MS);
472 <            phaser.arrive();
473 <        } catch (InterruptedException failure) {
474 <            this.unexpectedException();
475 <        }
457 >        th.start();
458 >        Thread.sleep(LONG_DELAY_MS);
459 >        th.interrupt();
460 >        Thread.sleep(LONG_DELAY_MS);
461 >        phaser.arrive();
462          assertFalse(th.isInterrupted());
463      }
464  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines