159 |
|
* remainingCapacity decreases on add, increases on remove |
160 |
|
*/ |
161 |
|
public void testRemainingCapacity() { |
162 |
< |
ArrayBlockingQueue q = populatedQueue(SIZE); |
162 |
> |
BlockingQueue q = populatedQueue(SIZE); |
163 |
|
for (int i = 0; i < SIZE; ++i) { |
164 |
|
assertEquals(i, q.remainingCapacity()); |
165 |
< |
assertEquals(SIZE-i, q.size()); |
166 |
< |
q.remove(); |
165 |
> |
assertEquals(SIZE, q.size() + q.remainingCapacity()); |
166 |
> |
assertEquals(i, q.remove()); |
167 |
|
} |
168 |
|
for (int i = 0; i < SIZE; ++i) { |
169 |
|
assertEquals(SIZE-i, q.remainingCapacity()); |
170 |
< |
assertEquals(i, q.size()); |
171 |
< |
q.add(new Integer(i)); |
170 |
> |
assertEquals(SIZE, q.size() + q.remainingCapacity()); |
171 |
> |
assertTrue(q.add(i)); |
172 |
|
} |
173 |
|
} |
174 |
|
|