32 |
|
} |
33 |
|
|
34 |
|
public static void main(String[] args) { |
35 |
< |
junit.textui.TestRunner.run(suite()); |
35 |
> |
main(suite(), args); |
36 |
|
} |
37 |
|
|
38 |
|
public static Test suite() { |
78 |
|
*/ |
79 |
|
public void testConstructor4() { |
80 |
|
Integer[] ints = new Integer[SIZE]; |
81 |
< |
for (int i = 0; i < SIZE-1; ++i) |
81 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
82 |
|
ints[i] = i; |
83 |
|
Collection<Integer> elements = Arrays.asList(ints); |
84 |
|
try { |
115 |
|
* remainingCapacity() always returns Integer.MAX_VALUE |
116 |
|
*/ |
117 |
|
public void testRemainingCapacity() { |
118 |
< |
LinkedTransferQueue<Integer> q = populatedQueue(SIZE); |
118 |
> |
BlockingQueue q = populatedQueue(SIZE); |
119 |
|
for (int i = 0; i < SIZE; ++i) { |
120 |
|
assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); |
121 |
|
assertEquals(SIZE - i, q.size()); |
122 |
< |
q.remove(); |
122 |
> |
assertEquals(i, q.remove()); |
123 |
|
} |
124 |
|
for (int i = 0; i < SIZE; ++i) { |
125 |
|
assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); |
126 |
|
assertEquals(i, q.size()); |
127 |
< |
q.add(i); |
127 |
> |
assertTrue(q.add(i)); |
128 |
|
} |
129 |
|
} |
130 |
|
|
132 |
|
* addAll(this) throws IllegalArgumentException |
133 |
|
*/ |
134 |
|
public void testAddAllSelf() { |
135 |
+ |
LinkedTransferQueue q = populatedQueue(SIZE); |
136 |
|
try { |
136 |
– |
LinkedTransferQueue q = populatedQueue(SIZE); |
137 |
|
q.addAll(q); |
138 |
|
shouldThrow(); |
139 |
|
} catch (IllegalArgumentException success) {} |
144 |
|
* NullPointerException after possibly adding some elements |
145 |
|
*/ |
146 |
|
public void testAddAll3() { |
147 |
+ |
LinkedTransferQueue q = new LinkedTransferQueue(); |
148 |
+ |
Integer[] ints = new Integer[SIZE]; |
149 |
+ |
for (int i = 0; i < SIZE - 1; ++i) |
150 |
+ |
ints[i] = i; |
151 |
|
try { |
148 |
– |
LinkedTransferQueue q = new LinkedTransferQueue(); |
149 |
– |
Integer[] ints = new Integer[SIZE]; |
150 |
– |
for (int i = 0; i < SIZE - 1; ++i) { |
151 |
– |
ints[i] = i; |
152 |
– |
} |
152 |
|
q.addAll(Arrays.asList(ints)); |
153 |
|
shouldThrow(); |
154 |
|
} catch (NullPointerException success) {} |
499 |
|
public void testIterator() throws InterruptedException { |
500 |
|
LinkedTransferQueue q = populatedQueue(SIZE); |
501 |
|
Iterator it = q.iterator(); |
502 |
< |
int i = 0; |
503 |
< |
while (it.hasNext()) { |
504 |
< |
assertEquals(it.next(), i++); |
506 |
< |
} |
502 |
> |
int i; |
503 |
> |
for (i = 0; it.hasNext(); i++) |
504 |
> |
assertTrue(q.contains(it.next())); |
505 |
|
assertEquals(i, SIZE); |
506 |
+ |
assertIteratorExhausted(it); |
507 |
+ |
|
508 |
+ |
it = q.iterator(); |
509 |
+ |
for (i = 0; it.hasNext(); i++) |
510 |
+ |
assertEquals(it.next(), q.take()); |
511 |
+ |
assertEquals(i, SIZE); |
512 |
+ |
assertIteratorExhausted(it); |
513 |
+ |
} |
514 |
+ |
|
515 |
+ |
/** |
516 |
+ |
* iterator of empty collection has no elements |
517 |
+ |
*/ |
518 |
+ |
public void testEmptyIterator() { |
519 |
+ |
assertIteratorExhausted(new LinkedTransferQueue().iterator()); |
520 |
|
} |
521 |
|
|
522 |
|
/** |
861 |
|
* tryTransfer(null) throws NullPointerException |
862 |
|
*/ |
863 |
|
public void testTryTransfer1() { |
864 |
+ |
final LinkedTransferQueue q = new LinkedTransferQueue(); |
865 |
|
try { |
853 |
– |
final LinkedTransferQueue q = new LinkedTransferQueue(); |
866 |
|
q.tryTransfer(null); |
867 |
|
shouldThrow(); |
868 |
|
} catch (NullPointerException success) {} |