548 |
|
/** |
549 |
|
* put(null) throws NPE |
550 |
|
*/ |
551 |
< |
public void testPutNull() throws InterruptedException { |
551 |
> |
public void testPutNull() throws InterruptedException { |
552 |
|
try { |
553 |
|
LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); |
554 |
|
q.put(null); |
555 |
|
shouldThrow(); |
556 |
|
} catch (NullPointerException success) {} |
557 |
< |
} |
557 |
> |
} |
558 |
|
|
559 |
|
/** |
560 |
|
* all elements successfully put are contained |
561 |
|
*/ |
562 |
< |
public void testPut() throws InterruptedException { |
563 |
< |
LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); |
564 |
< |
for (int i = 0; i < SIZE; ++i) { |
565 |
< |
Integer I = new Integer(i); |
566 |
< |
q.put(I); |
567 |
< |
assertTrue(q.contains(I)); |
568 |
< |
} |
569 |
< |
assertEquals(0, q.remainingCapacity()); |
562 |
> |
public void testPut() throws InterruptedException { |
563 |
> |
LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); |
564 |
> |
for (int i = 0; i < SIZE; ++i) { |
565 |
> |
Integer I = new Integer(i); |
566 |
> |
q.put(I); |
567 |
> |
assertTrue(q.contains(I)); |
568 |
> |
} |
569 |
> |
assertEquals(0, q.remainingCapacity()); |
570 |
|
} |
571 |
|
|
572 |
|
/** |
600 |
|
*/ |
601 |
|
public void testPutWithTake() throws InterruptedException { |
602 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
603 |
< |
Thread t = new Thread(new Runnable() { |
604 |
< |
public void run() { |
605 |
< |
int added = 0; |
606 |
< |
try { |
607 |
< |
q.put(new Object()); |
608 |
< |
++added; |
609 |
< |
q.put(new Object()); |
610 |
< |
++added; |
611 |
< |
q.put(new Object()); |
612 |
< |
++added; |
613 |
< |
q.put(new Object()); |
614 |
< |
++added; |
615 |
< |
threadShouldThrow(); |
616 |
< |
} catch (InterruptedException success) { |
617 |
< |
threadAssertTrue(added >= 2); |
618 |
< |
} |
603 |
> |
Thread t = new Thread(new CheckedRunnable() { |
604 |
> |
public void realRun() { |
605 |
> |
int added = 0; |
606 |
> |
try { |
607 |
> |
q.put(new Object()); |
608 |
> |
++added; |
609 |
> |
q.put(new Object()); |
610 |
> |
++added; |
611 |
> |
q.put(new Object()); |
612 |
> |
++added; |
613 |
> |
q.put(new Object()); |
614 |
> |
++added; |
615 |
> |
threadShouldThrow(); |
616 |
> |
} catch (InterruptedException success) { |
617 |
> |
threadAssertTrue(added >= 2); |
618 |
|
} |
619 |
< |
}); |
619 |
> |
}}); |
620 |
|
|
621 |
|
t.start(); |
622 |
|
Thread.sleep(SHORT_DELAY_MS); |
1558 |
|
try { |
1559 |
|
q.drainTo(q); |
1560 |
|
shouldThrow(); |
1561 |
< |
} catch (IllegalArgumentException success) { |
1563 |
< |
} |
1561 |
> |
} catch (IllegalArgumentException success) {} |
1562 |
|
} |
1563 |
|
|
1564 |
|
/** |