6 |
|
|
7 |
|
import junit.framework.*; |
8 |
|
import java.util.*; |
9 |
< |
import java.util.concurrent.*; |
10 |
< |
import java.io.*; |
9 |
> |
import java.util.concurrent.ConcurrentSkipListMap; |
10 |
|
|
11 |
|
public class ConcurrentSkipListMapTest extends JSR166TestCase { |
12 |
|
public static void main(String[] args) { |
17 |
|
} |
18 |
|
|
19 |
|
/** |
20 |
< |
* Create a map from Integers 1-5 to Strings "A"-"E". |
20 |
> |
* Creates a map from Integers 1-5 to Strings "A"-"E". |
21 |
|
*/ |
22 |
|
private static ConcurrentSkipListMap map5() { |
23 |
|
ConcurrentSkipListMap map = new ConcurrentSkipListMap(); |
38 |
|
public void testClear() { |
39 |
|
ConcurrentSkipListMap map = map5(); |
40 |
|
map.clear(); |
41 |
< |
assertEquals(map.size(), 0); |
41 |
> |
assertEquals(0, map.size()); |
42 |
|
} |
43 |
|
|
44 |
|
/** |
174 |
|
last = k; |
175 |
|
++count; |
176 |
|
} |
177 |
< |
assertEquals(count ,5); |
177 |
> |
assertEquals(5, count); |
178 |
|
} |
179 |
|
|
180 |
|
/** |
193 |
|
last = k; |
194 |
|
++count; |
195 |
|
} |
196 |
< |
assertEquals(count ,5); |
196 |
> |
assertEquals(5, count); |
197 |
|
} |
198 |
|
|
199 |
|
/** |
212 |
|
last = k; |
213 |
|
++count; |
214 |
|
} |
215 |
< |
assertEquals(count, 5); |
215 |
> |
assertEquals(5, count); |
216 |
|
} |
217 |
|
|
218 |
|
/** |
231 |
|
last = k; |
232 |
|
++count; |
233 |
|
} |
234 |
< |
assertEquals(count, 5); |
234 |
> |
assertEquals(5, count); |
235 |
|
} |
236 |
|
|
237 |
|
/** |
501 |
|
* lowerEntry, higherEntry, ceilingEntry, and floorEntry return |
502 |
|
* immutable entries |
503 |
|
*/ |
504 |
< |
public void testEntryImmutablity() { |
504 |
> |
public void testEntryImmutability() { |
505 |
|
ConcurrentSkipListMap map = map5(); |
506 |
|
Map.Entry e = map.lowerEntry(three); |
507 |
|
assertEquals(two, e.getKey()); |
529 |
|
} catch (UnsupportedOperationException success) {} |
530 |
|
} |
531 |
|
|
533 |
– |
|
532 |
|
/** |
533 |
|
* lowerKey returns preceding element |
534 |
|
*/ |
792 |
|
* A deserialized map equals original |
793 |
|
*/ |
794 |
|
public void testSerialization() throws Exception { |
795 |
< |
ConcurrentSkipListMap q = map5(); |
795 |
> |
NavigableMap x = map5(); |
796 |
> |
NavigableMap y = serialClone(x); |
797 |
|
|
798 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
799 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
800 |
< |
out.writeObject(q); |
801 |
< |
out.close(); |
802 |
< |
|
804 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
805 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
806 |
< |
ConcurrentSkipListMap r = (ConcurrentSkipListMap)in.readObject(); |
807 |
< |
assertEquals(q.size(), r.size()); |
808 |
< |
assertTrue(q.equals(r)); |
809 |
< |
assertTrue(r.equals(q)); |
798 |
> |
assertTrue(x != y); |
799 |
> |
assertEquals(x.size(), y.size()); |
800 |
> |
assertEquals(x.toString(), y.toString()); |
801 |
> |
assertEquals(x, y); |
802 |
> |
assertEquals(y, x); |
803 |
|
} |
804 |
|
|
805 |
|
/** |
986 |
|
static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception { |
987 |
|
NavigableMap<Integer, Integer> result = |
988 |
|
(NavigableMap<Integer, Integer>) cl.newInstance(); |
989 |
< |
assertEquals(result.size(), 0); |
989 |
> |
assertEquals(0, result.size()); |
990 |
|
assertFalse(result.keySet().iterator().hasNext()); |
991 |
|
return result; |
992 |
|
} |
1213 |
|
if (bsContainsI) |
1214 |
|
size++; |
1215 |
|
} |
1216 |
< |
assertEquals(map.size(), size); |
1216 |
> |
assertEquals(size, map.size()); |
1217 |
|
|
1218 |
|
// Test contents using contains keySet iterator |
1219 |
|
int size2 = 0; |