1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
import junit.framework.*; |
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); |
64 |
|
} |
65 |
|
|
66 |
|
/** |
67 |
< |
* clear removes all pairs |
67 |
> |
* clear removes all pairs |
68 |
|
*/ |
69 |
|
public void testClear() { |
70 |
|
ConcurrentNavigableMap map = map5(); |
74 |
|
|
75 |
|
|
76 |
|
/** |
77 |
< |
* Maps with same contents are equal |
77 |
> |
* Maps with same contents are equal |
78 |
|
*/ |
79 |
|
public void testEquals() { |
80 |
|
ConcurrentNavigableMap map1 = map5(); |
87 |
|
} |
88 |
|
|
89 |
|
/** |
90 |
< |
* containsKey returns true for contained key |
90 |
> |
* containsKey returns true for contained key |
91 |
|
*/ |
92 |
|
public void testContainsKey() { |
93 |
|
ConcurrentNavigableMap map = map5(); |
96 |
|
} |
97 |
|
|
98 |
|
/** |
99 |
< |
* containsValue returns true for held values |
99 |
> |
* containsValue returns true for held values |
100 |
|
*/ |
101 |
|
public void testContainsValue() { |
102 |
|
ConcurrentNavigableMap map = map5(); |
105 |
|
} |
106 |
|
|
107 |
|
/** |
108 |
< |
* get returns the correct element at the given key, |
109 |
< |
* or null if not present |
108 |
> |
* get returns the correct element at the given key, |
109 |
> |
* or null if not present |
110 |
|
*/ |
111 |
|
public void testGet() { |
112 |
|
ConcurrentNavigableMap map = map5(); |
116 |
|
} |
117 |
|
|
118 |
|
/** |
119 |
< |
* isEmpty is true of empty map and false for non-empty |
119 |
> |
* isEmpty is true of empty map and false for non-empty |
120 |
|
*/ |
121 |
|
public void testIsEmpty() { |
122 |
|
ConcurrentNavigableMap empty = map0(); |
126 |
|
} |
127 |
|
|
128 |
|
/** |
129 |
< |
* firstKey returns first key |
129 |
> |
* firstKey returns first key |
130 |
|
*/ |
131 |
|
public void testFirstKey() { |
132 |
|
ConcurrentNavigableMap map = map5(); |
134 |
|
} |
135 |
|
|
136 |
|
/** |
137 |
< |
* lastKey returns last key |
137 |
> |
* lastKey returns last key |
138 |
|
*/ |
139 |
|
public void testLastKey() { |
140 |
|
ConcurrentNavigableMap map = map5(); |
143 |
|
|
144 |
|
|
145 |
|
/** |
146 |
< |
* keySet returns a Set containing all the keys |
146 |
> |
* keySet returns a Set containing all the keys |
147 |
|
*/ |
148 |
|
public void testKeySet() { |
149 |
|
ConcurrentNavigableMap map = map5(); |
157 |
|
} |
158 |
|
|
159 |
|
/** |
160 |
< |
* keySet is ordered |
160 |
> |
* keySet is ordered |
161 |
|
*/ |
162 |
|
public void testKeySetOrder() { |
163 |
|
ConcurrentNavigableMap map = map5(); |
187 |
|
} |
188 |
|
|
189 |
|
/** |
190 |
< |
* keySet.toArray returns contains all keys |
190 |
> |
* keySet.toArray returns contains all keys |
191 |
|
*/ |
192 |
|
public void testKeySetToArray() { |
193 |
|
ConcurrentNavigableMap map = map5(); |
200 |
|
} |
201 |
|
|
202 |
|
/** |
203 |
< |
* descendingkeySet.toArray returns contains all keys |
203 |
> |
* descendingkeySet.toArray returns contains all keys |
204 |
|
*/ |
205 |
|
public void testDescendingKeySetToArray() { |
206 |
|
ConcurrentNavigableMap map = map5(); |
213 |
|
} |
214 |
|
|
215 |
|
/** |
216 |
< |
* Values.toArray contains all values |
216 |
> |
* Values.toArray contains all values |
217 |
|
*/ |
218 |
|
public void testValuesToArray() { |
219 |
|
ConcurrentNavigableMap map = map5(); |
249 |
|
} |
250 |
|
|
251 |
|
/** |
252 |
< |
* putAll adds all key-value pairs from the given map |
252 |
> |
* putAll adds all key-value pairs from the given map |
253 |
|
*/ |
254 |
|
public void testPutAll() { |
255 |
|
ConcurrentNavigableMap empty = map0(); |
264 |
|
} |
265 |
|
|
266 |
|
/** |
267 |
< |
* putIfAbsent works when the given key is not present |
267 |
> |
* putIfAbsent works when the given key is not present |
268 |
|
*/ |
269 |
|
public void testPutIfAbsent() { |
270 |
|
ConcurrentNavigableMap map = map5(); |
273 |
|
} |
274 |
|
|
275 |
|
/** |
276 |
< |
* putIfAbsent does not add the pair if the key is already present |
276 |
> |
* putIfAbsent does not add the pair if the key is already present |
277 |
|
*/ |
278 |
|
public void testPutIfAbsent2() { |
279 |
|
ConcurrentNavigableMap map = map5(); |
281 |
|
} |
282 |
|
|
283 |
|
/** |
284 |
< |
* replace fails when the given key is not present |
284 |
> |
* replace fails when the given key is not present |
285 |
|
*/ |
286 |
|
public void testReplace() { |
287 |
|
ConcurrentNavigableMap map = map5(); |
290 |
|
} |
291 |
|
|
292 |
|
/** |
293 |
< |
* replace succeeds if the key is already present |
293 |
> |
* replace succeeds if the key is already present |
294 |
|
*/ |
295 |
|
public void testReplace2() { |
296 |
|
ConcurrentNavigableMap map = map5(); |
321 |
|
|
322 |
|
|
323 |
|
/** |
324 |
< |
* remove removes the correct key-value pair from the map |
324 |
> |
* remove removes the correct key-value pair from the map |
325 |
|
*/ |
326 |
|
public void testRemove() { |
327 |
|
ConcurrentNavigableMap map = map5(); |
343 |
|
map.remove(four, "A"); |
344 |
|
assertEquals(4, map.size()); |
345 |
|
assertTrue(map.containsKey(four)); |
346 |
– |
|
346 |
|
} |
347 |
|
|
348 |
|
/** |
361 |
|
|
362 |
|
Map.Entry e4 = map.lowerEntry(zero); |
363 |
|
assertNull(e4); |
365 |
– |
|
364 |
|
} |
365 |
|
|
366 |
|
/** |
379 |
|
|
380 |
|
Map.Entry e4 = map.higherEntry(six); |
381 |
|
assertNull(e4); |
384 |
– |
|
382 |
|
} |
383 |
|
|
384 |
|
/** |
397 |
|
|
398 |
|
Map.Entry e4 = map.floorEntry(zero); |
399 |
|
assertNull(e4); |
403 |
– |
|
400 |
|
} |
401 |
|
|
402 |
|
/** |
415 |
|
|
416 |
|
Map.Entry e4 = map.ceilingEntry(six); |
417 |
|
assertNull(e4); |
422 |
– |
|
418 |
|
} |
419 |
|
|
420 |
|
/** |
439 |
|
try { |
440 |
|
e.setValue("A"); |
441 |
|
shouldThrow(); |
442 |
< |
} catch (Exception ok) { |
448 |
< |
} |
442 |
> |
} catch (UnsupportedOperationException success) {} |
443 |
|
e = map.pollFirstEntry(); |
444 |
|
assertNull(e); |
445 |
|
} |
466 |
|
try { |
467 |
|
e.setValue("E"); |
468 |
|
shouldThrow(); |
469 |
< |
} catch (Exception ok) { |
476 |
< |
} |
469 |
> |
} catch (UnsupportedOperationException success) {} |
470 |
|
e = map.pollLastEntry(); |
471 |
|
assertNull(e); |
472 |
|
} |
473 |
|
|
474 |
|
/** |
475 |
< |
* size returns the correct values |
475 |
> |
* size returns the correct values |
476 |
|
*/ |
477 |
|
public void testSize() { |
478 |
|
ConcurrentNavigableMap map = map5(); |
502 |
|
ConcurrentNavigableMap c = map5(); |
503 |
|
c.get(null); |
504 |
|
shouldThrow(); |
505 |
< |
} catch (NullPointerException e) {} |
505 |
> |
} catch (NullPointerException success) {} |
506 |
|
} |
507 |
|
|
508 |
|
/** |
513 |
|
ConcurrentNavigableMap c = map5(); |
514 |
|
c.containsKey(null); |
515 |
|
shouldThrow(); |
516 |
< |
} catch (NullPointerException e) {} |
516 |
> |
} catch (NullPointerException success) {} |
517 |
|
} |
518 |
|
|
519 |
|
/** |
524 |
|
ConcurrentNavigableMap c = map0(); |
525 |
|
c.containsValue(null); |
526 |
|
shouldThrow(); |
527 |
< |
} catch (NullPointerException e) {} |
527 |
> |
} catch (NullPointerException success) {} |
528 |
|
} |
529 |
|
|
530 |
|
|
536 |
|
ConcurrentNavigableMap c = map5(); |
537 |
|
c.put(null, "whatever"); |
538 |
|
shouldThrow(); |
539 |
< |
} catch (NullPointerException e) {} |
539 |
> |
} catch (NullPointerException success) {} |
540 |
|
} |
541 |
|
|
542 |
|
/** |
547 |
|
ConcurrentNavigableMap c = map5(); |
548 |
|
c.putIfAbsent(null, "whatever"); |
549 |
|
shouldThrow(); |
550 |
< |
} catch (NullPointerException e) {} |
550 |
> |
} catch (NullPointerException success) {} |
551 |
|
} |
552 |
|
|
553 |
|
/** |
558 |
|
ConcurrentNavigableMap c = map5(); |
559 |
|
c.replace(null, "whatever"); |
560 |
|
shouldThrow(); |
561 |
< |
} catch (NullPointerException e) {} |
561 |
> |
} catch (NullPointerException success) {} |
562 |
|
} |
563 |
|
|
564 |
|
/** |
569 |
|
ConcurrentNavigableMap c = map5(); |
570 |
|
c.replace(null, one, "whatever"); |
571 |
|
shouldThrow(); |
572 |
< |
} catch (NullPointerException e) {} |
572 |
> |
} catch (NullPointerException success) {} |
573 |
|
} |
574 |
|
|
575 |
|
/** |
580 |
|
ConcurrentNavigableMap c = map5(); |
581 |
|
c.remove(null); |
582 |
|
shouldThrow(); |
583 |
< |
} catch (NullPointerException e) {} |
583 |
> |
} catch (NullPointerException success) {} |
584 |
|
} |
585 |
|
|
586 |
|
/** |
591 |
|
ConcurrentNavigableMap c = map5(); |
592 |
|
c.remove(null, "whatever"); |
593 |
|
shouldThrow(); |
594 |
< |
} catch (NullPointerException e) {} |
594 |
> |
} catch (NullPointerException success) {} |
595 |
|
} |
596 |
|
|
597 |
|
/** |
598 |
|
* A deserialized map equals original |
599 |
|
*/ |
600 |
< |
public void testSerialization() { |
600 |
> |
public void testSerialization() throws Exception { |
601 |
|
ConcurrentNavigableMap q = map5(); |
602 |
|
|
603 |
< |
try { |
604 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
605 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
606 |
< |
out.writeObject(q); |
607 |
< |
out.close(); |
608 |
< |
|
609 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
610 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
611 |
< |
ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); |
612 |
< |
assertEquals(q.size(), r.size()); |
613 |
< |
assertTrue(q.equals(r)); |
621 |
< |
assertTrue(r.equals(q)); |
622 |
< |
} catch (Exception e) { |
623 |
< |
e.printStackTrace(); |
624 |
< |
unexpectedException(); |
625 |
< |
} |
603 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
604 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
605 |
> |
out.writeObject(q); |
606 |
> |
out.close(); |
607 |
> |
|
608 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
609 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
610 |
> |
ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); |
611 |
> |
assertEquals(q.size(), r.size()); |
612 |
> |
assertTrue(q.equals(r)); |
613 |
> |
assertTrue(r.equals(q)); |
614 |
|
} |
615 |
|
|
616 |
|
|
644 |
|
assertEquals(1, sm.size()); |
645 |
|
assertEquals(three, sm.firstKey()); |
646 |
|
assertEquals(three, sm.lastKey()); |
647 |
< |
assertTrue(sm.remove(three) != null); |
647 |
> |
assertEquals("C", sm.remove(three)); |
648 |
|
assertTrue(sm.isEmpty()); |
649 |
|
assertEquals(3, map.size()); |
650 |
|
} |
672 |
|
assertEquals(4, map.size()); |
673 |
|
assertEquals(0, sm.size()); |
674 |
|
assertTrue(sm.isEmpty()); |
675 |
< |
assertTrue(sm.remove(three) == null); |
675 |
> |
assertSame(sm.remove(three), null); |
676 |
|
assertEquals(4, map.size()); |
677 |
|
} |
678 |
|
|
744 |
|
SortedMap ssm = sm.tailMap(four); |
745 |
|
assertEquals(four, ssm.firstKey()); |
746 |
|
assertEquals(five, ssm.lastKey()); |
747 |
< |
assertTrue(ssm.remove(four) != null); |
747 |
> |
assertEquals("D", ssm.remove(four)); |
748 |
|
assertEquals(1, ssm.size()); |
749 |
|
assertEquals(3, sm.size()); |
750 |
|
assertEquals(4, map.size()); |
751 |
|
} |
752 |
|
|
753 |
|
/** |
754 |
< |
* clear removes all pairs |
754 |
> |
* clear removes all pairs |
755 |
|
*/ |
756 |
|
public void testDescendingClear() { |
757 |
|
ConcurrentNavigableMap map = dmap5(); |
761 |
|
|
762 |
|
|
763 |
|
/** |
764 |
< |
* Maps with same contents are equal |
764 |
> |
* Maps with same contents are equal |
765 |
|
*/ |
766 |
|
public void testDescendingEquals() { |
767 |
|
ConcurrentNavigableMap map1 = dmap5(); |
774 |
|
} |
775 |
|
|
776 |
|
/** |
777 |
< |
* containsKey returns true for contained key |
777 |
> |
* containsKey returns true for contained key |
778 |
|
*/ |
779 |
|
public void testDescendingContainsKey() { |
780 |
|
ConcurrentNavigableMap map = dmap5(); |
783 |
|
} |
784 |
|
|
785 |
|
/** |
786 |
< |
* containsValue returns true for held values |
786 |
> |
* containsValue returns true for held values |
787 |
|
*/ |
788 |
|
public void testDescendingContainsValue() { |
789 |
|
ConcurrentNavigableMap map = dmap5(); |
792 |
|
} |
793 |
|
|
794 |
|
/** |
795 |
< |
* get returns the correct element at the given key, |
796 |
< |
* or null if not present |
795 |
> |
* get returns the correct element at the given key, |
796 |
> |
* or null if not present |
797 |
|
*/ |
798 |
|
public void testDescendingGet() { |
799 |
|
ConcurrentNavigableMap map = dmap5(); |
803 |
|
} |
804 |
|
|
805 |
|
/** |
806 |
< |
* isEmpty is true of empty map and false for non-empty |
806 |
> |
* isEmpty is true of empty map and false for non-empty |
807 |
|
*/ |
808 |
|
public void testDescendingIsEmpty() { |
809 |
|
ConcurrentNavigableMap empty = dmap0(); |
813 |
|
} |
814 |
|
|
815 |
|
/** |
816 |
< |
* firstKey returns first key |
816 |
> |
* firstKey returns first key |
817 |
|
*/ |
818 |
|
public void testDescendingFirstKey() { |
819 |
|
ConcurrentNavigableMap map = dmap5(); |
821 |
|
} |
822 |
|
|
823 |
|
/** |
824 |
< |
* lastKey returns last key |
824 |
> |
* lastKey returns last key |
825 |
|
*/ |
826 |
|
public void testDescendingLastKey() { |
827 |
|
ConcurrentNavigableMap map = dmap5(); |
830 |
|
|
831 |
|
|
832 |
|
/** |
833 |
< |
* keySet returns a Set containing all the keys |
833 |
> |
* keySet returns a Set containing all the keys |
834 |
|
*/ |
835 |
|
public void testDescendingKeySet() { |
836 |
|
ConcurrentNavigableMap map = dmap5(); |
844 |
|
} |
845 |
|
|
846 |
|
/** |
847 |
< |
* keySet is ordered |
847 |
> |
* keySet is ordered |
848 |
|
*/ |
849 |
|
public void testDescendingKeySetOrder() { |
850 |
|
ConcurrentNavigableMap map = dmap5(); |
874 |
|
} |
875 |
|
|
876 |
|
/** |
877 |
< |
* keySet.toArray returns contains all keys |
877 |
> |
* keySet.toArray returns contains all keys |
878 |
|
*/ |
879 |
|
public void testDescendingAscendingKeySetToArray() { |
880 |
|
ConcurrentNavigableMap map = dmap5(); |
887 |
|
} |
888 |
|
|
889 |
|
/** |
890 |
< |
* descendingkeySet.toArray returns contains all keys |
890 |
> |
* descendingkeySet.toArray returns contains all keys |
891 |
|
*/ |
892 |
|
public void testDescendingDescendingKeySetToArray() { |
893 |
|
ConcurrentNavigableMap map = dmap5(); |
900 |
|
} |
901 |
|
|
902 |
|
/** |
903 |
< |
* Values.toArray contains all values |
903 |
> |
* Values.toArray contains all values |
904 |
|
*/ |
905 |
|
public void testDescendingValuesToArray() { |
906 |
|
ConcurrentNavigableMap map = dmap5(); |
936 |
|
} |
937 |
|
|
938 |
|
/** |
939 |
< |
* putAll adds all key-value pairs from the given map |
939 |
> |
* putAll adds all key-value pairs from the given map |
940 |
|
*/ |
941 |
|
public void testDescendingPutAll() { |
942 |
|
ConcurrentNavigableMap empty = dmap0(); |
951 |
|
} |
952 |
|
|
953 |
|
/** |
954 |
< |
* putIfAbsent works when the given key is not present |
954 |
> |
* putIfAbsent works when the given key is not present |
955 |
|
*/ |
956 |
|
public void testDescendingPutIfAbsent() { |
957 |
|
ConcurrentNavigableMap map = dmap5(); |
960 |
|
} |
961 |
|
|
962 |
|
/** |
963 |
< |
* putIfAbsent does not add the pair if the key is already present |
963 |
> |
* putIfAbsent does not add the pair if the key is already present |
964 |
|
*/ |
965 |
|
public void testDescendingPutIfAbsent2() { |
966 |
|
ConcurrentNavigableMap map = dmap5(); |
968 |
|
} |
969 |
|
|
970 |
|
/** |
971 |
< |
* replace fails when the given key is not present |
971 |
> |
* replace fails when the given key is not present |
972 |
|
*/ |
973 |
|
public void testDescendingReplace() { |
974 |
|
ConcurrentNavigableMap map = dmap5(); |
977 |
|
} |
978 |
|
|
979 |
|
/** |
980 |
< |
* replace succeeds if the key is already present |
980 |
> |
* replace succeeds if the key is already present |
981 |
|
*/ |
982 |
|
public void testDescendingReplace2() { |
983 |
|
ConcurrentNavigableMap map = dmap5(); |
1008 |
|
|
1009 |
|
|
1010 |
|
/** |
1011 |
< |
* remove removes the correct key-value pair from the map |
1011 |
> |
* remove removes the correct key-value pair from the map |
1012 |
|
*/ |
1013 |
|
public void testDescendingRemove() { |
1014 |
|
ConcurrentNavigableMap map = dmap5(); |
1030 |
|
map.remove(m4, "A"); |
1031 |
|
assertEquals(4, map.size()); |
1032 |
|
assertTrue(map.containsKey(m4)); |
1045 |
– |
|
1033 |
|
} |
1034 |
|
|
1035 |
|
/** |
1048 |
|
|
1049 |
|
Map.Entry e4 = map.lowerEntry(zero); |
1050 |
|
assertNull(e4); |
1064 |
– |
|
1051 |
|
} |
1052 |
|
|
1053 |
|
/** |
1066 |
|
|
1067 |
|
Map.Entry e4 = map.higherEntry(m6); |
1068 |
|
assertNull(e4); |
1083 |
– |
|
1069 |
|
} |
1070 |
|
|
1071 |
|
/** |
1084 |
|
|
1085 |
|
Map.Entry e4 = map.floorEntry(zero); |
1086 |
|
assertNull(e4); |
1102 |
– |
|
1087 |
|
} |
1088 |
|
|
1089 |
|
/** |
1102 |
|
|
1103 |
|
Map.Entry e4 = map.ceilingEntry(m6); |
1104 |
|
assertNull(e4); |
1121 |
– |
|
1105 |
|
} |
1106 |
|
|
1107 |
|
/** |
1126 |
|
try { |
1127 |
|
e.setValue("A"); |
1128 |
|
shouldThrow(); |
1129 |
< |
} catch (Exception ok) { |
1147 |
< |
} |
1129 |
> |
} catch (UnsupportedOperationException success) {} |
1130 |
|
e = map.pollFirstEntry(); |
1131 |
|
assertNull(e); |
1132 |
|
} |
1153 |
|
try { |
1154 |
|
e.setValue("E"); |
1155 |
|
shouldThrow(); |
1156 |
< |
} catch (Exception ok) { |
1175 |
< |
} |
1156 |
> |
} catch (UnsupportedOperationException success) {} |
1157 |
|
e = map.pollLastEntry(); |
1158 |
|
assertNull(e); |
1159 |
|
} |
1160 |
|
|
1161 |
|
/** |
1162 |
< |
* size returns the correct values |
1162 |
> |
* size returns the correct values |
1163 |
|
*/ |
1164 |
|
public void testDescendingSize() { |
1165 |
|
ConcurrentNavigableMap map = dmap5(); |
1182 |
|
// Exception testDescendings |
1183 |
|
|
1184 |
|
/** |
1185 |
< |
* get(null) of nm1mpty map throws NPE |
1185 |
> |
* get(null) of empty map throws NPE |
1186 |
|
*/ |
1187 |
|
public void testDescendingGet_NullPointerException() { |
1188 |
|
try { |
1189 |
|
ConcurrentNavigableMap c = dmap5(); |
1190 |
|
c.get(null); |
1191 |
|
shouldThrow(); |
1192 |
< |
} catch (NullPointerException e) {} |
1192 |
> |
} catch (NullPointerException success) {} |
1193 |
|
} |
1194 |
|
|
1195 |
|
/** |
1196 |
< |
* containsKey(null) of nm1mpty map throws NPE |
1196 |
> |
* containsKey(null) of empty map throws NPE |
1197 |
|
*/ |
1198 |
|
public void testDescendingContainsKey_NullPointerException() { |
1199 |
|
try { |
1200 |
|
ConcurrentNavigableMap c = dmap5(); |
1201 |
|
c.containsKey(null); |
1202 |
|
shouldThrow(); |
1203 |
< |
} catch (NullPointerException e) {} |
1203 |
> |
} catch (NullPointerException success) {} |
1204 |
|
} |
1205 |
|
|
1206 |
|
/** |
1211 |
|
ConcurrentNavigableMap c = dmap0(); |
1212 |
|
c.containsValue(null); |
1213 |
|
shouldThrow(); |
1214 |
< |
} catch (NullPointerException e) {} |
1214 |
> |
} catch (NullPointerException success) {} |
1215 |
|
} |
1216 |
|
|
1217 |
|
|
1223 |
|
ConcurrentNavigableMap c = dmap5(); |
1224 |
|
c.put(null, "whatever"); |
1225 |
|
shouldThrow(); |
1226 |
< |
} catch (NullPointerException e) {} |
1226 |
> |
} catch (NullPointerException success) {} |
1227 |
|
} |
1228 |
|
|
1229 |
|
/** |
1234 |
|
ConcurrentNavigableMap c = dmap5(); |
1235 |
|
c.putIfAbsent(null, "whatever"); |
1236 |
|
shouldThrow(); |
1237 |
< |
} catch (NullPointerException e) {} |
1237 |
> |
} catch (NullPointerException success) {} |
1238 |
|
} |
1239 |
|
|
1240 |
|
/** |
1245 |
|
ConcurrentNavigableMap c = dmap5(); |
1246 |
|
c.replace(null, "whatever"); |
1247 |
|
shouldThrow(); |
1248 |
< |
} catch (NullPointerException e) {} |
1248 |
> |
} catch (NullPointerException success) {} |
1249 |
|
} |
1250 |
|
|
1251 |
|
/** |
1256 |
|
ConcurrentNavigableMap c = dmap5(); |
1257 |
|
c.replace(null, m1, "whatever"); |
1258 |
|
shouldThrow(); |
1259 |
< |
} catch (NullPointerException e) {} |
1259 |
> |
} catch (NullPointerException success) {} |
1260 |
|
} |
1261 |
|
|
1262 |
|
/** |
1267 |
|
ConcurrentNavigableMap c = dmap5(); |
1268 |
|
c.remove(null); |
1269 |
|
shouldThrow(); |
1270 |
< |
} catch (NullPointerException e) {} |
1270 |
> |
} catch (NullPointerException success) {} |
1271 |
|
} |
1272 |
|
|
1273 |
|
/** |
1278 |
|
ConcurrentNavigableMap c = dmap5(); |
1279 |
|
c.remove(null, "whatever"); |
1280 |
|
shouldThrow(); |
1281 |
< |
} catch (NullPointerException e) {} |
1281 |
> |
} catch (NullPointerException success) {} |
1282 |
|
} |
1283 |
|
|
1284 |
|
/** |
1285 |
|
* A deserialized map equals original |
1286 |
|
*/ |
1287 |
< |
public void testDescendingSerialization() { |
1287 |
> |
public void testDescendingSerialization() throws Exception { |
1288 |
|
ConcurrentNavigableMap q = dmap5(); |
1289 |
|
|
1290 |
< |
try { |
1291 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
1292 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
1293 |
< |
out.writeObject(q); |
1294 |
< |
out.close(); |
1295 |
< |
|
1296 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
1297 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1298 |
< |
ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); |
1299 |
< |
assertEquals(q.size(), r.size()); |
1300 |
< |
assertTrue(q.equals(r)); |
1320 |
< |
assertTrue(r.equals(q)); |
1321 |
< |
} catch (Exception e) { |
1322 |
< |
e.printStackTrace(); |
1323 |
< |
unexpectedException(); |
1324 |
< |
} |
1290 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
1291 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
1292 |
> |
out.writeObject(q); |
1293 |
> |
out.close(); |
1294 |
> |
|
1295 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
1296 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1297 |
> |
ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject(); |
1298 |
> |
assertEquals(q.size(), r.size()); |
1299 |
> |
assertTrue(q.equals(r)); |
1300 |
> |
assertTrue(r.equals(q)); |
1301 |
|
} |
1302 |
|
|
1303 |
|
|
1328 |
– |
|
1304 |
|
/** |
1305 |
|
* subMap returns map with keys in requested range |
1306 |
|
*/ |
1330 |
|
assertEquals(1, sm.size()); |
1331 |
|
assertEquals(m3, sm.firstKey()); |
1332 |
|
assertEquals(m3, sm.lastKey()); |
1333 |
< |
assertTrue(sm.remove(m3) != null); |
1333 |
> |
assertEquals("C", sm.remove(m3)); |
1334 |
|
assertTrue(sm.isEmpty()); |
1335 |
|
assertEquals(3, map.size()); |
1336 |
|
} |
1358 |
|
assertEquals(4, map.size()); |
1359 |
|
assertEquals(0, sm.size()); |
1360 |
|
assertTrue(sm.isEmpty()); |
1361 |
< |
assertTrue(sm.remove(m3) == null); |
1361 |
> |
assertSame(sm.remove(m3), null); |
1362 |
|
assertEquals(4, map.size()); |
1363 |
|
} |
1364 |
|
|
1430 |
|
SortedMap ssm = sm.tailMap(m4); |
1431 |
|
assertEquals(m4, ssm.firstKey()); |
1432 |
|
assertEquals(m5, ssm.lastKey()); |
1433 |
< |
assertTrue(ssm.remove(m4) != null); |
1433 |
> |
assertEquals("D", ssm.remove(m4)); |
1434 |
|
assertEquals(1, ssm.size()); |
1435 |
|
assertEquals(3, sm.size()); |
1436 |
|
assertEquals(4, map.size()); |