200 |
|
try { |
201 |
|
q.removeFirst(); |
202 |
|
shouldThrow(); |
203 |
< |
} catch (NoSuchElementException success){ |
203 |
> |
} catch (NoSuchElementException success) { |
204 |
|
} |
205 |
|
} |
206 |
|
|
215 |
|
try { |
216 |
|
q.remove(); |
217 |
|
shouldThrow(); |
218 |
< |
} catch (NoSuchElementException success){ |
218 |
> |
} catch (NoSuchElementException success) { |
219 |
|
} |
220 |
|
} |
221 |
|
|
420 |
|
} |
421 |
|
assertEquals(0, q.remainingCapacity()); |
422 |
|
q.push(new Integer(SIZE)); |
423 |
< |
} catch (IllegalStateException success){ |
423 |
> |
} catch (IllegalStateException success) { |
424 |
|
} |
425 |
|
} |
426 |
|
|
446 |
|
try { |
447 |
|
q.pop(); |
448 |
|
shouldThrow(); |
449 |
< |
} catch (NoSuchElementException success){ |
449 |
> |
} catch (NoSuchElementException success) { |
450 |
|
} |
451 |
|
} |
452 |
|
|
471 |
|
} |
472 |
|
assertEquals(0, q.remainingCapacity()); |
473 |
|
q.add(new Integer(SIZE)); |
474 |
< |
} catch (IllegalStateException success){ |
474 |
> |
} catch (IllegalStateException success) { |
475 |
|
} |
476 |
|
} |
477 |
|
|
568 |
|
q.put(null); |
569 |
|
shouldThrow(); |
570 |
|
} |
571 |
< |
catch (NullPointerException success){ |
571 |
> |
catch (NullPointerException success) { |
572 |
|
} |
573 |
|
catch (InterruptedException ie) { |
574 |
|
unexpectedException(); |
608 |
|
} |
609 |
|
q.put(new Integer(SIZE)); |
610 |
|
threadShouldThrow(); |
611 |
< |
} catch (InterruptedException ie){ |
611 |
> |
} catch (InterruptedException ie) { |
612 |
|
threadAssertEquals(added, SIZE); |
613 |
|
} |
614 |
|
}}); |
641 |
|
q.put(new Object()); |
642 |
|
++added; |
643 |
|
threadShouldThrow(); |
644 |
< |
} catch (InterruptedException e){ |
644 |
> |
} catch (InterruptedException e) { |
645 |
|
threadAssertTrue(added >= 2); |
646 |
|
} |
647 |
|
} |
652 |
|
q.take(); |
653 |
|
t.interrupt(); |
654 |
|
t.join(); |
655 |
< |
} catch (Exception e){ |
655 |
> |
} catch (Exception e) { |
656 |
|
unexpectedException(); |
657 |
|
} |
658 |
|
} |
670 |
|
threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
671 |
|
q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
672 |
|
threadShouldThrow(); |
673 |
< |
} catch (InterruptedException success){} |
673 |
> |
} catch (InterruptedException success) {} |
674 |
|
} |
675 |
|
}); |
676 |
|
|
679 |
|
Thread.sleep(SMALL_DELAY_MS); |
680 |
|
t.interrupt(); |
681 |
|
t.join(); |
682 |
< |
} catch (Exception e){ |
682 |
> |
} catch (Exception e) { |
683 |
|
unexpectedException(); |
684 |
|
} |
685 |
|
} |
693 |
|
for (int i = 0; i < SIZE; ++i) { |
694 |
|
assertEquals(i, ((Integer)q.take()).intValue()); |
695 |
|
} |
696 |
< |
} catch (InterruptedException e){ |
696 |
> |
} catch (InterruptedException e) { |
697 |
|
unexpectedException(); |
698 |
|
} |
699 |
|
} |
708 |
|
try { |
709 |
|
q.take(); |
710 |
|
threadShouldThrow(); |
711 |
< |
} catch (InterruptedException success){ } |
711 |
> |
} catch (InterruptedException success) { } |
712 |
|
} |
713 |
|
}); |
714 |
|
try { |
716 |
|
Thread.sleep(SHORT_DELAY_MS); |
717 |
|
t.interrupt(); |
718 |
|
t.join(); |
719 |
< |
} catch (Exception e){ |
719 |
> |
} catch (Exception e) { |
720 |
|
unexpectedException(); |
721 |
|
} |
722 |
|
} |
734 |
|
} |
735 |
|
q.take(); |
736 |
|
threadShouldThrow(); |
737 |
< |
} catch (InterruptedException success){ |
737 |
> |
} catch (InterruptedException success) { |
738 |
|
} |
739 |
|
}}); |
740 |
|
t.start(); |
770 |
|
assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); |
771 |
|
} |
772 |
|
assertNull(q.poll(0, TimeUnit.MILLISECONDS)); |
773 |
< |
} catch (InterruptedException e){ |
773 |
> |
} catch (InterruptedException e) { |
774 |
|
unexpectedException(); |
775 |
|
} |
776 |
|
} |
785 |
|
assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
786 |
|
} |
787 |
|
assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
788 |
< |
} catch (InterruptedException e){ |
788 |
> |
} catch (InterruptedException e) { |
789 |
|
unexpectedException(); |
790 |
|
} |
791 |
|
} |
803 |
|
threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
804 |
|
} |
805 |
|
threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
806 |
< |
} catch (InterruptedException success){ |
806 |
> |
} catch (InterruptedException success) { |
807 |
|
} |
808 |
|
}}); |
809 |
|
t.start(); |
839 |
|
assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
840 |
|
t.interrupt(); |
841 |
|
t.join(); |
842 |
< |
} catch (Exception e){ |
842 |
> |
} catch (Exception e) { |
843 |
|
unexpectedException(); |
844 |
|
} |
845 |
|
} |
854 |
|
q.putFirst(null); |
855 |
|
shouldThrow(); |
856 |
|
} |
857 |
< |
catch (NullPointerException success){ |
857 |
> |
catch (NullPointerException success) { |
858 |
|
} |
859 |
|
catch (InterruptedException ie) { |
860 |
|
unexpectedException(); |
894 |
|
} |
895 |
|
q.putFirst(new Integer(SIZE)); |
896 |
|
threadShouldThrow(); |
897 |
< |
} catch (InterruptedException ie){ |
897 |
> |
} catch (InterruptedException ie) { |
898 |
|
threadAssertEquals(added, SIZE); |
899 |
|
} |
900 |
|
}}); |
927 |
|
q.putFirst(new Object()); |
928 |
|
++added; |
929 |
|
threadShouldThrow(); |
930 |
< |
} catch (InterruptedException e){ |
930 |
> |
} catch (InterruptedException e) { |
931 |
|
threadAssertTrue(added >= 2); |
932 |
|
} |
933 |
|
} |
938 |
|
q.take(); |
939 |
|
t.interrupt(); |
940 |
|
t.join(); |
941 |
< |
} catch (Exception e){ |
941 |
> |
} catch (Exception e) { |
942 |
|
unexpectedException(); |
943 |
|
} |
944 |
|
} |
956 |
|
threadAssertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
957 |
|
q.offerFirst(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
958 |
|
threadShouldThrow(); |
959 |
< |
} catch (InterruptedException success){} |
959 |
> |
} catch (InterruptedException success) {} |
960 |
|
} |
961 |
|
}); |
962 |
|
|
965 |
|
Thread.sleep(SMALL_DELAY_MS); |
966 |
|
t.interrupt(); |
967 |
|
t.join(); |
968 |
< |
} catch (Exception e){ |
968 |
> |
} catch (Exception e) { |
969 |
|
unexpectedException(); |
970 |
|
} |
971 |
|
} |
979 |
|
for (int i = 0; i < SIZE; ++i) { |
980 |
|
assertEquals(i, ((Integer)q.takeFirst()).intValue()); |
981 |
|
} |
982 |
< |
} catch (InterruptedException e){ |
982 |
> |
} catch (InterruptedException e) { |
983 |
|
unexpectedException(); |
984 |
|
} |
985 |
|
} |
994 |
|
try { |
995 |
|
q.takeFirst(); |
996 |
|
threadShouldThrow(); |
997 |
< |
} catch (InterruptedException success){ } |
997 |
> |
} catch (InterruptedException success) { } |
998 |
|
} |
999 |
|
}); |
1000 |
|
try { |
1002 |
|
Thread.sleep(SHORT_DELAY_MS); |
1003 |
|
t.interrupt(); |
1004 |
|
t.join(); |
1005 |
< |
} catch (Exception e){ |
1005 |
> |
} catch (Exception e) { |
1006 |
|
unexpectedException(); |
1007 |
|
} |
1008 |
|
} |
1020 |
|
} |
1021 |
|
q.takeFirst(); |
1022 |
|
threadShouldThrow(); |
1023 |
< |
} catch (InterruptedException success){ |
1023 |
> |
} catch (InterruptedException success) { |
1024 |
|
} |
1025 |
|
}}); |
1026 |
|
t.start(); |
1045 |
|
assertEquals(i, ((Integer)q.pollFirst(0, TimeUnit.MILLISECONDS)).intValue()); |
1046 |
|
} |
1047 |
|
assertNull(q.pollFirst(0, TimeUnit.MILLISECONDS)); |
1048 |
< |
} catch (InterruptedException e){ |
1048 |
> |
} catch (InterruptedException e) { |
1049 |
|
unexpectedException(); |
1050 |
|
} |
1051 |
|
} |
1060 |
|
assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
1061 |
|
} |
1062 |
|
assertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
1063 |
< |
} catch (InterruptedException e){ |
1063 |
> |
} catch (InterruptedException e) { |
1064 |
|
unexpectedException(); |
1065 |
|
} |
1066 |
|
} |
1078 |
|
threadAssertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
1079 |
|
} |
1080 |
|
threadAssertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
1081 |
< |
} catch (InterruptedException success){ |
1081 |
> |
} catch (InterruptedException success) { |
1082 |
|
} |
1083 |
|
}}); |
1084 |
|
t.start(); |
1114 |
|
assertTrue(q.offerFirst(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
1115 |
|
t.interrupt(); |
1116 |
|
t.join(); |
1117 |
< |
} catch (Exception e){ |
1117 |
> |
} catch (Exception e) { |
1118 |
|
unexpectedException(); |
1119 |
|
} |
1120 |
|
} |
1128 |
|
q.putLast(null); |
1129 |
|
shouldThrow(); |
1130 |
|
} |
1131 |
< |
catch (NullPointerException success){ |
1131 |
> |
catch (NullPointerException success) { |
1132 |
|
} |
1133 |
|
catch (InterruptedException ie) { |
1134 |
|
unexpectedException(); |
1168 |
|
} |
1169 |
|
q.putLast(new Integer(SIZE)); |
1170 |
|
threadShouldThrow(); |
1171 |
< |
} catch (InterruptedException ie){ |
1171 |
> |
} catch (InterruptedException ie) { |
1172 |
|
threadAssertEquals(added, SIZE); |
1173 |
|
} |
1174 |
|
}}); |
1201 |
|
q.putLast(new Object()); |
1202 |
|
++added; |
1203 |
|
threadShouldThrow(); |
1204 |
< |
} catch (InterruptedException e){ |
1204 |
> |
} catch (InterruptedException e) { |
1205 |
|
threadAssertTrue(added >= 2); |
1206 |
|
} |
1207 |
|
} |
1212 |
|
q.take(); |
1213 |
|
t.interrupt(); |
1214 |
|
t.join(); |
1215 |
< |
} catch (Exception e){ |
1215 |
> |
} catch (Exception e) { |
1216 |
|
unexpectedException(); |
1217 |
|
} |
1218 |
|
} |
1230 |
|
threadAssertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
1231 |
|
q.offerLast(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
1232 |
|
threadShouldThrow(); |
1233 |
< |
} catch (InterruptedException success){} |
1233 |
> |
} catch (InterruptedException success) {} |
1234 |
|
} |
1235 |
|
}); |
1236 |
|
|
1239 |
|
Thread.sleep(SMALL_DELAY_MS); |
1240 |
|
t.interrupt(); |
1241 |
|
t.join(); |
1242 |
< |
} catch (Exception e){ |
1242 |
> |
} catch (Exception e) { |
1243 |
|
unexpectedException(); |
1244 |
|
} |
1245 |
|
} |
1253 |
|
for (int i = 0; i < SIZE; ++i) { |
1254 |
|
assertEquals(SIZE-i-1, ((Integer)q.takeLast()).intValue()); |
1255 |
|
} |
1256 |
< |
} catch (InterruptedException e){ |
1256 |
> |
} catch (InterruptedException e) { |
1257 |
|
unexpectedException(); |
1258 |
|
} |
1259 |
|
} |
1268 |
|
try { |
1269 |
|
q.takeLast(); |
1270 |
|
threadShouldThrow(); |
1271 |
< |
} catch (InterruptedException success){ } |
1271 |
> |
} catch (InterruptedException success) { } |
1272 |
|
} |
1273 |
|
}); |
1274 |
|
try { |
1276 |
|
Thread.sleep(SHORT_DELAY_MS); |
1277 |
|
t.interrupt(); |
1278 |
|
t.join(); |
1279 |
< |
} catch (Exception e){ |
1279 |
> |
} catch (Exception e) { |
1280 |
|
unexpectedException(); |
1281 |
|
} |
1282 |
|
} |
1294 |
|
} |
1295 |
|
q.takeLast(); |
1296 |
|
threadShouldThrow(); |
1297 |
< |
} catch (InterruptedException success){ |
1297 |
> |
} catch (InterruptedException success) { |
1298 |
|
} |
1299 |
|
}}); |
1300 |
|
t.start(); |
1319 |
|
assertEquals(SIZE-i-1, ((Integer)q.pollLast(0, TimeUnit.MILLISECONDS)).intValue()); |
1320 |
|
} |
1321 |
|
assertNull(q.pollLast(0, TimeUnit.MILLISECONDS)); |
1322 |
< |
} catch (InterruptedException e){ |
1322 |
> |
} catch (InterruptedException e) { |
1323 |
|
unexpectedException(); |
1324 |
|
} |
1325 |
|
} |
1334 |
|
assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
1335 |
|
} |
1336 |
|
assertNull(q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
1337 |
< |
} catch (InterruptedException e){ |
1337 |
> |
} catch (InterruptedException e) { |
1338 |
|
unexpectedException(); |
1339 |
|
} |
1340 |
|
} |
1352 |
|
threadAssertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
1353 |
|
} |
1354 |
|
threadAssertNull(q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
1355 |
< |
} catch (InterruptedException success){ |
1355 |
> |
} catch (InterruptedException success) { |
1356 |
|
} |
1357 |
|
}}); |
1358 |
|
t.start(); |
1388 |
|
assertTrue(q.offerLast(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
1389 |
|
t.interrupt(); |
1390 |
|
t.join(); |
1391 |
< |
} catch (Exception e){ |
1391 |
> |
} catch (Exception e) { |
1392 |
|
unexpectedException(); |
1393 |
|
} |
1394 |
|
} |
1511 |
|
try { |
1512 |
|
for (int i = 0; i < o.length; i++) |
1513 |
|
assertEquals(o[i], q.take()); |
1514 |
< |
} catch (InterruptedException e){ |
1514 |
> |
} catch (InterruptedException e) { |
1515 |
|
unexpectedException(); |
1516 |
|
} |
1517 |
|
} |
1526 |
|
try { |
1527 |
|
for (int i = 0; i < ints.length; i++) |
1528 |
|
assertEquals(ints[i], q.take()); |
1529 |
< |
} catch (InterruptedException e){ |
1529 |
> |
} catch (InterruptedException e) { |
1530 |
|
unexpectedException(); |
1531 |
|
} |
1532 |
|
} |
1539 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1540 |
|
Object o[] = q.toArray(null); |
1541 |
|
shouldThrow(); |
1542 |
< |
} catch (NullPointerException success){} |
1542 |
> |
} catch (NullPointerException success) {} |
1543 |
|
} |
1544 |
|
|
1545 |
|
/** |
1550 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1551 |
|
Object o[] = q.toArray(new String[10] ); |
1552 |
|
shouldThrow(); |
1553 |
< |
} catch (ArrayStoreException success){} |
1553 |
> |
} catch (ArrayStoreException success) {} |
1554 |
|
} |
1555 |
|
|
1556 |
|
|
1561 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1562 |
|
Iterator it = q.iterator(); |
1563 |
|
try { |
1564 |
< |
while (it.hasNext()){ |
1564 |
> |
while (it.hasNext()) { |
1565 |
|
assertEquals(it.next(), q.take()); |
1566 |
|
} |
1567 |
< |
} catch (InterruptedException e){ |
1567 |
> |
} catch (InterruptedException e) { |
1568 |
|
unexpectedException(); |
1569 |
|
} |
1570 |
|
} |
1791 |
|
assertEquals(q.size(), r.size()); |
1792 |
|
while (!q.isEmpty()) |
1793 |
|
assertEquals(q.remove(), r.remove()); |
1794 |
< |
} catch (Exception e){ |
1794 |
> |
} catch (Exception e) { |
1795 |
|
unexpectedException(); |
1796 |
|
} |
1797 |
|
} |
1853 |
|
public void run() { |
1854 |
|
try { |
1855 |
|
q.put(new Integer(SIZE+1)); |
1856 |
< |
} catch (InterruptedException ie){ |
1856 |
> |
} catch (InterruptedException ie) { |
1857 |
|
threadUnexpectedException(); |
1858 |
|
} |
1859 |
|
} |
1867 |
|
assertEquals(l.get(i), new Integer(i)); |
1868 |
|
t.join(); |
1869 |
|
assertTrue(q.size() + l.size() >= SIZE); |
1870 |
< |
} catch (Exception e){ |
1870 |
> |
} catch (Exception e) { |
1871 |
|
unexpectedException(); |
1872 |
|
} |
1873 |
|
} |