11 |
|
|
12 |
|
public class ConcurrentSkipListSubMapTest extends JSR166TestCase { |
13 |
|
public static void main(String[] args) { |
14 |
< |
junit.textui.TestRunner.run (suite()); |
14 |
> |
junit.textui.TestRunner.run (suite()); |
15 |
|
} |
16 |
|
public static Test suite() { |
17 |
|
return new TestSuite(ConcurrentSkipListSubMapTest.class); |
20 |
|
/** |
21 |
|
* Create a map from Integers 1-5 to Strings "A"-"E". |
22 |
|
*/ |
23 |
< |
private static ConcurrentNavigableMap map5() { |
23 |
> |
private static ConcurrentNavigableMap map5() { |
24 |
|
ConcurrentSkipListMap map = new ConcurrentSkipListMap(); |
25 |
|
assertTrue(map.isEmpty()); |
26 |
|
map.put(zero, "Z"); |
38 |
|
/** |
39 |
|
* Create a map from Integers -5 to -1 to Strings "A"-"E". |
40 |
|
*/ |
41 |
< |
private static ConcurrentNavigableMap dmap5() { |
41 |
> |
private static ConcurrentNavigableMap dmap5() { |
42 |
|
ConcurrentSkipListMap map = new ConcurrentSkipListMap(); |
43 |
|
assertTrue(map.isEmpty()); |
44 |
|
map.put(m1, "A"); |
51 |
|
return map.descendingMap(); |
52 |
|
} |
53 |
|
|
54 |
< |
private static ConcurrentNavigableMap map0() { |
54 |
> |
private static ConcurrentNavigableMap map0() { |
55 |
|
ConcurrentSkipListMap map = new ConcurrentSkipListMap(); |
56 |
|
assertTrue(map.isEmpty()); |
57 |
|
return map.tailMap(one, true); |
58 |
|
} |
59 |
|
|
60 |
< |
private static ConcurrentNavigableMap dmap0() { |
60 |
> |
private static ConcurrentNavigableMap dmap0() { |
61 |
|
ConcurrentSkipListMap map = new ConcurrentSkipListMap(); |
62 |
|
assertTrue(map.isEmpty()); |
63 |
|
return map; |
239 |
|
Iterator it = s.iterator(); |
240 |
|
while (it.hasNext()) { |
241 |
|
Map.Entry e = (Map.Entry) it.next(); |
242 |
< |
assertTrue( |
242 |
> |
assertTrue( |
243 |
|
(e.getKey().equals(one) && e.getValue().equals("A")) || |
244 |
|
(e.getKey().equals(two) && e.getValue().equals("B")) || |
245 |
|
(e.getKey().equals(three) && e.getValue().equals("C")) || |
497 |
|
for (int i = 1; i <= 5; ++i) { |
498 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
499 |
|
} |
500 |
< |
} |
500 |
> |
} |
501 |
|
|
502 |
|
// Exception tests |
503 |
|
|
509 |
|
ConcurrentNavigableMap c = map5(); |
510 |
|
c.get(null); |
511 |
|
shouldThrow(); |
512 |
< |
} catch(NullPointerException e){} |
512 |
> |
} catch (NullPointerException e){} |
513 |
|
} |
514 |
|
|
515 |
|
/** |
520 |
|
ConcurrentNavigableMap c = map5(); |
521 |
|
c.containsKey(null); |
522 |
|
shouldThrow(); |
523 |
< |
} catch(NullPointerException e){} |
523 |
> |
} catch (NullPointerException e){} |
524 |
|
} |
525 |
|
|
526 |
|
/** |
531 |
|
ConcurrentNavigableMap c = map0(); |
532 |
|
c.containsValue(null); |
533 |
|
shouldThrow(); |
534 |
< |
} catch(NullPointerException e){} |
534 |
> |
} catch (NullPointerException e){} |
535 |
|
} |
536 |
|
|
537 |
|
|
543 |
|
ConcurrentNavigableMap c = map5(); |
544 |
|
c.put(null, "whatever"); |
545 |
|
shouldThrow(); |
546 |
< |
} catch(NullPointerException e){} |
546 |
> |
} catch (NullPointerException e){} |
547 |
|
} |
548 |
|
|
549 |
|
/** |
554 |
|
ConcurrentNavigableMap c = map5(); |
555 |
|
c.putIfAbsent(null, "whatever"); |
556 |
|
shouldThrow(); |
557 |
< |
} catch(NullPointerException e){} |
557 |
> |
} catch (NullPointerException e){} |
558 |
|
} |
559 |
|
|
560 |
|
/** |
565 |
|
ConcurrentNavigableMap c = map5(); |
566 |
|
c.replace(null, "whatever"); |
567 |
|
shouldThrow(); |
568 |
< |
} catch(NullPointerException e){} |
568 |
> |
} catch (NullPointerException e){} |
569 |
|
} |
570 |
|
|
571 |
|
/** |
576 |
|
ConcurrentNavigableMap c = map5(); |
577 |
|
c.replace(null, one, "whatever"); |
578 |
|
shouldThrow(); |
579 |
< |
} catch(NullPointerException e){} |
579 |
> |
} catch (NullPointerException e){} |
580 |
|
} |
581 |
|
|
582 |
|
/** |
587 |
|
ConcurrentNavigableMap c = map5(); |
588 |
|
c.remove(null); |
589 |
|
shouldThrow(); |
590 |
< |
} catch(NullPointerException e){} |
590 |
> |
} catch (NullPointerException e){} |
591 |
|
} |
592 |
|
|
593 |
|
/** |
598 |
|
ConcurrentNavigableMap c = map5(); |
599 |
|
c.remove(null, "whatever"); |
600 |
|
shouldThrow(); |
601 |
< |
} catch(NullPointerException e){} |
601 |
> |
} catch (NullPointerException e){} |
602 |
|
} |
603 |
|
|
604 |
|
/** |
619 |
|
assertEquals(q.size(), r.size()); |
620 |
|
assertTrue(q.equals(r)); |
621 |
|
assertTrue(r.equals(q)); |
622 |
< |
} catch(Exception e){ |
622 |
> |
} catch (Exception e){ |
623 |
|
e.printStackTrace(); |
624 |
|
unexpectedException(); |
625 |
|
} |
938 |
|
Iterator it = s.iterator(); |
939 |
|
while (it.hasNext()) { |
940 |
|
Map.Entry e = (Map.Entry) it.next(); |
941 |
< |
assertTrue( |
941 |
> |
assertTrue( |
942 |
|
(e.getKey().equals(m1) && e.getValue().equals("A")) || |
943 |
|
(e.getKey().equals(m2) && e.getValue().equals("B")) || |
944 |
|
(e.getKey().equals(m3) && e.getValue().equals("C")) || |
1196 |
|
for (int i = 1; i <= 5; ++i) { |
1197 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
1198 |
|
} |
1199 |
< |
} |
1199 |
> |
} |
1200 |
|
|
1201 |
|
// Exception testDescendings |
1202 |
|
|
1208 |
|
ConcurrentNavigableMap c = dmap5(); |
1209 |
|
c.get(null); |
1210 |
|
shouldThrow(); |
1211 |
< |
} catch(NullPointerException e){} |
1211 |
> |
} catch (NullPointerException e){} |
1212 |
|
} |
1213 |
|
|
1214 |
|
/** |
1219 |
|
ConcurrentNavigableMap c = dmap5(); |
1220 |
|
c.containsKey(null); |
1221 |
|
shouldThrow(); |
1222 |
< |
} catch(NullPointerException e){} |
1222 |
> |
} catch (NullPointerException e){} |
1223 |
|
} |
1224 |
|
|
1225 |
|
/** |
1230 |
|
ConcurrentNavigableMap c = dmap0(); |
1231 |
|
c.containsValue(null); |
1232 |
|
shouldThrow(); |
1233 |
< |
} catch(NullPointerException e){} |
1233 |
> |
} catch (NullPointerException e){} |
1234 |
|
} |
1235 |
|
|
1236 |
|
|
1242 |
|
ConcurrentNavigableMap c = dmap5(); |
1243 |
|
c.put(null, "whatever"); |
1244 |
|
shouldThrow(); |
1245 |
< |
} catch(NullPointerException e){} |
1245 |
> |
} catch (NullPointerException e){} |
1246 |
|
} |
1247 |
|
|
1248 |
|
/** |
1253 |
|
ConcurrentNavigableMap c = dmap5(); |
1254 |
|
c.putIfAbsent(null, "whatever"); |
1255 |
|
shouldThrow(); |
1256 |
< |
} catch(NullPointerException e){} |
1256 |
> |
} catch (NullPointerException e){} |
1257 |
|
} |
1258 |
|
|
1259 |
|
/** |
1264 |
|
ConcurrentNavigableMap c = dmap5(); |
1265 |
|
c.replace(null, "whatever"); |
1266 |
|
shouldThrow(); |
1267 |
< |
} catch(NullPointerException e){} |
1267 |
> |
} catch (NullPointerException e){} |
1268 |
|
} |
1269 |
|
|
1270 |
|
/** |
1275 |
|
ConcurrentNavigableMap c = dmap5(); |
1276 |
|
c.replace(null, m1, "whatever"); |
1277 |
|
shouldThrow(); |
1278 |
< |
} catch(NullPointerException e){} |
1278 |
> |
} catch (NullPointerException e){} |
1279 |
|
} |
1280 |
|
|
1281 |
|
/** |
1286 |
|
ConcurrentNavigableMap c = dmap5(); |
1287 |
|
c.remove(null); |
1288 |
|
shouldThrow(); |
1289 |
< |
} catch(NullPointerException e){} |
1289 |
> |
} catch (NullPointerException e){} |
1290 |
|
} |
1291 |
|
|
1292 |
|
/** |
1297 |
|
ConcurrentNavigableMap c = dmap5(); |
1298 |
|
c.remove(null, "whatever"); |
1299 |
|
shouldThrow(); |
1300 |
< |
} catch(NullPointerException e){} |
1300 |
> |
} catch (NullPointerException e){} |
1301 |
|
} |
1302 |
|
|
1303 |
|
/** |
1318 |
|
assertEquals(q.size(), r.size()); |
1319 |
|
assertTrue(q.equals(r)); |
1320 |
|
assertTrue(r.equals(q)); |
1321 |
< |
} catch(Exception e){ |
1321 |
> |
} catch (Exception e){ |
1322 |
|
e.printStackTrace(); |
1323 |
|
unexpectedException(); |
1324 |
|
} |
1460 |
|
assertEquals(3, sm.size()); |
1461 |
|
assertEquals(4, map.size()); |
1462 |
|
} |
1463 |
< |
|
1463 |
> |
|
1464 |
|
} |