6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
< |
import junit.framework.*; |
10 |
< |
import java.util.Arrays; |
9 |
> |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
10 |
> |
|
11 |
|
import java.util.ArrayList; |
12 |
+ |
import java.util.Arrays; |
13 |
|
import java.util.Collection; |
14 |
|
import java.util.Iterator; |
15 |
|
import java.util.NoSuchElementException; |
18 |
|
import java.util.concurrent.Executors; |
19 |
|
import java.util.concurrent.ExecutorService; |
20 |
|
import java.util.concurrent.SynchronousQueue; |
21 |
< |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
21 |
> |
|
22 |
> |
import junit.framework.Test; |
23 |
|
|
24 |
|
public class SynchronousQueueTest extends JSR166TestCase { |
25 |
|
|
36 |
|
} |
37 |
|
|
38 |
|
public static void main(String[] args) { |
39 |
< |
junit.textui.TestRunner.run(suite()); |
39 |
> |
main(suite(), args); |
40 |
|
} |
41 |
|
|
42 |
|
public static Test suite() { |
423 |
|
public void testToArray_null(boolean fair) { |
424 |
|
final SynchronousQueue q = new SynchronousQueue(fair); |
425 |
|
try { |
426 |
< |
Object o[] = q.toArray(null); |
426 |
> |
Object[] o = q.toArray(null); |
427 |
|
shouldThrow(); |
428 |
|
} catch (NullPointerException success) {} |
429 |
|
} |
434 |
|
public void testIterator() { testIterator(false); } |
435 |
|
public void testIterator_fair() { testIterator(true); } |
436 |
|
public void testIterator(boolean fair) { |
437 |
< |
final SynchronousQueue q = new SynchronousQueue(fair); |
436 |
< |
Iterator it = q.iterator(); |
437 |
< |
assertFalse(it.hasNext()); |
438 |
< |
try { |
439 |
< |
Object x = it.next(); |
440 |
< |
shouldThrow(); |
441 |
< |
} catch (NoSuchElementException success) {} |
437 |
> |
assertIteratorExhausted(new SynchronousQueue(fair).iterator()); |
438 |
|
} |
439 |
|
|
440 |
|
/** |