--- jsr166/src/test/tck/LinkedBlockingDequeTest.java 2009/11/21 08:37:39 1.9 +++ jsr166/src/test/tck/LinkedBlockingDequeTest.java 2009/11/21 10:25:05 1.11 @@ -276,7 +276,7 @@ public class LinkedBlockingDequeTest ext } /** - * Constructor throws IAE if capacity argument nonpositive + * Constructor throws IAE if capacity argument nonpositive */ public void testConstructor2() { try { @@ -548,25 +548,25 @@ public class LinkedBlockingDequeTest ext /** * put(null) throws NPE */ - public void testPutNull() throws InterruptedException { + public void testPutNull() throws InterruptedException { try { LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); q.put(null); shouldThrow(); } catch (NullPointerException success) {} - } + } /** * all elements successfully put are contained */ - public void testPut() throws InterruptedException { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); - for (int i = 0; i < SIZE; ++i) { - Integer I = new Integer(i); - q.put(I); - assertTrue(q.contains(I)); - } - assertEquals(0, q.remainingCapacity()); + public void testPut() throws InterruptedException { + LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + for (int i = 0; i < SIZE; ++i) { + Integer I = new Integer(i); + q.put(I); + assertTrue(q.contains(I)); + } + assertEquals(0, q.remainingCapacity()); } /** @@ -600,24 +600,23 @@ public class LinkedBlockingDequeTest ext */ public void testPutWithTake() throws InterruptedException { final LinkedBlockingDeque q = new LinkedBlockingDeque(2); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - threadShouldThrow(); - } catch (InterruptedException success) { - threadAssertTrue(added >= 2); - } + Thread t = new Thread(new CheckedRunnable() { + public void realRun() { + int added = 0; + try { + q.put(new Object()); + ++added; + q.put(new Object()); + ++added; + q.put(new Object()); + ++added; + q.put(new Object()); + ++added; + threadShouldThrow(); + } catch (InterruptedException success) { + threadAssertTrue(added >= 2); } - }); + }}); t.start(); Thread.sleep(SHORT_DELAY_MS); @@ -793,21 +792,21 @@ public class LinkedBlockingDequeTest ext * putFirst blocks interruptibly if full */ public void testBlockingPutFirst() throws InterruptedException { - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); - for (int i = 0; i < SIZE; ++i) { - q.putFirst(new Integer(i)); - ++added; - } - q.putFirst(new Integer(SIZE)); - threadShouldThrow(); - } catch (InterruptedException success) { - threadAssertEquals(added, SIZE); + Thread t = new Thread(new CheckedRunnable() { + public void realRun() { + int added = 0; + try { + LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + for (int i = 0; i < SIZE; ++i) { + q.putFirst(new Integer(i)); + ++added; } - }}); + q.putFirst(new Integer(SIZE)); + threadShouldThrow(); + } catch (InterruptedException success) { + threadAssertEquals(added, SIZE); + } + }}); t.start(); Thread.sleep(SHORT_DELAY_MS); @@ -820,24 +819,23 @@ public class LinkedBlockingDequeTest ext */ public void testPutFirstWithTake() throws InterruptedException { final LinkedBlockingDeque q = new LinkedBlockingDeque(2); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.putFirst(new Object()); - ++added; - q.putFirst(new Object()); - ++added; - q.putFirst(new Object()); - ++added; - q.putFirst(new Object()); - ++added; - threadShouldThrow(); - } catch (InterruptedException success) { - threadAssertTrue(added >= 2); - } + Thread t = new Thread(new CheckedRunnable() { + public void realRun() { + int added = 0; + try { + q.putFirst(new Object()); + ++added; + q.putFirst(new Object()); + ++added; + q.putFirst(new Object()); + ++added; + q.putFirst(new Object()); + ++added; + threadShouldThrow(); + } catch (InterruptedException success) { + threadAssertTrue(added >= 2); } - }); + }}); t.start(); Thread.sleep(SHORT_DELAY_MS); @@ -1001,21 +999,22 @@ public class LinkedBlockingDequeTest ext * putLast blocks interruptibly if full */ public void testBlockingPutLast() throws InterruptedException { - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); - for (int i = 0; i < SIZE; ++i) { - q.putLast(new Integer(i)); - ++added; - } - q.putLast(new Integer(SIZE)); - threadShouldThrow(); - } catch (InterruptedException success) { - threadAssertEquals(added, SIZE); + Thread t = new Thread(new CheckedRunnable() { + public void realRun() { + int added = 0; + try { + LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + for (int i = 0; i < SIZE; ++i) { + q.putLast(new Integer(i)); + ++added; } - }}); + q.putLast(new Integer(SIZE)); + threadShouldThrow(); + } catch (InterruptedException success) { + threadAssertEquals(added, SIZE); + } + }}); + t.start(); Thread.sleep(SHORT_DELAY_MS); t.interrupt(); @@ -1027,24 +1026,23 @@ public class LinkedBlockingDequeTest ext */ public void testPutLastWithTake() throws InterruptedException { final LinkedBlockingDeque q = new LinkedBlockingDeque(2); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.putLast(new Object()); - ++added; - q.putLast(new Object()); - ++added; - q.putLast(new Object()); - ++added; - q.putLast(new Object()); - ++added; - threadShouldThrow(); - } catch (InterruptedException success) { - threadAssertTrue(added >= 2); - } + Thread t = new Thread(new CheckedRunnable() { + public void realRun() { + int added = 0; + try { + q.putLast(new Object()); + ++added; + q.putLast(new Object()); + ++added; + q.putLast(new Object()); + ++added; + q.putLast(new Object()); + ++added; + threadShouldThrow(); + } catch (InterruptedException success) { + threadAssertTrue(added >= 2); } - }); + }}); t.start(); Thread.sleep(SHORT_DELAY_MS); @@ -1559,8 +1557,7 @@ public class LinkedBlockingDequeTest ext try { q.drainTo(q); shouldThrow(); - } catch (IllegalArgumentException success) { - } + } catch (IllegalArgumentException success) {} } /**