ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentSkipListSubMapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentSkipListSubMapTest.java (file contents):
Revision 1.10 by jsr166, Sat Nov 21 10:25:05 2009 UTC vs.
Revision 1.20 by jsr166, Sat Nov 26 05:19:17 2011 UTC

# Line 1 | Line 1
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.*;
8 + import java.util.concurrent.ConcurrentNavigableMap;
9 + import java.util.concurrent.ConcurrentSkipListMap;
10   import java.util.*;
9 import java.util.concurrent.*;
10 import java.io.*;
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);
# Line 64 | Line 64 | public class ConcurrentSkipListSubMapTes
64      }
65  
66      /**
67 <     *  clear removes all pairs
67 >     * clear removes all pairs
68       */
69      public void testClear() {
70          ConcurrentNavigableMap map = map5();
71          map.clear();
72 <        assertEquals(map.size(), 0);
72 >        assertEquals(0, map.size());
73      }
74  
75
75      /**
76 <     *  Maps with same contents are equal
76 >     * Maps with same contents are equal
77       */
78      public void testEquals() {
79          ConcurrentNavigableMap map1 = map5();
# Line 87 | Line 86 | public class ConcurrentSkipListSubMapTes
86      }
87  
88      /**
89 <     *  containsKey returns true for contained key
89 >     * containsKey returns true for contained key
90       */
91      public void testContainsKey() {
92          ConcurrentNavigableMap map = map5();
# Line 96 | Line 95 | public class ConcurrentSkipListSubMapTes
95      }
96  
97      /**
98 <     *  containsValue returns true for held values
98 >     * containsValue returns true for held values
99       */
100      public void testContainsValue() {
101          ConcurrentNavigableMap map = map5();
# Line 105 | Line 104 | public class ConcurrentSkipListSubMapTes
104      }
105  
106      /**
107 <     *  get returns the correct element at the given key,
108 <     *  or null if not present
107 >     * get returns the correct element at the given key,
108 >     * or null if not present
109       */
110      public void testGet() {
111          ConcurrentNavigableMap map = map5();
# Line 116 | Line 115 | public class ConcurrentSkipListSubMapTes
115      }
116  
117      /**
118 <     *  isEmpty is true of empty map and false for non-empty
118 >     * isEmpty is true of empty map and false for non-empty
119       */
120      public void testIsEmpty() {
121          ConcurrentNavigableMap empty = map0();
# Line 126 | Line 125 | public class ConcurrentSkipListSubMapTes
125      }
126  
127      /**
128 <     *   firstKey returns first key
128 >     * firstKey returns first key
129       */
130      public void testFirstKey() {
131          ConcurrentNavigableMap map = map5();
# Line 134 | Line 133 | public class ConcurrentSkipListSubMapTes
133      }
134  
135      /**
136 <     *   lastKey returns last key
136 >     * lastKey returns last key
137       */
138      public void testLastKey() {
139          ConcurrentNavigableMap map = map5();
140          assertEquals(five, map.lastKey());
141      }
142  
144
143      /**
144 <     *   keySet returns a Set containing all the keys
144 >     * keySet returns a Set containing all the keys
145       */
146      public void testKeySet() {
147          ConcurrentNavigableMap map = map5();
# Line 157 | Line 155 | public class ConcurrentSkipListSubMapTes
155      }
156  
157      /**
158 <     *   keySet is ordered
158 >     * keySet is ordered
159       */
160      public void testKeySetOrder() {
161          ConcurrentNavigableMap map = map5();
# Line 187 | Line 185 | public class ConcurrentSkipListSubMapTes
185      }
186  
187      /**
188 <     *  keySet.toArray returns contains all keys
188 >     * keySet.toArray returns contains all keys
189       */
190      public void testKeySetToArray() {
191          ConcurrentNavigableMap map = map5();
# Line 200 | Line 198 | public class ConcurrentSkipListSubMapTes
198      }
199  
200      /**
201 <     *  descendingkeySet.toArray returns contains all keys
201 >     * descendingkeySet.toArray returns contains all keys
202       */
203      public void testDescendingKeySetToArray() {
204          ConcurrentNavigableMap map = map5();
# Line 213 | Line 211 | public class ConcurrentSkipListSubMapTes
211      }
212  
213      /**
214 <     *  Values.toArray contains all values
214 >     * Values.toArray contains all values
215       */
216      public void testValuesToArray() {
217          ConcurrentNavigableMap map = map5();
# Line 228 | Line 226 | public class ConcurrentSkipListSubMapTes
226          assertTrue(s.contains("E"));
227      }
228  
231
229      /**
230       * entrySet contains all pairs
231       */
# Line 249 | Line 246 | public class ConcurrentSkipListSubMapTes
246      }
247  
248      /**
249 <     *   putAll  adds all key-value pairs from the given map
249 >     * putAll adds all key-value pairs from the given map
250       */
251      public void testPutAll() {
252          ConcurrentNavigableMap empty = map0();
# Line 264 | Line 261 | public class ConcurrentSkipListSubMapTes
261      }
262  
263      /**
264 <     *   putIfAbsent works when the given key is not present
264 >     * putIfAbsent works when the given key is not present
265       */
266      public void testPutIfAbsent() {
267          ConcurrentNavigableMap map = map5();
# Line 273 | Line 270 | public class ConcurrentSkipListSubMapTes
270      }
271  
272      /**
273 <     *   putIfAbsent does not add the pair if the key is already present
273 >     * putIfAbsent does not add the pair if the key is already present
274       */
275      public void testPutIfAbsent2() {
276          ConcurrentNavigableMap map = map5();
# Line 281 | Line 278 | public class ConcurrentSkipListSubMapTes
278      }
279  
280      /**
281 <     *   replace fails when the given key is not present
281 >     * replace fails when the given key is not present
282       */
283      public void testReplace() {
284          ConcurrentNavigableMap map = map5();
# Line 290 | Line 287 | public class ConcurrentSkipListSubMapTes
287      }
288  
289      /**
290 <     *   replace succeeds if the key is already present
290 >     * replace succeeds if the key is already present
291       */
292      public void testReplace2() {
293          ConcurrentNavigableMap map = map5();
# Line 298 | Line 295 | public class ConcurrentSkipListSubMapTes
295          assertEquals("Z", map.get(one));
296      }
297  
301
298      /**
299       * replace value fails when the given key not mapped to expected value
300       */
# Line 319 | Line 315 | public class ConcurrentSkipListSubMapTes
315          assertEquals("Z", map.get(one));
316      }
317  
322
318      /**
319 <     *   remove removes the correct key-value pair from the map
319 >     * remove removes the correct key-value pair from the map
320       */
321      public void testRemove() {
322          ConcurrentNavigableMap map = map5();
# Line 343 | Line 338 | public class ConcurrentSkipListSubMapTes
338          map.remove(four, "A");
339          assertEquals(4, map.size());
340          assertTrue(map.containsKey(four));
346
341      }
342  
343      /**
# Line 362 | Line 356 | public class ConcurrentSkipListSubMapTes
356  
357          Map.Entry e4 = map.lowerEntry(zero);
358          assertNull(e4);
365
359      }
360  
361      /**
# Line 381 | Line 374 | public class ConcurrentSkipListSubMapTes
374  
375          Map.Entry e4 = map.higherEntry(six);
376          assertNull(e4);
384
377      }
378  
379      /**
# Line 400 | Line 392 | public class ConcurrentSkipListSubMapTes
392  
393          Map.Entry e4 = map.floorEntry(zero);
394          assertNull(e4);
403
395      }
396  
397      /**
# Line 419 | Line 410 | public class ConcurrentSkipListSubMapTes
410  
411          Map.Entry e4 = map.ceilingEntry(six);
412          assertNull(e4);
422
413      }
414  
415      /**
# Line 444 | Line 434 | public class ConcurrentSkipListSubMapTes
434          try {
435              e.setValue("A");
436              shouldThrow();
437 <        } catch (Exception ok) {
448 <        }
437 >        } catch (UnsupportedOperationException success) {}
438          e = map.pollFirstEntry();
439          assertNull(e);
440      }
# Line 472 | Line 461 | public class ConcurrentSkipListSubMapTes
461          try {
462              e.setValue("E");
463              shouldThrow();
464 <        } catch (Exception ok) {
476 <        }
464 >        } catch (UnsupportedOperationException success) {}
465          e = map.pollLastEntry();
466          assertNull(e);
467      }
468  
469      /**
470 <     *   size returns the correct values
470 >     * size returns the correct values
471       */
472      public void testSize() {
473          ConcurrentNavigableMap map = map5();
# Line 495 | Line 483 | public class ConcurrentSkipListSubMapTes
483          ConcurrentNavigableMap map = map5();
484          String s = map.toString();
485          for (int i = 1; i <= 5; ++i) {
486 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
486 >            assertTrue(s.contains(String.valueOf(i)));
487          }
488      }
489  
# Line 509 | Line 497 | public class ConcurrentSkipListSubMapTes
497              ConcurrentNavigableMap c = map5();
498              c.get(null);
499              shouldThrow();
500 <        } catch (NullPointerException e) {}
500 >        } catch (NullPointerException success) {}
501      }
502  
503      /**
# Line 520 | Line 508 | public class ConcurrentSkipListSubMapTes
508              ConcurrentNavigableMap c = map5();
509              c.containsKey(null);
510              shouldThrow();
511 <        } catch (NullPointerException e) {}
511 >        } catch (NullPointerException success) {}
512      }
513  
514      /**
# Line 531 | Line 519 | public class ConcurrentSkipListSubMapTes
519              ConcurrentNavigableMap c = map0();
520              c.containsValue(null);
521              shouldThrow();
522 <        } catch (NullPointerException e) {}
522 >        } catch (NullPointerException success) {}
523      }
524  
537
525      /**
526       * put(null,x) throws NPE
527       */
# Line 543 | Line 530 | public class ConcurrentSkipListSubMapTes
530              ConcurrentNavigableMap c = map5();
531              c.put(null, "whatever");
532              shouldThrow();
533 <        } catch (NullPointerException e) {}
533 >        } catch (NullPointerException success) {}
534      }
535  
536      /**
# Line 554 | Line 541 | public class ConcurrentSkipListSubMapTes
541              ConcurrentNavigableMap c = map5();
542              c.putIfAbsent(null, "whatever");
543              shouldThrow();
544 <        } catch (NullPointerException e) {}
544 >        } catch (NullPointerException success) {}
545      }
546  
547      /**
# Line 565 | Line 552 | public class ConcurrentSkipListSubMapTes
552              ConcurrentNavigableMap c = map5();
553              c.replace(null, "whatever");
554              shouldThrow();
555 <        } catch (NullPointerException e) {}
555 >        } catch (NullPointerException success) {}
556      }
557  
558      /**
# Line 576 | Line 563 | public class ConcurrentSkipListSubMapTes
563              ConcurrentNavigableMap c = map5();
564              c.replace(null, one, "whatever");
565              shouldThrow();
566 <        } catch (NullPointerException e) {}
566 >        } catch (NullPointerException success) {}
567      }
568  
569      /**
# Line 587 | Line 574 | public class ConcurrentSkipListSubMapTes
574              ConcurrentNavigableMap c = map5();
575              c.remove(null);
576              shouldThrow();
577 <        } catch (NullPointerException e) {}
577 >        } catch (NullPointerException success) {}
578      }
579  
580      /**
# Line 598 | Line 585 | public class ConcurrentSkipListSubMapTes
585              ConcurrentNavigableMap c = map5();
586              c.remove(null, "whatever");
587              shouldThrow();
588 <        } catch (NullPointerException e) {}
588 >        } catch (NullPointerException success) {}
589      }
590  
591      /**
592       * A deserialized map equals original
593       */
594      public void testSerialization() throws Exception {
595 <        ConcurrentNavigableMap q = map5();
595 >        NavigableMap x = map5();
596 >        NavigableMap y = serialClone(x);
597  
598 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
599 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
600 <        out.writeObject(q);
601 <        out.close();
602 <
615 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
616 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
617 <        ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
618 <        assertEquals(q.size(), r.size());
619 <        assertTrue(q.equals(r));
620 <        assertTrue(r.equals(q));
598 >        assertTrue(x != y);
599 >        assertEquals(x.size(), y.size());
600 >        assertEquals(x.toString(), y.toString());
601 >        assertEquals(x, y);
602 >        assertEquals(y, x);
603      }
604  
623
624
605      /**
606       * subMap returns map with keys in requested range
607       */
# Line 651 | Line 631 | public class ConcurrentSkipListSubMapTes
631          assertEquals(1, sm.size());
632          assertEquals(three, sm.firstKey());
633          assertEquals(three, sm.lastKey());
634 <        assertTrue(sm.remove(three) != null);
634 >        assertEquals("C", sm.remove(three));
635          assertTrue(sm.isEmpty());
636          assertEquals(3, map.size());
637      }
# Line 679 | Line 659 | public class ConcurrentSkipListSubMapTes
659          assertEquals(4, map.size());
660          assertEquals(0, sm.size());
661          assertTrue(sm.isEmpty());
662 <        assertTrue(sm.remove(three) == null);
662 >        assertSame(sm.remove(three), null);
663          assertEquals(4, map.size());
664      }
665  
# Line 751 | Line 731 | public class ConcurrentSkipListSubMapTes
731          SortedMap ssm = sm.tailMap(four);
732          assertEquals(four, ssm.firstKey());
733          assertEquals(five, ssm.lastKey());
734 <        assertTrue(ssm.remove(four) != null);
734 >        assertEquals("D", ssm.remove(four));
735          assertEquals(1, ssm.size());
736          assertEquals(3, sm.size());
737          assertEquals(4, map.size());
738      }
739  
740      /**
741 <     *  clear removes all pairs
741 >     * clear removes all pairs
742       */
743      public void testDescendingClear() {
744          ConcurrentNavigableMap map = dmap5();
745          map.clear();
746 <        assertEquals(map.size(), 0);
746 >        assertEquals(0, map.size());
747      }
748  
769
749      /**
750 <     *  Maps with same contents are equal
750 >     * Maps with same contents are equal
751       */
752      public void testDescendingEquals() {
753          ConcurrentNavigableMap map1 = dmap5();
# Line 781 | Line 760 | public class ConcurrentSkipListSubMapTes
760      }
761  
762      /**
763 <     *  containsKey returns true for contained key
763 >     * containsKey returns true for contained key
764       */
765      public void testDescendingContainsKey() {
766          ConcurrentNavigableMap map = dmap5();
# Line 790 | Line 769 | public class ConcurrentSkipListSubMapTes
769      }
770  
771      /**
772 <     *  containsValue returns true for held values
772 >     * containsValue returns true for held values
773       */
774      public void testDescendingContainsValue() {
775          ConcurrentNavigableMap map = dmap5();
# Line 799 | Line 778 | public class ConcurrentSkipListSubMapTes
778      }
779  
780      /**
781 <     *  get returns the correct element at the given key,
782 <     *  or null if not present
781 >     * get returns the correct element at the given key,
782 >     * or null if not present
783       */
784      public void testDescendingGet() {
785          ConcurrentNavigableMap map = dmap5();
# Line 810 | Line 789 | public class ConcurrentSkipListSubMapTes
789      }
790  
791      /**
792 <     *  isEmpty is true of empty map and false for non-empty
792 >     * isEmpty is true of empty map and false for non-empty
793       */
794      public void testDescendingIsEmpty() {
795          ConcurrentNavigableMap empty = dmap0();
# Line 820 | Line 799 | public class ConcurrentSkipListSubMapTes
799      }
800  
801      /**
802 <     *   firstKey returns first key
802 >     * firstKey returns first key
803       */
804      public void testDescendingFirstKey() {
805          ConcurrentNavigableMap map = dmap5();
# Line 828 | Line 807 | public class ConcurrentSkipListSubMapTes
807      }
808  
809      /**
810 <     *   lastKey returns last key
810 >     * lastKey returns last key
811       */
812      public void testDescendingLastKey() {
813          ConcurrentNavigableMap map = dmap5();
814          assertEquals(m5, map.lastKey());
815      }
816  
838
817      /**
818 <     *   keySet returns a Set containing all the keys
818 >     * keySet returns a Set containing all the keys
819       */
820      public void testDescendingKeySet() {
821          ConcurrentNavigableMap map = dmap5();
# Line 851 | Line 829 | public class ConcurrentSkipListSubMapTes
829      }
830  
831      /**
832 <     *   keySet is ordered
832 >     * keySet is ordered
833       */
834      public void testDescendingKeySetOrder() {
835          ConcurrentNavigableMap map = dmap5();
# Line 881 | Line 859 | public class ConcurrentSkipListSubMapTes
859      }
860  
861      /**
862 <     *  keySet.toArray returns contains all keys
862 >     * keySet.toArray returns contains all keys
863       */
864      public void testDescendingAscendingKeySetToArray() {
865          ConcurrentNavigableMap map = dmap5();
# Line 894 | Line 872 | public class ConcurrentSkipListSubMapTes
872      }
873  
874      /**
875 <     *  descendingkeySet.toArray returns contains all keys
875 >     * descendingkeySet.toArray returns contains all keys
876       */
877      public void testDescendingDescendingKeySetToArray() {
878          ConcurrentNavigableMap map = dmap5();
# Line 907 | Line 885 | public class ConcurrentSkipListSubMapTes
885      }
886  
887      /**
888 <     *  Values.toArray contains all values
888 >     * Values.toArray contains all values
889       */
890      public void testDescendingValuesToArray() {
891          ConcurrentNavigableMap map = dmap5();
# Line 922 | Line 900 | public class ConcurrentSkipListSubMapTes
900          assertTrue(s.contains("E"));
901      }
902  
925
903      /**
904       * entrySet contains all pairs
905       */
# Line 943 | Line 920 | public class ConcurrentSkipListSubMapTes
920      }
921  
922      /**
923 <     *   putAll  adds all key-value pairs from the given map
923 >     * putAll adds all key-value pairs from the given map
924       */
925      public void testDescendingPutAll() {
926          ConcurrentNavigableMap empty = dmap0();
# Line 958 | Line 935 | public class ConcurrentSkipListSubMapTes
935      }
936  
937      /**
938 <     *   putIfAbsent works when the given key is not present
938 >     * putIfAbsent works when the given key is not present
939       */
940      public void testDescendingPutIfAbsent() {
941          ConcurrentNavigableMap map = dmap5();
# Line 967 | Line 944 | public class ConcurrentSkipListSubMapTes
944      }
945  
946      /**
947 <     *   putIfAbsent does not add the pair if the key is already present
947 >     * putIfAbsent does not add the pair if the key is already present
948       */
949      public void testDescendingPutIfAbsent2() {
950          ConcurrentNavigableMap map = dmap5();
# Line 975 | Line 952 | public class ConcurrentSkipListSubMapTes
952      }
953  
954      /**
955 <     *   replace fails when the given key is not present
955 >     * replace fails when the given key is not present
956       */
957      public void testDescendingReplace() {
958          ConcurrentNavigableMap map = dmap5();
# Line 984 | Line 961 | public class ConcurrentSkipListSubMapTes
961      }
962  
963      /**
964 <     *   replace succeeds if the key is already present
964 >     * replace succeeds if the key is already present
965       */
966      public void testDescendingReplace2() {
967          ConcurrentNavigableMap map = dmap5();
# Line 992 | Line 969 | public class ConcurrentSkipListSubMapTes
969          assertEquals("Z", map.get(m1));
970      }
971  
995
972      /**
973       * replace value fails when the given key not mapped to expected value
974       */
# Line 1013 | Line 989 | public class ConcurrentSkipListSubMapTes
989          assertEquals("Z", map.get(m1));
990      }
991  
1016
992      /**
993 <     *   remove removes the correct key-value pair from the map
993 >     * remove removes the correct key-value pair from the map
994       */
995      public void testDescendingRemove() {
996          ConcurrentNavigableMap map = dmap5();
# Line 1037 | Line 1012 | public class ConcurrentSkipListSubMapTes
1012          map.remove(m4, "A");
1013          assertEquals(4, map.size());
1014          assertTrue(map.containsKey(m4));
1040
1015      }
1016  
1017      /**
# Line 1056 | Line 1030 | public class ConcurrentSkipListSubMapTes
1030  
1031          Map.Entry e4 = map.lowerEntry(zero);
1032          assertNull(e4);
1059
1033      }
1034  
1035      /**
# Line 1075 | Line 1048 | public class ConcurrentSkipListSubMapTes
1048  
1049          Map.Entry e4 = map.higherEntry(m6);
1050          assertNull(e4);
1078
1051      }
1052  
1053      /**
# Line 1094 | Line 1066 | public class ConcurrentSkipListSubMapTes
1066  
1067          Map.Entry e4 = map.floorEntry(zero);
1068          assertNull(e4);
1097
1069      }
1070  
1071      /**
# Line 1113 | Line 1084 | public class ConcurrentSkipListSubMapTes
1084  
1085          Map.Entry e4 = map.ceilingEntry(m6);
1086          assertNull(e4);
1116
1087      }
1088  
1089      /**
# Line 1138 | Line 1108 | public class ConcurrentSkipListSubMapTes
1108          try {
1109              e.setValue("A");
1110              shouldThrow();
1111 <        } catch (Exception ok) {
1142 <        }
1111 >        } catch (UnsupportedOperationException success) {}
1112          e = map.pollFirstEntry();
1113          assertNull(e);
1114      }
# Line 1166 | Line 1135 | public class ConcurrentSkipListSubMapTes
1135          try {
1136              e.setValue("E");
1137              shouldThrow();
1138 <        } catch (Exception ok) {
1170 <        }
1138 >        } catch (UnsupportedOperationException success) {}
1139          e = map.pollLastEntry();
1140          assertNull(e);
1141      }
1142  
1143      /**
1144 <     *   size returns the correct values
1144 >     * size returns the correct values
1145       */
1146      public void testDescendingSize() {
1147          ConcurrentNavigableMap map = dmap5();
# Line 1189 | Line 1157 | public class ConcurrentSkipListSubMapTes
1157          ConcurrentNavigableMap map = dmap5();
1158          String s = map.toString();
1159          for (int i = 1; i <= 5; ++i) {
1160 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
1160 >            assertTrue(s.contains(String.valueOf(i)));
1161          }
1162      }
1163  
1164      // Exception testDescendings
1165  
1166      /**
1167 <     * get(null) of nm1mpty map throws NPE
1167 >     * get(null) of empty map throws NPE
1168       */
1169      public void testDescendingGet_NullPointerException() {
1170          try {
1171              ConcurrentNavigableMap c = dmap5();
1172              c.get(null);
1173              shouldThrow();
1174 <        } catch (NullPointerException e) {}
1174 >        } catch (NullPointerException success) {}
1175      }
1176  
1177      /**
1178 <     * containsKey(null) of nm1mpty map throws NPE
1178 >     * containsKey(null) of empty map throws NPE
1179       */
1180      public void testDescendingContainsKey_NullPointerException() {
1181          try {
1182              ConcurrentNavigableMap c = dmap5();
1183              c.containsKey(null);
1184              shouldThrow();
1185 <        } catch (NullPointerException e) {}
1185 >        } catch (NullPointerException success) {}
1186      }
1187  
1188      /**
# Line 1225 | Line 1193 | public class ConcurrentSkipListSubMapTes
1193              ConcurrentNavigableMap c = dmap0();
1194              c.containsValue(null);
1195              shouldThrow();
1196 <        } catch (NullPointerException e) {}
1196 >        } catch (NullPointerException success) {}
1197      }
1198  
1231
1199      /**
1200       * put(null,x) throws NPE
1201       */
# Line 1237 | Line 1204 | public class ConcurrentSkipListSubMapTes
1204              ConcurrentNavigableMap c = dmap5();
1205              c.put(null, "whatever");
1206              shouldThrow();
1207 <        } catch (NullPointerException e) {}
1207 >        } catch (NullPointerException success) {}
1208      }
1209  
1210      /**
# Line 1248 | Line 1215 | public class ConcurrentSkipListSubMapTes
1215              ConcurrentNavigableMap c = dmap5();
1216              c.putIfAbsent(null, "whatever");
1217              shouldThrow();
1218 <        } catch (NullPointerException e) {}
1218 >        } catch (NullPointerException success) {}
1219      }
1220  
1221      /**
# Line 1259 | Line 1226 | public class ConcurrentSkipListSubMapTes
1226              ConcurrentNavigableMap c = dmap5();
1227              c.replace(null, "whatever");
1228              shouldThrow();
1229 <        } catch (NullPointerException e) {}
1229 >        } catch (NullPointerException success) {}
1230      }
1231  
1232      /**
# Line 1270 | Line 1237 | public class ConcurrentSkipListSubMapTes
1237              ConcurrentNavigableMap c = dmap5();
1238              c.replace(null, m1, "whatever");
1239              shouldThrow();
1240 <        } catch (NullPointerException e) {}
1240 >        } catch (NullPointerException success) {}
1241      }
1242  
1243      /**
# Line 1281 | Line 1248 | public class ConcurrentSkipListSubMapTes
1248              ConcurrentNavigableMap c = dmap5();
1249              c.remove(null);
1250              shouldThrow();
1251 <        } catch (NullPointerException e) {}
1251 >        } catch (NullPointerException success) {}
1252      }
1253  
1254      /**
# Line 1292 | Line 1259 | public class ConcurrentSkipListSubMapTes
1259              ConcurrentNavigableMap c = dmap5();
1260              c.remove(null, "whatever");
1261              shouldThrow();
1262 <        } catch (NullPointerException e) {}
1262 >        } catch (NullPointerException success) {}
1263      }
1264  
1265      /**
1266       * A deserialized map equals original
1267       */
1268      public void testDescendingSerialization() throws Exception {
1269 <        ConcurrentNavigableMap q = dmap5();
1269 >        NavigableMap x = dmap5();
1270 >        NavigableMap y = serialClone(x);
1271  
1272 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
1273 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
1274 <        out.writeObject(q);
1275 <        out.close();
1276 <
1309 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
1310 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
1311 <        ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
1312 <        assertEquals(q.size(), r.size());
1313 <        assertTrue(q.equals(r));
1314 <        assertTrue(r.equals(q));
1272 >        assertTrue(x != y);
1273 >        assertEquals(x.size(), y.size());
1274 >        assertEquals(x.toString(), y.toString());
1275 >        assertEquals(x, y);
1276 >        assertEquals(y, x);
1277      }
1278  
1317
1279      /**
1280       * subMap returns map with keys in requested range
1281       */
# Line 1344 | Line 1305 | public class ConcurrentSkipListSubMapTes
1305          assertEquals(1, sm.size());
1306          assertEquals(m3, sm.firstKey());
1307          assertEquals(m3, sm.lastKey());
1308 <        assertTrue(sm.remove(m3) != null);
1308 >        assertEquals("C", sm.remove(m3));
1309          assertTrue(sm.isEmpty());
1310          assertEquals(3, map.size());
1311      }
# Line 1372 | Line 1333 | public class ConcurrentSkipListSubMapTes
1333          assertEquals(4, map.size());
1334          assertEquals(0, sm.size());
1335          assertTrue(sm.isEmpty());
1336 <        assertTrue(sm.remove(m3) == null);
1336 >        assertSame(sm.remove(m3), null);
1337          assertEquals(4, map.size());
1338      }
1339  
# Line 1444 | Line 1405 | public class ConcurrentSkipListSubMapTes
1405          SortedMap ssm = sm.tailMap(m4);
1406          assertEquals(m4, ssm.firstKey());
1407          assertEquals(m5, ssm.lastKey());
1408 <        assertTrue(ssm.remove(m4) != null);
1408 >        assertEquals("D", ssm.remove(m4));
1409          assertEquals(1, ssm.size());
1410          assertEquals(3, sm.size());
1411          assertEquals(4, map.size());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines