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

Comparing jsr166/src/test/tck/ConcurrentSkipListMapTest.java (file contents):
Revision 1.34 by jsr166, Wed Dec 31 21:45:16 2014 UTC vs.
Revision 1.41 by jsr166, Wed Aug 23 05:33:00 2017 UTC

# Line 18 | Line 18 | import java.util.Set;
18   import java.util.concurrent.ConcurrentSkipListMap;
19  
20   import junit.framework.Test;
21 import junit.framework.TestSuite;
21  
22   public class ConcurrentSkipListMapTest extends JSR166TestCase {
23      public static void main(String[] args) {
24 <        junit.textui.TestRunner.run(suite());
24 >        main(suite(), args);
25      }
26      public static Test suite() {
27 <        return new TestSuite(ConcurrentSkipListMapTest.class);
27 >        class Implementation implements MapImplementation {
28 >            public Class<?> klazz() { return ConcurrentSkipListMap.class; }
29 >            public Map emptyMap() { return new ConcurrentSkipListMap(); }
30 >            public Object makeKey(int i) { return i; }
31 >            public Object makeValue(int i) { return i; }
32 >            public boolean isConcurrent() { return true; }
33 >            public boolean permitsNullKeys() { return false; }
34 >            public boolean permitsNullValues() { return false; }
35 >            public boolean supportsSetValue() { return false; }
36 >        }
37 >        return newTestSuite(
38 >            ConcurrentSkipListMapTest.class,
39 >            MapTest.testSuite(new Implementation()));
40      }
41  
42      /**
# Line 694 | Line 705 | public class ConcurrentSkipListMapTest e
705       * get(null) of nonempty map throws NPE
706       */
707      public void testGet_NullPointerException() {
708 +        ConcurrentSkipListMap c = map5();
709          try {
698            ConcurrentSkipListMap c = map5();
710              c.get(null);
711              shouldThrow();
712          } catch (NullPointerException success) {}
# Line 705 | Line 716 | public class ConcurrentSkipListMapTest e
716       * containsKey(null) of nonempty map throws NPE
717       */
718      public void testContainsKey_NullPointerException() {
719 +        ConcurrentSkipListMap c = map5();
720          try {
709            ConcurrentSkipListMap c = map5();
721              c.containsKey(null);
722              shouldThrow();
723          } catch (NullPointerException success) {}
# Line 716 | Line 727 | public class ConcurrentSkipListMapTest e
727       * containsValue(null) throws NPE
728       */
729      public void testContainsValue_NullPointerException() {
730 +        ConcurrentSkipListMap c = new ConcurrentSkipListMap();
731          try {
720            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
732              c.containsValue(null);
733              shouldThrow();
734          } catch (NullPointerException success) {}
# Line 727 | Line 738 | public class ConcurrentSkipListMapTest e
738       * put(null,x) throws NPE
739       */
740      public void testPut1_NullPointerException() {
741 +        ConcurrentSkipListMap c = map5();
742          try {
731            ConcurrentSkipListMap c = map5();
743              c.put(null, "whatever");
744              shouldThrow();
745          } catch (NullPointerException success) {}
# Line 738 | Line 749 | public class ConcurrentSkipListMapTest e
749       * putIfAbsent(null, x) throws NPE
750       */
751      public void testPutIfAbsent1_NullPointerException() {
752 +        ConcurrentSkipListMap c = map5();
753          try {
742            ConcurrentSkipListMap c = map5();
754              c.putIfAbsent(null, "whatever");
755              shouldThrow();
756          } catch (NullPointerException success) {}
# Line 749 | Line 760 | public class ConcurrentSkipListMapTest e
760       * replace(null, x) throws NPE
761       */
762      public void testReplace_NullPointerException() {
763 +        ConcurrentSkipListMap c = map5();
764          try {
753            ConcurrentSkipListMap c = map5();
765              c.replace(null, "whatever");
766              shouldThrow();
767          } catch (NullPointerException success) {}
# Line 760 | Line 771 | public class ConcurrentSkipListMapTest e
771       * replace(null, x, y) throws NPE
772       */
773      public void testReplaceValue_NullPointerException() {
774 +        ConcurrentSkipListMap c = map5();
775          try {
764            ConcurrentSkipListMap c = map5();
776              c.replace(null, one, "whatever");
777              shouldThrow();
778          } catch (NullPointerException success) {}
# Line 771 | Line 782 | public class ConcurrentSkipListMapTest e
782       * remove(null) throws NPE
783       */
784      public void testRemove1_NullPointerException() {
785 +        ConcurrentSkipListMap c = new ConcurrentSkipListMap();
786 +        c.put("sadsdf", "asdads");
787          try {
775            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
776            c.put("sadsdf", "asdads");
788              c.remove(null);
789              shouldThrow();
790          } catch (NullPointerException success) {}
# Line 783 | Line 794 | public class ConcurrentSkipListMapTest e
794       * remove(null, x) throws NPE
795       */
796      public void testRemove2_NullPointerException() {
797 +        ConcurrentSkipListMap c = new ConcurrentSkipListMap();
798 +        c.put("sadsdf", "asdads");
799          try {
787            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
788            c.put("sadsdf", "asdads");
800              c.remove(null, "whatever");
801              shouldThrow();
802          } catch (NullPointerException success) {}
# Line 801 | Line 812 | public class ConcurrentSkipListMapTest e
812      }
813  
814      /**
815 <     * A deserialized map equals original
815 >     * A cloned map equals original
816 >     */
817 >    public void testClone() {
818 >        ConcurrentSkipListMap x = map5();
819 >        ConcurrentSkipListMap y = x.clone();
820 >
821 >        assertNotSame(x, y);
822 >        assertEquals(x.size(), y.size());
823 >        assertEquals(x.toString(), y.toString());
824 >        assertEquals(x, y);
825 >        assertEquals(y, x);
826 >        y.clear();
827 >        assertTrue(y.isEmpty());
828 >        assertFalse(x.equals(y));
829 >    }
830 >
831 >    /**
832 >     * A deserialized/reserialized map equals original
833       */
834      public void testSerialization() throws Exception {
835          NavigableMap x = map5();
# Line 812 | Line 840 | public class ConcurrentSkipListMapTest e
840          assertEquals(x.toString(), y.toString());
841          assertEquals(x, y);
842          assertEquals(y, x);
843 +        y.clear();
844 +        assertTrue(y.isEmpty());
845 +        assertFalse(x.equals(y));
846      }
847  
848      /**
# Line 997 | Line 1028 | public class ConcurrentSkipListMapTest e
1028  
1029      static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception {
1030          NavigableMap<Integer, Integer> result =
1031 <            (NavigableMap<Integer, Integer>) cl.newInstance();
1031 >            (NavigableMap<Integer, Integer>) cl.getConstructor().newInstance();
1032          assertEquals(0, result.size());
1033          assertFalse(result.keySet().iterator().hasNext());
1034          return result;
# Line 1273 | Line 1304 | public class ConcurrentSkipListMapTest e
1304      }
1305  
1306      static boolean eq(Integer i, int j) {
1307 <        return i == null ? j == -1 : i == j;
1307 >        return (i == null) ? j == -1 : i == j;
1308      }
1309  
1310   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines