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.9 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.18 by jsr166, Fri May 27 19:21:27 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.*;
# Line 11 | Line 11 | 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();
# Line 72 | Line 72 | public class ConcurrentSkipListSubMapTes
72          assertEquals(map.size(), 0);
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() {
594 >    public void testSerialization() throws Exception {
595          ConcurrentNavigableMap q = map5();
596  
597 <        try {
598 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
599 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
600 <            out.writeObject(q);
601 <            out.close();
602 <
603 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
604 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
605 <            ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
606 <            assertEquals(q.size(), r.size());
607 <            assertTrue(q.equals(r));
621 <            assertTrue(r.equals(q));
622 <        } catch (Exception e) {
623 <            e.printStackTrace();
624 <            unexpectedException();
625 <        }
597 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
598 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
599 >        out.writeObject(q);
600 >        out.close();
601 >
602 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
603 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
604 >        ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
605 >        assertEquals(q.size(), r.size());
606 >        assertTrue(q.equals(r));
607 >        assertTrue(r.equals(q));
608      }
609  
628
629
610      /**
611       * subMap returns map with keys in requested range
612       */
# Line 656 | Line 636 | public class ConcurrentSkipListSubMapTes
636          assertEquals(1, sm.size());
637          assertEquals(three, sm.firstKey());
638          assertEquals(three, sm.lastKey());
639 <        assertTrue(sm.remove(three) != null);
639 >        assertEquals("C", sm.remove(three));
640          assertTrue(sm.isEmpty());
641          assertEquals(3, map.size());
642      }
# Line 684 | Line 664 | public class ConcurrentSkipListSubMapTes
664          assertEquals(4, map.size());
665          assertEquals(0, sm.size());
666          assertTrue(sm.isEmpty());
667 <        assertTrue(sm.remove(three) == null);
667 >        assertSame(sm.remove(three), null);
668          assertEquals(4, map.size());
669      }
670  
# Line 756 | Line 736 | public class ConcurrentSkipListSubMapTes
736          SortedMap ssm = sm.tailMap(four);
737          assertEquals(four, ssm.firstKey());
738          assertEquals(five, ssm.lastKey());
739 <        assertTrue(ssm.remove(four) != null);
739 >        assertEquals("D", ssm.remove(four));
740          assertEquals(1, ssm.size());
741          assertEquals(3, sm.size());
742          assertEquals(4, map.size());
743      }
744  
745      /**
746 <     *  clear removes all pairs
746 >     * clear removes all pairs
747       */
748      public void testDescendingClear() {
749          ConcurrentNavigableMap map = dmap5();
# Line 771 | Line 751 | public class ConcurrentSkipListSubMapTes
751          assertEquals(map.size(), 0);
752      }
753  
774
754      /**
755 <     *  Maps with same contents are equal
755 >     * Maps with same contents are equal
756       */
757      public void testDescendingEquals() {
758          ConcurrentNavigableMap map1 = dmap5();
# Line 786 | Line 765 | public class ConcurrentSkipListSubMapTes
765      }
766  
767      /**
768 <     *  containsKey returns true for contained key
768 >     * containsKey returns true for contained key
769       */
770      public void testDescendingContainsKey() {
771          ConcurrentNavigableMap map = dmap5();
# Line 795 | Line 774 | public class ConcurrentSkipListSubMapTes
774      }
775  
776      /**
777 <     *  containsValue returns true for held values
777 >     * containsValue returns true for held values
778       */
779      public void testDescendingContainsValue() {
780          ConcurrentNavigableMap map = dmap5();
# Line 804 | Line 783 | public class ConcurrentSkipListSubMapTes
783      }
784  
785      /**
786 <     *  get returns the correct element at the given key,
787 <     *  or null if not present
786 >     * get returns the correct element at the given key,
787 >     * or null if not present
788       */
789      public void testDescendingGet() {
790          ConcurrentNavigableMap map = dmap5();
# Line 815 | Line 794 | public class ConcurrentSkipListSubMapTes
794      }
795  
796      /**
797 <     *  isEmpty is true of empty map and false for non-empty
797 >     * isEmpty is true of empty map and false for non-empty
798       */
799      public void testDescendingIsEmpty() {
800          ConcurrentNavigableMap empty = dmap0();
# Line 825 | Line 804 | public class ConcurrentSkipListSubMapTes
804      }
805  
806      /**
807 <     *   firstKey returns first key
807 >     * firstKey returns first key
808       */
809      public void testDescendingFirstKey() {
810          ConcurrentNavigableMap map = dmap5();
# Line 833 | Line 812 | public class ConcurrentSkipListSubMapTes
812      }
813  
814      /**
815 <     *   lastKey returns last key
815 >     * lastKey returns last key
816       */
817      public void testDescendingLastKey() {
818          ConcurrentNavigableMap map = dmap5();
819          assertEquals(m5, map.lastKey());
820      }
821  
843
822      /**
823 <     *   keySet returns a Set containing all the keys
823 >     * keySet returns a Set containing all the keys
824       */
825      public void testDescendingKeySet() {
826          ConcurrentNavigableMap map = dmap5();
# Line 856 | Line 834 | public class ConcurrentSkipListSubMapTes
834      }
835  
836      /**
837 <     *   keySet is ordered
837 >     * keySet is ordered
838       */
839      public void testDescendingKeySetOrder() {
840          ConcurrentNavigableMap map = dmap5();
# Line 886 | Line 864 | public class ConcurrentSkipListSubMapTes
864      }
865  
866      /**
867 <     *  keySet.toArray returns contains all keys
867 >     * keySet.toArray returns contains all keys
868       */
869      public void testDescendingAscendingKeySetToArray() {
870          ConcurrentNavigableMap map = dmap5();
# Line 899 | Line 877 | public class ConcurrentSkipListSubMapTes
877      }
878  
879      /**
880 <     *  descendingkeySet.toArray returns contains all keys
880 >     * descendingkeySet.toArray returns contains all keys
881       */
882      public void testDescendingDescendingKeySetToArray() {
883          ConcurrentNavigableMap map = dmap5();
# Line 912 | Line 890 | public class ConcurrentSkipListSubMapTes
890      }
891  
892      /**
893 <     *  Values.toArray contains all values
893 >     * Values.toArray contains all values
894       */
895      public void testDescendingValuesToArray() {
896          ConcurrentNavigableMap map = dmap5();
# Line 927 | Line 905 | public class ConcurrentSkipListSubMapTes
905          assertTrue(s.contains("E"));
906      }
907  
930
908      /**
909       * entrySet contains all pairs
910       */
# Line 948 | Line 925 | public class ConcurrentSkipListSubMapTes
925      }
926  
927      /**
928 <     *   putAll  adds all key-value pairs from the given map
928 >     * putAll adds all key-value pairs from the given map
929       */
930      public void testDescendingPutAll() {
931          ConcurrentNavigableMap empty = dmap0();
# Line 963 | Line 940 | public class ConcurrentSkipListSubMapTes
940      }
941  
942      /**
943 <     *   putIfAbsent works when the given key is not present
943 >     * putIfAbsent works when the given key is not present
944       */
945      public void testDescendingPutIfAbsent() {
946          ConcurrentNavigableMap map = dmap5();
# Line 972 | Line 949 | public class ConcurrentSkipListSubMapTes
949      }
950  
951      /**
952 <     *   putIfAbsent does not add the pair if the key is already present
952 >     * putIfAbsent does not add the pair if the key is already present
953       */
954      public void testDescendingPutIfAbsent2() {
955          ConcurrentNavigableMap map = dmap5();
# Line 980 | Line 957 | public class ConcurrentSkipListSubMapTes
957      }
958  
959      /**
960 <     *   replace fails when the given key is not present
960 >     * replace fails when the given key is not present
961       */
962      public void testDescendingReplace() {
963          ConcurrentNavigableMap map = dmap5();
# Line 989 | Line 966 | public class ConcurrentSkipListSubMapTes
966      }
967  
968      /**
969 <     *   replace succeeds if the key is already present
969 >     * replace succeeds if the key is already present
970       */
971      public void testDescendingReplace2() {
972          ConcurrentNavigableMap map = dmap5();
# Line 997 | Line 974 | public class ConcurrentSkipListSubMapTes
974          assertEquals("Z", map.get(m1));
975      }
976  
1000
977      /**
978       * replace value fails when the given key not mapped to expected value
979       */
# Line 1018 | Line 994 | public class ConcurrentSkipListSubMapTes
994          assertEquals("Z", map.get(m1));
995      }
996  
1021
997      /**
998 <     *   remove removes the correct key-value pair from the map
998 >     * remove removes the correct key-value pair from the map
999       */
1000      public void testDescendingRemove() {
1001          ConcurrentNavigableMap map = dmap5();
# Line 1042 | Line 1017 | public class ConcurrentSkipListSubMapTes
1017          map.remove(m4, "A");
1018          assertEquals(4, map.size());
1019          assertTrue(map.containsKey(m4));
1045
1020      }
1021  
1022      /**
# Line 1061 | Line 1035 | public class ConcurrentSkipListSubMapTes
1035  
1036          Map.Entry e4 = map.lowerEntry(zero);
1037          assertNull(e4);
1064
1038      }
1039  
1040      /**
# Line 1080 | Line 1053 | public class ConcurrentSkipListSubMapTes
1053  
1054          Map.Entry e4 = map.higherEntry(m6);
1055          assertNull(e4);
1083
1056      }
1057  
1058      /**
# Line 1099 | Line 1071 | public class ConcurrentSkipListSubMapTes
1071  
1072          Map.Entry e4 = map.floorEntry(zero);
1073          assertNull(e4);
1102
1074      }
1075  
1076      /**
# Line 1118 | Line 1089 | public class ConcurrentSkipListSubMapTes
1089  
1090          Map.Entry e4 = map.ceilingEntry(m6);
1091          assertNull(e4);
1121
1092      }
1093  
1094      /**
# Line 1143 | Line 1113 | public class ConcurrentSkipListSubMapTes
1113          try {
1114              e.setValue("A");
1115              shouldThrow();
1116 <        } catch (Exception ok) {
1147 <        }
1116 >        } catch (UnsupportedOperationException success) {}
1117          e = map.pollFirstEntry();
1118          assertNull(e);
1119      }
# Line 1171 | Line 1140 | public class ConcurrentSkipListSubMapTes
1140          try {
1141              e.setValue("E");
1142              shouldThrow();
1143 <        } catch (Exception ok) {
1175 <        }
1143 >        } catch (UnsupportedOperationException success) {}
1144          e = map.pollLastEntry();
1145          assertNull(e);
1146      }
1147  
1148      /**
1149 <     *   size returns the correct values
1149 >     * size returns the correct values
1150       */
1151      public void testDescendingSize() {
1152          ConcurrentNavigableMap map = dmap5();
# Line 1194 | Line 1162 | public class ConcurrentSkipListSubMapTes
1162          ConcurrentNavigableMap map = dmap5();
1163          String s = map.toString();
1164          for (int i = 1; i <= 5; ++i) {
1165 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
1165 >            assertTrue(s.contains(String.valueOf(i)));
1166          }
1167      }
1168  
1169      // Exception testDescendings
1170  
1171      /**
1172 <     * get(null) of nm1mpty map throws NPE
1172 >     * get(null) of empty map throws NPE
1173       */
1174      public void testDescendingGet_NullPointerException() {
1175          try {
1176              ConcurrentNavigableMap c = dmap5();
1177              c.get(null);
1178              shouldThrow();
1179 <        } catch (NullPointerException e) {}
1179 >        } catch (NullPointerException success) {}
1180      }
1181  
1182      /**
1183 <     * containsKey(null) of nm1mpty map throws NPE
1183 >     * containsKey(null) of empty map throws NPE
1184       */
1185      public void testDescendingContainsKey_NullPointerException() {
1186          try {
1187              ConcurrentNavigableMap c = dmap5();
1188              c.containsKey(null);
1189              shouldThrow();
1190 <        } catch (NullPointerException e) {}
1190 >        } catch (NullPointerException success) {}
1191      }
1192  
1193      /**
# Line 1230 | Line 1198 | public class ConcurrentSkipListSubMapTes
1198              ConcurrentNavigableMap c = dmap0();
1199              c.containsValue(null);
1200              shouldThrow();
1201 <        } catch (NullPointerException e) {}
1201 >        } catch (NullPointerException success) {}
1202      }
1203  
1236
1204      /**
1205       * put(null,x) throws NPE
1206       */
# Line 1242 | Line 1209 | public class ConcurrentSkipListSubMapTes
1209              ConcurrentNavigableMap c = dmap5();
1210              c.put(null, "whatever");
1211              shouldThrow();
1212 <        } catch (NullPointerException e) {}
1212 >        } catch (NullPointerException success) {}
1213      }
1214  
1215      /**
# Line 1253 | Line 1220 | public class ConcurrentSkipListSubMapTes
1220              ConcurrentNavigableMap c = dmap5();
1221              c.putIfAbsent(null, "whatever");
1222              shouldThrow();
1223 <        } catch (NullPointerException e) {}
1223 >        } catch (NullPointerException success) {}
1224      }
1225  
1226      /**
# Line 1264 | Line 1231 | public class ConcurrentSkipListSubMapTes
1231              ConcurrentNavigableMap c = dmap5();
1232              c.replace(null, "whatever");
1233              shouldThrow();
1234 <        } catch (NullPointerException e) {}
1234 >        } catch (NullPointerException success) {}
1235      }
1236  
1237      /**
# Line 1275 | Line 1242 | public class ConcurrentSkipListSubMapTes
1242              ConcurrentNavigableMap c = dmap5();
1243              c.replace(null, m1, "whatever");
1244              shouldThrow();
1245 <        } catch (NullPointerException e) {}
1245 >        } catch (NullPointerException success) {}
1246      }
1247  
1248      /**
# Line 1286 | Line 1253 | public class ConcurrentSkipListSubMapTes
1253              ConcurrentNavigableMap c = dmap5();
1254              c.remove(null);
1255              shouldThrow();
1256 <        } catch (NullPointerException e) {}
1256 >        } catch (NullPointerException success) {}
1257      }
1258  
1259      /**
# Line 1297 | Line 1264 | public class ConcurrentSkipListSubMapTes
1264              ConcurrentNavigableMap c = dmap5();
1265              c.remove(null, "whatever");
1266              shouldThrow();
1267 <        } catch (NullPointerException e) {}
1267 >        } catch (NullPointerException success) {}
1268      }
1269  
1270      /**
1271       * A deserialized map equals original
1272       */
1273 <    public void testDescendingSerialization() {
1273 >    public void testDescendingSerialization() throws Exception {
1274          ConcurrentNavigableMap q = dmap5();
1275  
1276 <        try {
1277 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
1278 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
1279 <            out.writeObject(q);
1280 <            out.close();
1281 <
1282 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
1283 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
1284 <            ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
1285 <            assertEquals(q.size(), r.size());
1286 <            assertTrue(q.equals(r));
1320 <            assertTrue(r.equals(q));
1321 <        } catch (Exception e) {
1322 <            e.printStackTrace();
1323 <            unexpectedException();
1324 <        }
1276 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
1277 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
1278 >        out.writeObject(q);
1279 >        out.close();
1280 >
1281 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
1282 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
1283 >        ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
1284 >        assertEquals(q.size(), r.size());
1285 >        assertTrue(q.equals(r));
1286 >        assertTrue(r.equals(q));
1287      }
1288  
1327
1328
1289      /**
1290       * subMap returns map with keys in requested range
1291       */
# Line 1355 | Line 1315 | public class ConcurrentSkipListSubMapTes
1315          assertEquals(1, sm.size());
1316          assertEquals(m3, sm.firstKey());
1317          assertEquals(m3, sm.lastKey());
1318 <        assertTrue(sm.remove(m3) != null);
1318 >        assertEquals("C", sm.remove(m3));
1319          assertTrue(sm.isEmpty());
1320          assertEquals(3, map.size());
1321      }
# Line 1383 | Line 1343 | public class ConcurrentSkipListSubMapTes
1343          assertEquals(4, map.size());
1344          assertEquals(0, sm.size());
1345          assertTrue(sm.isEmpty());
1346 <        assertTrue(sm.remove(m3) == null);
1346 >        assertSame(sm.remove(m3), null);
1347          assertEquals(4, map.size());
1348      }
1349  
# Line 1455 | Line 1415 | public class ConcurrentSkipListSubMapTes
1415          SortedMap ssm = sm.tailMap(m4);
1416          assertEquals(m4, ssm.firstKey());
1417          assertEquals(m5, ssm.lastKey());
1418 <        assertTrue(ssm.remove(m4) != null);
1418 >        assertEquals("D", ssm.remove(m4));
1419          assertEquals(1, ssm.size());
1420          assertEquals(3, sm.size());
1421          assertEquals(4, map.size());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines