--- jsr166/src/test/tck/ExchangerTest.java 2003/09/14 20:42:40 1.2 +++ jsr166/src/test/tck/ExchangerTest.java 2003/09/20 18:20:07 1.3 @@ -18,6 +18,9 @@ public class ExchangerTest extends JSR16 return new TestSuite(ExchangerTest.class); } + /** + * + */ public void testExchange() { final Exchanger e = new Exchanger(); Thread t1 = new Thread(new Runnable(){ @@ -28,7 +31,7 @@ public class ExchangerTest extends JSR16 Object w = e.exchange(v); threadAssertEquals(w, one); } catch(InterruptedException e){ - threadFail("unexpected exception"); + threadUnexpectedException(); } } }); @@ -40,7 +43,7 @@ public class ExchangerTest extends JSR16 Object w = e.exchange(v); threadAssertEquals(w, two); } catch(InterruptedException e){ - threadFail("unexpected exception"); + threadUnexpectedException(); } } }); @@ -50,10 +53,13 @@ public class ExchangerTest extends JSR16 t1.join(); t2.join(); } catch(InterruptedException ex) { - fail("unexpected exception"); + unexpectedException(); } } + /** + * + */ public void testTimedExchange() { final Exchanger e = new Exchanger(); Thread t1 = new Thread(new Runnable(){ @@ -64,9 +70,9 @@ public class ExchangerTest extends JSR16 Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); threadAssertEquals(w, one); } catch(InterruptedException e){ - threadFail("unexpected exception"); + threadUnexpectedException(); } catch(TimeoutException toe) { - threadFail("unexpected exception"); + threadUnexpectedException(); } } }); @@ -78,9 +84,9 @@ public class ExchangerTest extends JSR16 Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); threadAssertEquals(w, two); } catch(InterruptedException e){ - threadFail("unexpected exception"); + threadUnexpectedException(); } catch(TimeoutException toe) { - threadFail("unexpected exception"); + threadUnexpectedException(); } } }); @@ -90,17 +96,20 @@ public class ExchangerTest extends JSR16 t1.join(); t2.join(); } catch(InterruptedException ex) { - fail("unexpected exception"); + unexpectedException(); } } + /** + * + */ public void testExchange_InterruptedException(){ final Exchanger e = new Exchanger(); Thread t = new Thread(new Runnable() { public void run(){ try { e.exchange(one); - threadFail("should throw"); + threadShouldThrow(); } catch(InterruptedException success){ } } @@ -111,17 +120,20 @@ public class ExchangerTest extends JSR16 t.interrupt(); t.join(); } catch(InterruptedException ex) { - fail("unexpected exception"); + unexpectedException(); } } + /** + * + */ public void testTimedExchange_InterruptedException(){ final Exchanger e = new Exchanger(); Thread t = new Thread(new Runnable() { public void run(){ try { e.exchange(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadFail("should throw"); + threadShouldThrow(); } catch(InterruptedException success){ } catch(Exception e2){ threadFail("should throw IE"); @@ -133,17 +145,20 @@ public class ExchangerTest extends JSR16 t.interrupt(); t.join(); } catch(InterruptedException ex){ - fail("unexpected exception"); + unexpectedException(); } } + /** + * + */ public void testExchange_TimeOutException(){ final Exchanger e = new Exchanger(); Thread t = new Thread(new Runnable() { public void run(){ try { e.exchange(null, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadFail("should throw"); + threadShouldThrow(); } catch(TimeoutException success){ } catch(InterruptedException e2){ threadFail("should throw TOE"); @@ -154,7 +169,7 @@ public class ExchangerTest extends JSR16 t.start(); t.join(); } catch(InterruptedException ex){ - fail("unexpected exception"); + unexpectedException(); } } }