15 |
|
|
16 |
|
public class ArrayBlockingQueueTest extends JSR166TestCase { |
17 |
|
public static void main(String[] args) { |
18 |
< |
junit.textui.TestRunner.run (suite()); |
18 |
> |
junit.textui.TestRunner.run(suite()); |
19 |
|
} |
20 |
|
public static Test suite() { |
21 |
|
return new TestSuite(ArrayBlockingQueueTest.class); |
224 |
|
shouldThrow(); |
225 |
|
} catch (NullPointerException success) {} |
226 |
|
} |
227 |
+ |
|
228 |
|
/** |
229 |
|
* addAll of a collection with any null elements throws NPE after |
230 |
|
* possibly adding some elements |
239 |
|
shouldThrow(); |
240 |
|
} catch (NullPointerException success) {} |
241 |
|
} |
242 |
+ |
|
243 |
|
/** |
244 |
|
* addAll throws ISE if not enough room |
245 |
|
*/ |
253 |
|
shouldThrow(); |
254 |
|
} catch (IllegalStateException success) {} |
255 |
|
} |
256 |
+ |
|
257 |
|
/** |
258 |
|
* Queue contains all elements, in traversal order, of successful addAll |
259 |
|
*/ |
479 |
|
final ArrayBlockingQueue q = new ArrayBlockingQueue(2); |
480 |
|
Thread t = new Thread(new CheckedRunnable() { |
481 |
|
public void realRun() throws InterruptedException { |
479 |
– |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
480 |
– |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
482 |
|
try { |
483 |
+ |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
484 |
+ |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
485 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
486 |
|
shouldThrow(); |
487 |
|
} catch (InterruptedException success) {} |
688 |
|
/** |
689 |
|
* iterator.remove removes current element |
690 |
|
*/ |
691 |
< |
public void testIteratorRemove () { |
691 |
> |
public void testIteratorRemove() { |
692 |
|
final ArrayBlockingQueue q = new ArrayBlockingQueue(3); |
693 |
|
q.add(two); |
694 |
|
q.add(one); |
699 |
|
it.remove(); |
700 |
|
|
701 |
|
it = q.iterator(); |
702 |
< |
assertEquals(it.next(), one); |
703 |
< |
assertEquals(it.next(), three); |
702 |
> |
assertSame(it.next(), one); |
703 |
> |
assertSame(it.next(), three); |
704 |
|
assertFalse(it.hasNext()); |
705 |
|
} |
706 |
|
|
725 |
|
/** |
726 |
|
* Modifications do not cause iterators to fail |
727 |
|
*/ |
728 |
< |
public void testWeaklyConsistentIteration () { |
728 |
> |
public void testWeaklyConsistentIteration() { |
729 |
|
final ArrayBlockingQueue q = new ArrayBlockingQueue(3); |
730 |
|
q.add(one); |
731 |
|
q.add(two); |
772 |
|
}}); |
773 |
|
|
774 |
|
joinPool(executor); |
772 |
– |
|
775 |
|
} |
776 |
|
|
777 |
|
/** |