540 |
|
shouldThrow(); |
541 |
|
} catch (IllegalStateException success) {} |
542 |
|
} |
543 |
+ |
|
544 |
|
/** |
545 |
|
* Deque contains all elements, in traversal order, of successful addAll |
546 |
|
*/ |
642 |
|
*/ |
643 |
|
public void testTimedOffer() throws InterruptedException { |
644 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
645 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
645 |
> |
Thread t = new Thread(new CheckedRunnable() { |
646 |
|
public void realRun() throws InterruptedException { |
647 |
|
q.put(new Object()); |
648 |
|
q.put(new Object()); |
649 |
< |
threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
650 |
< |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
651 |
< |
}}; |
649 |
> |
assertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
650 |
> |
try { |
651 |
> |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
652 |
> |
shouldThrow(); |
653 |
> |
} catch (InterruptedException success) {} |
654 |
> |
}}); |
655 |
|
|
656 |
|
t.start(); |
657 |
|
Thread.sleep(SMALL_DELAY_MS); |
870 |
|
*/ |
871 |
|
public void testTimedOfferFirst() throws InterruptedException { |
872 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
873 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
873 |
> |
Thread t = new Thread(new CheckedRunnable() { |
874 |
|
public void realRun() throws InterruptedException { |
875 |
|
q.putFirst(new Object()); |
876 |
|
q.putFirst(new Object()); |
877 |
< |
threadAssertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
878 |
< |
q.offerFirst(new Object(), LONG_DELAY_MS, MILLISECONDS); |
879 |
< |
}}; |
877 |
> |
assertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
878 |
> |
try { |
879 |
> |
q.offerFirst(new Object(), LONG_DELAY_MS, MILLISECONDS); |
880 |
> |
shouldThrow(); |
881 |
> |
} catch (InterruptedException success) {} |
882 |
> |
}}); |
883 |
|
|
884 |
|
t.start(); |
885 |
|
Thread.sleep(SMALL_DELAY_MS); |
1086 |
|
*/ |
1087 |
|
public void testTimedOfferLast() throws InterruptedException { |
1088 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
1089 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
1089 |
> |
Thread t = new Thread(new CheckedRunnable() { |
1090 |
|
public void realRun() throws InterruptedException { |
1091 |
|
q.putLast(new Object()); |
1092 |
|
q.putLast(new Object()); |
1093 |
< |
threadAssertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
1094 |
< |
q.offerLast(new Object(), LONG_DELAY_MS, MILLISECONDS); |
1095 |
< |
}}; |
1093 |
> |
assertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
1094 |
> |
try { |
1095 |
> |
q.offerLast(new Object(), LONG_DELAY_MS, MILLISECONDS); |
1096 |
> |
shouldThrow(); |
1097 |
> |
} catch (InterruptedException success) {} |
1098 |
> |
}}); |
1099 |
|
|
1100 |
|
t.start(); |
1101 |
|
Thread.sleep(SMALL_DELAY_MS); |