18 |
|
import java.util.concurrent.ConcurrentSkipListMap; |
19 |
|
|
20 |
|
import junit.framework.Test; |
21 |
– |
import junit.framework.TestSuite; |
21 |
|
|
22 |
|
public class ConcurrentSkipListMapTest extends JSR166TestCase { |
23 |
|
public static void main(String[] args) { |
24 |
|
main(suite(), args); |
25 |
|
} |
26 |
|
public static Test suite() { |
27 |
< |
return new TestSuite(ConcurrentSkipListMapTest.class); |
27 |
> |
class Implementation implements MapImplementation { |
28 |
> |
public Class<?> klazz() { return ConcurrentSkipListMap.class; } |
29 |
> |
public Map emptyMap() { return new ConcurrentSkipListMap(); } |
30 |
> |
public boolean isConcurrent() { return true; } |
31 |
> |
public boolean remappingFunctionCalledAtMostOnce() { return false; }; |
32 |
> |
public boolean permitsNullKeys() { return false; } |
33 |
> |
public boolean permitsNullValues() { return false; } |
34 |
> |
public boolean supportsSetValue() { return false; } |
35 |
> |
} |
36 |
> |
return newTestSuite( |
37 |
> |
ConcurrentSkipListMapTest.class, |
38 |
> |
MapTest.testSuite(new Implementation())); |
39 |
|
} |
40 |
|
|
41 |
|
/** |
811 |
|
} |
812 |
|
|
813 |
|
/** |
814 |
< |
* A deserialized map equals original |
814 |
> |
* A cloned map equals original |
815 |
> |
*/ |
816 |
> |
public void testClone() { |
817 |
> |
ConcurrentSkipListMap x = map5(); |
818 |
> |
ConcurrentSkipListMap y = x.clone(); |
819 |
> |
|
820 |
> |
assertNotSame(x, y); |
821 |
> |
assertEquals(x.size(), y.size()); |
822 |
> |
assertEquals(x.toString(), y.toString()); |
823 |
> |
assertEquals(x, y); |
824 |
> |
assertEquals(y, x); |
825 |
> |
y.clear(); |
826 |
> |
assertTrue(y.isEmpty()); |
827 |
> |
assertFalse(x.equals(y)); |
828 |
> |
} |
829 |
> |
|
830 |
> |
/** |
831 |
> |
* A deserialized/reserialized map equals original |
832 |
|
*/ |
833 |
|
public void testSerialization() throws Exception { |
834 |
|
NavigableMap x = map5(); |
839 |
|
assertEquals(x.toString(), y.toString()); |
840 |
|
assertEquals(x, y); |
841 |
|
assertEquals(y, x); |
842 |
+ |
y.clear(); |
843 |
+ |
assertTrue(y.isEmpty()); |
844 |
+ |
assertFalse(x.equals(y)); |
845 |
|
} |
846 |
|
|
847 |
|
/** |
1027 |
|
|
1028 |
|
static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception { |
1029 |
|
NavigableMap<Integer, Integer> result = |
1030 |
< |
(NavigableMap<Integer, Integer>) cl.newInstance(); |
1030 |
> |
(NavigableMap<Integer, Integer>) cl.getConstructor().newInstance(); |
1031 |
|
assertEquals(0, result.size()); |
1032 |
|
assertFalse(result.keySet().iterator().hasNext()); |
1033 |
|
return result; |
1303 |
|
} |
1304 |
|
|
1305 |
|
static boolean eq(Integer i, int j) { |
1306 |
< |
return i == null ? j == -1 : i == j; |
1306 |
> |
return (i == null) ? j == -1 : i == j; |
1307 |
|
} |
1308 |
|
|
1309 |
|
} |