30 |
|
|
31 |
|
public static class Bounded extends BlockingQueueTest { |
32 |
|
protected BlockingQueue emptyCollection() { |
33 |
< |
return new LinkedBlockingQueue(20); |
33 |
> |
return new LinkedBlockingQueue(SIZE); |
34 |
|
} |
35 |
|
} |
36 |
|
|
504 |
|
} |
505 |
|
|
506 |
|
/** |
507 |
– |
* remove(x) removes x and returns true if present |
508 |
– |
*/ |
509 |
– |
public void testRemoveElement() { |
510 |
– |
LinkedBlockingQueue q = populatedQueue(SIZE); |
511 |
– |
for (int i = 1; i < SIZE; i+=2) { |
512 |
– |
assertTrue(q.contains(i)); |
513 |
– |
assertTrue(q.remove(i)); |
514 |
– |
assertFalse(q.contains(i)); |
515 |
– |
assertTrue(q.contains(i-1)); |
516 |
– |
} |
517 |
– |
for (int i = 0; i < SIZE; i+=2) { |
518 |
– |
assertTrue(q.contains(i)); |
519 |
– |
assertTrue(q.remove(i)); |
520 |
– |
assertFalse(q.contains(i)); |
521 |
– |
assertFalse(q.remove(i+1)); |
522 |
– |
assertFalse(q.contains(i+1)); |
523 |
– |
} |
524 |
– |
assertTrue(q.isEmpty()); |
525 |
– |
} |
526 |
– |
|
527 |
– |
/** |
507 |
|
* An add following remove(x) succeeds |
508 |
|
*/ |
509 |
|
public void testRemoveElementAndAdd() throws InterruptedException { |