183 |
|
} |
184 |
|
assertEquals(0, q.remainingCapacity()); |
185 |
|
q.add(new Integer(SIZE)); |
186 |
< |
} catch (IllegalStateException success){ |
186 |
> |
} catch (IllegalStateException success) { |
187 |
|
} |
188 |
|
} |
189 |
|
|
279 |
|
q.put(null); |
280 |
|
shouldThrow(); |
281 |
|
} |
282 |
< |
catch (NullPointerException success){ |
282 |
> |
catch (NullPointerException success) { |
283 |
|
} |
284 |
|
catch (InterruptedException ie) { |
285 |
|
unexpectedException(); |
319 |
|
} |
320 |
|
q.put(new Integer(SIZE)); |
321 |
|
threadShouldThrow(); |
322 |
< |
} catch (InterruptedException ie){ |
322 |
> |
} catch (InterruptedException ie) { |
323 |
|
threadAssertEquals(added, SIZE); |
324 |
|
} |
325 |
|
}}); |
352 |
|
q.put(new Object()); |
353 |
|
++added; |
354 |
|
threadShouldThrow(); |
355 |
< |
} catch (InterruptedException e){ |
355 |
> |
} catch (InterruptedException e) { |
356 |
|
threadAssertTrue(added >= 2); |
357 |
|
} |
358 |
|
} |
363 |
|
q.take(); |
364 |
|
t.interrupt(); |
365 |
|
t.join(); |
366 |
< |
} catch (Exception e){ |
366 |
> |
} catch (Exception e) { |
367 |
|
unexpectedException(); |
368 |
|
} |
369 |
|
} |
381 |
|
threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
382 |
|
q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
383 |
|
threadShouldThrow(); |
384 |
< |
} catch (InterruptedException success){} |
384 |
> |
} catch (InterruptedException success) {} |
385 |
|
} |
386 |
|
}); |
387 |
|
|
390 |
|
Thread.sleep(SMALL_DELAY_MS); |
391 |
|
t.interrupt(); |
392 |
|
t.join(); |
393 |
< |
} catch (Exception e){ |
393 |
> |
} catch (Exception e) { |
394 |
|
unexpectedException(); |
395 |
|
} |
396 |
|
} |
404 |
|
for (int i = 0; i < SIZE; ++i) { |
405 |
|
assertEquals(i, ((Integer)q.take()).intValue()); |
406 |
|
} |
407 |
< |
} catch (InterruptedException e){ |
407 |
> |
} catch (InterruptedException e) { |
408 |
|
unexpectedException(); |
409 |
|
} |
410 |
|
} |
419 |
|
try { |
420 |
|
q.take(); |
421 |
|
threadShouldThrow(); |
422 |
< |
} catch (InterruptedException success){ } |
422 |
> |
} catch (InterruptedException success) { } |
423 |
|
} |
424 |
|
}); |
425 |
|
try { |
427 |
|
Thread.sleep(SHORT_DELAY_MS); |
428 |
|
t.interrupt(); |
429 |
|
t.join(); |
430 |
< |
} catch (Exception e){ |
430 |
> |
} catch (Exception e) { |
431 |
|
unexpectedException(); |
432 |
|
} |
433 |
|
} |
445 |
|
} |
446 |
|
q.take(); |
447 |
|
threadShouldThrow(); |
448 |
< |
} catch (InterruptedException success){ |
448 |
> |
} catch (InterruptedException success) { |
449 |
|
} |
450 |
|
}}); |
451 |
|
t.start(); |
481 |
|
assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); |
482 |
|
} |
483 |
|
assertNull(q.poll(0, TimeUnit.MILLISECONDS)); |
484 |
< |
} catch (InterruptedException e){ |
484 |
> |
} catch (InterruptedException e) { |
485 |
|
unexpectedException(); |
486 |
|
} |
487 |
|
} |
496 |
|
assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
497 |
|
} |
498 |
|
assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
499 |
< |
} catch (InterruptedException e){ |
499 |
> |
} catch (InterruptedException e) { |
500 |
|
unexpectedException(); |
501 |
|
} |
502 |
|
} |
514 |
|
threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
515 |
|
} |
516 |
|
threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
517 |
< |
} catch (InterruptedException success){ |
517 |
> |
} catch (InterruptedException success) { |
518 |
|
} |
519 |
|
}}); |
520 |
|
t.start(); |
550 |
|
assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
551 |
|
t.interrupt(); |
552 |
|
t.join(); |
553 |
< |
} catch (Exception e){ |
553 |
> |
} catch (Exception e) { |
554 |
|
unexpectedException(); |
555 |
|
} |
556 |
|
} |
596 |
|
try { |
597 |
|
q.remove(); |
598 |
|
shouldThrow(); |
599 |
< |
} catch (NoSuchElementException success){ |
599 |
> |
} catch (NoSuchElementException success) { |
600 |
|
} |
601 |
|
} |
602 |
|
|
627 |
|
assertTrue(q.remove(new Integer(2))); |
628 |
|
assertTrue(q.add(new Integer(3))); |
629 |
|
assertTrue(q.take() != null); |
630 |
< |
} catch (Exception e){ |
630 |
> |
} catch (Exception e) { |
631 |
|
unexpectedException(); |
632 |
|
} |
633 |
|
} |
718 |
|
try { |
719 |
|
for (int i = 0; i < o.length; i++) |
720 |
|
assertEquals(o[i], q.take()); |
721 |
< |
} catch (InterruptedException e){ |
721 |
> |
} catch (InterruptedException e) { |
722 |
|
unexpectedException(); |
723 |
|
} |
724 |
|
} |
733 |
|
try { |
734 |
|
for (int i = 0; i < ints.length; i++) |
735 |
|
assertEquals(ints[i], q.take()); |
736 |
< |
} catch (InterruptedException e){ |
736 |
> |
} catch (InterruptedException e) { |
737 |
|
unexpectedException(); |
738 |
|
} |
739 |
|
} |
746 |
|
LinkedBlockingQueue q = populatedQueue(SIZE); |
747 |
|
Object o[] = q.toArray(null); |
748 |
|
shouldThrow(); |
749 |
< |
} catch (NullPointerException success){} |
749 |
> |
} catch (NullPointerException success) {} |
750 |
|
} |
751 |
|
|
752 |
|
/** |
757 |
|
LinkedBlockingQueue q = populatedQueue(SIZE); |
758 |
|
Object o[] = q.toArray(new String[10] ); |
759 |
|
shouldThrow(); |
760 |
< |
} catch (ArrayStoreException success){} |
760 |
> |
} catch (ArrayStoreException success) {} |
761 |
|
} |
762 |
|
|
763 |
|
|
768 |
|
LinkedBlockingQueue q = populatedQueue(SIZE); |
769 |
|
Iterator it = q.iterator(); |
770 |
|
try { |
771 |
< |
while (it.hasNext()){ |
771 |
> |
while (it.hasNext()) { |
772 |
|
assertEquals(it.next(), q.take()); |
773 |
|
} |
774 |
< |
} catch (InterruptedException e){ |
774 |
> |
} catch (InterruptedException e) { |
775 |
|
unexpectedException(); |
776 |
|
} |
777 |
|
} |
934 |
|
assertEquals(q.size(), r.size()); |
935 |
|
while (!q.isEmpty()) |
936 |
|
assertEquals(q.remove(), r.remove()); |
937 |
< |
} catch (Exception e){ |
937 |
> |
} catch (Exception e) { |
938 |
|
unexpectedException(); |
939 |
|
} |
940 |
|
} |
996 |
|
public void run() { |
997 |
|
try { |
998 |
|
q.put(new Integer(SIZE+1)); |
999 |
< |
} catch (InterruptedException ie){ |
999 |
> |
} catch (InterruptedException ie) { |
1000 |
|
threadUnexpectedException(); |
1001 |
|
} |
1002 |
|
} |
1010 |
|
assertEquals(l.get(i), new Integer(i)); |
1011 |
|
t.join(); |
1012 |
|
assertTrue(q.size() + l.size() >= SIZE); |
1013 |
< |
} catch (Exception e){ |
1013 |
> |
} catch (Exception e) { |
1014 |
|
unexpectedException(); |
1015 |
|
} |
1016 |
|
} |