15 |
|
public class SynchronousQueueTest extends JSR166TestCase { |
16 |
|
|
17 |
|
public static void main(String[] args) { |
18 |
< |
junit.textui.TestRunner.run (suite()); |
18 |
> |
junit.textui.TestRunner.run(suite()); |
19 |
|
} |
20 |
|
|
21 |
|
public static Test suite() { |
119 |
|
shouldThrow(); |
120 |
|
} catch (NullPointerException success) {} |
121 |
|
} |
122 |
+ |
|
123 |
|
/** |
124 |
|
* addAll throws ISE if no active taker |
125 |
|
*/ |
175 |
|
++added; |
176 |
|
} |
177 |
|
} catch (InterruptedException success) { |
178 |
< |
assertTrue(added == 1); |
178 |
> |
assertEquals(1, added); |
179 |
|
} |
180 |
|
}}); |
181 |
|
|
252 |
|
++added; |
253 |
|
} |
254 |
|
} catch (InterruptedException success) { |
255 |
< |
assertTrue(added == 1); |
255 |
> |
assertEquals(1, added); |
256 |
|
} |
257 |
|
}}); |
258 |
|
|
347 |
|
final SynchronousQueue q = new SynchronousQueue(); |
348 |
|
Thread t = new Thread(new CheckedRunnable() { |
349 |
|
public void realRun() throws InterruptedException { |
349 |
– |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
350 |
– |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
350 |
|
try { |
351 |
+ |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
352 |
+ |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
353 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
354 |
|
shouldThrow(); |
355 |
|
} catch (InterruptedException success) {} |
387 |
|
final SynchronousQueue q = new SynchronousQueue(true); |
388 |
|
Thread t = new Thread(new CheckedRunnable() { |
389 |
|
public void realRun() throws InterruptedException { |
389 |
– |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
390 |
– |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
390 |
|
try { |
391 |
+ |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
392 |
+ |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
393 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
394 |
|
threadShouldThrow(); |
395 |
|
} catch (InterruptedException success) {} |
717 |
|
ArrayList l = new ArrayList(); |
718 |
|
Thread.sleep(SHORT_DELAY_MS); |
719 |
|
q.drainTo(l, 1); |
720 |
< |
assertTrue(l.size() == 1); |
720 |
> |
assertEquals(1, l.size()); |
721 |
|
q.drainTo(l, 1); |
722 |
< |
assertTrue(l.size() == 2); |
722 |
> |
assertEquals(2, l.size()); |
723 |
|
assertTrue(l.contains(one)); |
724 |
|
assertTrue(l.contains(two)); |
725 |
|
t1.join(); |