8 |
|
import java.util.Arrays; |
9 |
|
import java.util.ArrayList; |
10 |
|
import java.util.Collection; |
11 |
+ |
import java.util.Deque; |
12 |
|
import java.util.Iterator; |
13 |
|
import java.util.NoSuchElementException; |
14 |
|
import java.util.Queue; |
45 |
|
} |
46 |
|
|
47 |
|
/** |
48 |
< |
* Create a deque of given size containing consecutive |
48 |
> |
* Returns a new deque of given size containing consecutive |
49 |
|
* Integers 0 ... n. |
50 |
|
*/ |
51 |
|
private LinkedBlockingDeque<Integer> populatedDeque(int n) { |
1065 |
|
|
1066 |
|
pleaseInterrupt.countDown(); |
1067 |
|
try { |
1068 |
< |
q.pollFirst(SMALL_DELAY_MS, MILLISECONDS); |
1068 |
> |
q.pollFirst(LONG_DELAY_MS, MILLISECONDS); |
1069 |
|
shouldThrow(); |
1070 |
|
} catch (InterruptedException success) {} |
1071 |
|
assertFalse(Thread.interrupted()); |
1701 |
|
Queue x = populatedDeque(SIZE); |
1702 |
|
Queue y = serialClone(x); |
1703 |
|
|
1704 |
< |
assertTrue(x != y); |
1704 |
> |
assertNotSame(y, x); |
1705 |
|
assertEquals(x.size(), y.size()); |
1706 |
|
assertEquals(x.toString(), y.toString()); |
1707 |
|
assertTrue(Arrays.equals(x.toArray(), y.toArray())); |
1775 |
|
} |
1776 |
|
} |
1777 |
|
|
1778 |
+ |
/** |
1779 |
+ |
* remove(null), contains(null) always return false |
1780 |
+ |
*/ |
1781 |
+ |
public void testNeverContainsNull() { |
1782 |
+ |
Deque<?>[] qs = { |
1783 |
+ |
new LinkedBlockingDeque<Object>(), |
1784 |
+ |
populatedDeque(2), |
1785 |
+ |
}; |
1786 |
+ |
|
1787 |
+ |
for (Deque<?> q : qs) { |
1788 |
+ |
assertFalse(q.contains(null)); |
1789 |
+ |
assertFalse(q.remove(null)); |
1790 |
+ |
assertFalse(q.removeFirstOccurrence(null)); |
1791 |
+ |
assertFalse(q.removeLastOccurrence(null)); |
1792 |
+ |
} |
1793 |
+ |
} |
1794 |
+ |
|
1795 |
|
} |