166 |
|
}}); |
167 |
|
|
168 |
|
await(pleaseTake); |
169 |
< |
assertEquals(q.remainingCapacity(), 0); |
169 |
> |
assertEquals(0, q.remainingCapacity()); |
170 |
|
try { assertSame(one, q.take()); } |
171 |
|
catch (InterruptedException e) { threadUnexpectedException(e); } |
172 |
|
|
174 |
|
assertThreadStaysAlive(t); |
175 |
|
t.interrupt(); |
176 |
|
awaitTermination(t); |
177 |
< |
assertEquals(q.remainingCapacity(), 0); |
177 |
> |
assertEquals(0, q.remainingCapacity()); |
178 |
|
} |
179 |
|
|
180 |
|
/** |
389 |
|
public void testToArray(boolean fair) { |
390 |
|
final SynchronousQueue q = new SynchronousQueue(fair); |
391 |
|
Object[] o = q.toArray(); |
392 |
< |
assertEquals(o.length, 0); |
392 |
> |
assertEquals(0, o.length); |
393 |
|
} |
394 |
|
|
395 |
|
/** |
396 |
< |
* toArray(a) is nulled at position 0 |
396 |
> |
* toArray(Integer array) returns its argument with the first |
397 |
> |
* element (if present) nulled out |
398 |
|
*/ |
399 |
|
public void testToArray2() { testToArray2(false); } |
400 |
|
public void testToArray2_fair() { testToArray2(true); } |
401 |
|
public void testToArray2(boolean fair) { |
402 |
< |
final SynchronousQueue q = new SynchronousQueue(fair); |
403 |
< |
Integer[] ints = new Integer[1]; |
404 |
< |
assertNull(ints[0]); |
402 |
> |
final SynchronousQueue<Integer> q |
403 |
> |
= new SynchronousQueue<Integer>(fair); |
404 |
> |
Integer[] a; |
405 |
> |
|
406 |
> |
a = new Integer[0]; |
407 |
> |
assertSame(a, q.toArray(a)); |
408 |
> |
|
409 |
> |
a = new Integer[3]; |
410 |
> |
Arrays.fill(a, 42); |
411 |
> |
assertSame(a, q.toArray(a)); |
412 |
> |
assertNull(a[0]); |
413 |
> |
for (int i = 1; i < a.length; i++) |
414 |
> |
assertEquals(42, (int) a[i]); |
415 |
|
} |
416 |
|
|
417 |
|
/** |
523 |
|
/** |
524 |
|
* a deserialized serialized queue is usable |
525 |
|
*/ |
526 |
< |
public void testSerialization() { testSerialization(false); } |
527 |
< |
public void testSerialization_fair() { testSerialization(true); } |
528 |
< |
public void testSerialization(boolean fair) { |
529 |
< |
final SynchronousQueue x = new SynchronousQueue(fair); |
530 |
< |
final SynchronousQueue y = serialClone(x); |
531 |
< |
assertTrue(x != y); |
532 |
< |
assertTrue(x.isEmpty()); |
533 |
< |
assertTrue(y.isEmpty()); |
526 |
> |
public void testSerialization() { |
527 |
> |
final SynchronousQueue x = new SynchronousQueue(); |
528 |
> |
final SynchronousQueue y = new SynchronousQueue(false); |
529 |
> |
final SynchronousQueue z = new SynchronousQueue(true); |
530 |
> |
assertSerialEquals(x, y); |
531 |
> |
assertNotSerialEquals(x, z); |
532 |
> |
SynchronousQueue[] qs = { x, y, z }; |
533 |
> |
for (SynchronousQueue q : qs) { |
534 |
> |
SynchronousQueue clone = serialClone(q); |
535 |
> |
assert(q != clone); |
536 |
> |
assertSerialEquals(q, clone); |
537 |
> |
assertTrue(clone.isEmpty()); |
538 |
> |
assertEquals(0, clone.size()); |
539 |
> |
assertEquals(0, clone.remainingCapacity()); |
540 |
> |
assertFalse(clone.offer(zero)); |
541 |
> |
} |
542 |
|
} |
543 |
|
|
544 |
|
/** |
550 |
|
final SynchronousQueue q = new SynchronousQueue(fair); |
551 |
|
ArrayList l = new ArrayList(); |
552 |
|
q.drainTo(l); |
553 |
< |
assertEquals(q.size(), 0); |
554 |
< |
assertEquals(l.size(), 0); |
553 |
> |
assertEquals(0, q.size()); |
554 |
> |
assertEquals(0, l.size()); |
555 |
|
} |
556 |
|
|
557 |
|
/** |