106 |
|
} |
107 |
|
|
108 |
|
/** |
109 |
< |
* put(null) throws NullPointerException |
109 |
> |
* addAll(null) throws NullPointerException |
110 |
|
*/ |
111 |
|
public void testAddAllNull() throws InterruptedException { |
112 |
|
final Collection q = emptyCollection(); |
134 |
|
public void testToArray_NullArray() { |
135 |
|
final Collection q = emptyCollection(); |
136 |
|
try { |
137 |
< |
q.toArray(null); |
137 |
> |
q.toArray((Object[])null); |
138 |
|
shouldThrow(); |
139 |
|
} catch (NullPointerException success) {} |
140 |
|
} |
189 |
|
public void testDrainToNonPositiveMaxElements() { |
190 |
|
final BlockingQueue q = emptyCollection(); |
191 |
|
final int[] ns = { 0, -1, -42, Integer.MIN_VALUE }; |
192 |
< |
for (int n : ns) |
193 |
< |
assertEquals(0, q.drainTo(new ArrayList(), n)); |
192 |
> |
final ArrayList sink = new ArrayList(); |
193 |
> |
for (int n : ns) { |
194 |
> |
assertEquals(0, q.drainTo(sink, n)); |
195 |
> |
assertTrue(sink.isEmpty()); |
196 |
> |
} |
197 |
|
if (q.remainingCapacity() > 0) { |
198 |
|
// Not SynchronousQueue, that is |
199 |
|
Object one = makeElement(1); |
200 |
|
q.add(one); |
198 |
– |
ArrayList c = new ArrayList(); |
201 |
|
for (int n : ns) |
202 |
< |
assertEquals(0, q.drainTo(new ArrayList(), n)); |
202 |
> |
assertEquals(0, q.drainTo(sink, n)); |
203 |
|
assertEquals(1, q.size()); |
204 |
|
assertSame(one, q.poll()); |
205 |
< |
assertTrue(c.isEmpty()); |
205 |
> |
assertTrue(sink.isEmpty()); |
206 |
|
} |
207 |
|
} |
208 |
|
|