9 |
|
import java.util.ArrayList; |
10 |
|
import java.util.Arrays; |
11 |
|
import java.util.Collection; |
12 |
– |
import java.util.Collections; |
12 |
|
import java.util.Iterator; |
13 |
|
import java.util.LinkedList; |
14 |
|
import java.util.List; |
26 |
|
} |
27 |
|
|
28 |
|
public static Test suite() { |
29 |
< |
return new TestSuite(CopyOnWriteArrayListTest.class); |
29 |
> |
class Implementation implements CollectionImplementation { |
30 |
> |
public Class<?> klazz() { return ArrayList.class; } |
31 |
> |
public List emptyCollection() { return new CopyOnWriteArrayList(); } |
32 |
> |
public Object makeElement(int i) { return i; } |
33 |
> |
public boolean isConcurrent() { return true; } |
34 |
> |
public boolean permitsNulls() { return true; } |
35 |
> |
} |
36 |
> |
class SubListImplementation extends Implementation { |
37 |
> |
public List emptyCollection() { |
38 |
> |
return super.emptyCollection().subList(0, 0); |
39 |
> |
} |
40 |
> |
} |
41 |
> |
return newTestSuite( |
42 |
> |
CopyOnWriteArrayListTest.class, |
43 |
> |
CollectionTest.testSuite(new Implementation()), |
44 |
> |
CollectionTest.testSuite(new SubListImplementation())); |
45 |
|
} |
46 |
|
|
47 |
|
static CopyOnWriteArrayList<Integer> populatedArray(int n) { |
278 |
|
Integer[] elements = new Integer[SIZE]; |
279 |
|
for (int i = 0; i < SIZE; i++) |
280 |
|
elements[i] = i; |
281 |
< |
Collections.shuffle(Arrays.asList(elements)); |
281 |
> |
shuffle(elements); |
282 |
|
Collection<Integer> full = populatedArray(elements); |
283 |
|
|
284 |
|
Iterator it = full.iterator(); |
446 |
|
Integer[] elements = new Integer[SIZE]; |
447 |
|
for (int i = 0; i < SIZE; i++) |
448 |
|
elements[i] = i; |
449 |
< |
Collections.shuffle(Arrays.asList(elements)); |
449 |
> |
shuffle(elements); |
450 |
|
Collection<Integer> full = populatedArray(elements); |
451 |
|
|
452 |
|
assertTrue(Arrays.equals(elements, full.toArray())); |
474 |
|
Integer[] elements = new Integer[SIZE]; |
475 |
|
for (int i = 0; i < SIZE; i++) |
476 |
|
elements[i] = i; |
477 |
< |
Collections.shuffle(Arrays.asList(elements)); |
477 |
> |
shuffle(elements); |
478 |
|
Collection<Integer> full = populatedArray(elements); |
479 |
|
|
480 |
|
Arrays.fill(a, 42); |