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

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.64 by jsr166, Tue Jan 26 18:03:27 2021 UTC vs.
Revision 1.65 by jsr166, Wed Jan 27 01:57:24 2021 UTC

# Line 288 | Line 288 | public class ConcurrentHashMapTest exten
288      public void testGet() {
289          ConcurrentHashMap<Item,String> map = map5();
290          mustEqual("A", map.get(one));
291 <        ConcurrentHashMap<Item,String> empty = new ConcurrentHashMap<Item,String>();
291 >        ConcurrentHashMap<Item,String> empty = new ConcurrentHashMap<>();
292          assertNull(map.get("anything"));
293          assertNull(empty.get("anything"));
294      }
# Line 297 | Line 297 | public class ConcurrentHashMapTest exten
297       * isEmpty is true of empty map and false for non-empty
298       */
299      public void testIsEmpty() {
300 <        ConcurrentHashMap<Item,String> empty = new ConcurrentHashMap<Item,String>();
300 >        ConcurrentHashMap<Item,String> empty = new ConcurrentHashMap<>();
301          ConcurrentHashMap<Item,String> map = map5();
302          assertTrue(empty.isEmpty());
303          assertFalse(map.isEmpty());
# Line 366 | Line 366 | public class ConcurrentHashMapTest exten
366          ConcurrentHashMap<Item,String> map = map5();
367          Collection<String> v = map.values();
368          String[] ar = v.toArray(new String[0]);
369 <        ArrayList<String> s = new ArrayList<String>(Arrays.asList(ar));
369 >        ArrayList<String> s = new ArrayList<>(Arrays.asList(ar));
370          mustEqual(5, ar.length);
371          assertTrue(s.contains("A"));
372          assertTrue(s.contains("B"));
# Line 426 | Line 426 | public class ConcurrentHashMapTest exten
426       * putAll adds all key-value pairs from the given map
427       */
428      public void testPutAll() {
429 <        ConcurrentHashMap<Item,String> p = new ConcurrentHashMap<Item,String>();
429 >        ConcurrentHashMap<Item,String> p = new ConcurrentHashMap<>();
430          ConcurrentHashMap<Item,String> map = map5();
431          p.putAll(map);
432          mustEqual(5, p.size());
# Line 520 | Line 520 | public class ConcurrentHashMapTest exten
520       */
521      public void testSize() {
522          ConcurrentHashMap<Item,String> map = map5();
523 <        ConcurrentHashMap<Item,String> empty = new ConcurrentHashMap<Item,String>();
523 >        ConcurrentHashMap<Item,String> empty = new ConcurrentHashMap<>();
524          mustEqual(0, empty.size());
525          mustEqual(5, map.size());
526      }
# Line 602 | Line 602 | public class ConcurrentHashMapTest exten
602       */
603      public void testConstructor5() {
604          ConcurrentHashMap<Item,String> map1 = map5();
605 <        ConcurrentHashMap<Item,String> map2 = new ConcurrentHashMap<Item,String>(map1);
605 >        ConcurrentHashMap<Item,String> map2 = new ConcurrentHashMap<>(map1);
606          assertTrue(map2.equals(map1));
607          map2.put(one, "F");
608          assertFalse(map2.equals(map1));
# Line 612 | Line 612 | public class ConcurrentHashMapTest exten
612       * get(null) throws NPE
613       */
614      public void testGet_NullPointerException() {
615 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
615 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
616          try {
617              c.get(null);
618              shouldThrow();
# Line 623 | Line 623 | public class ConcurrentHashMapTest exten
623       * containsKey(null) throws NPE
624       */
625      public void testContainsKey_NullPointerException() {
626 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
626 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
627          try {
628              c.containsKey(null);
629              shouldThrow();
# Line 634 | Line 634 | public class ConcurrentHashMapTest exten
634       * containsValue(null) throws NPE
635       */
636      public void testContainsValue_NullPointerException() {
637 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
637 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
638          try {
639              c.containsValue(null);
640              shouldThrow();
# Line 645 | Line 645 | public class ConcurrentHashMapTest exten
645       * contains(null) throws NPE
646       */
647      public void testContains_NullPointerException() {
648 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
648 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
649          try {
650              c.contains(null);
651              shouldThrow();
# Line 656 | Line 656 | public class ConcurrentHashMapTest exten
656       * put(null,x) throws NPE
657       */
658      public void testPut1_NullPointerException() {
659 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
659 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
660          try {
661              c.put(null, "whatever");
662              shouldThrow();
# Line 667 | Line 667 | public class ConcurrentHashMapTest exten
667       * put(x, null) throws NPE
668       */
669      public void testPut2_NullPointerException() {
670 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
670 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
671          try {
672              c.put(zero, null);
673              shouldThrow();
# Line 678 | Line 678 | public class ConcurrentHashMapTest exten
678       * putIfAbsent(null, x) throws NPE
679       */
680      public void testPutIfAbsent1_NullPointerException() {
681 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
681 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
682          try {
683              c.putIfAbsent(null, "whatever");
684              shouldThrow();
# Line 689 | Line 689 | public class ConcurrentHashMapTest exten
689       * replace(null, x) throws NPE
690       */
691      public void testReplace_NullPointerException() {
692 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
692 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
693          try {
694              c.replace(null, "whatever");
695              shouldThrow();
# Line 700 | Line 700 | public class ConcurrentHashMapTest exten
700       * replace(null, x, y) throws NPE
701       */
702      public void testReplaceValue_NullPointerException() {
703 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
703 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
704          try {
705              c.replace(null, "A", "B");
706              shouldThrow();
# Line 711 | Line 711 | public class ConcurrentHashMapTest exten
711       * putIfAbsent(x, null) throws NPE
712       */
713      public void testPutIfAbsent2_NullPointerException() {
714 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
714 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
715          try {
716              c.putIfAbsent(zero, null);
717              shouldThrow();
# Line 722 | Line 722 | public class ConcurrentHashMapTest exten
722       * replace(x, null) throws NPE
723       */
724      public void testReplace2_NullPointerException() {
725 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
725 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
726          try {
727              c.replace(one, null);
728              shouldThrow();
# Line 733 | Line 733 | public class ConcurrentHashMapTest exten
733       * replace(x, null, y) throws NPE
734       */
735      public void testReplaceValue2_NullPointerException() {
736 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
736 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
737          try {
738              c.replace(one, null, "A");
739              shouldThrow();
# Line 744 | Line 744 | public class ConcurrentHashMapTest exten
744       * replace(x, y, null) throws NPE
745       */
746      public void testReplaceValue3_NullPointerException() {
747 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
747 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
748          try {
749              c.replace(zero, "A", null);
750              shouldThrow();
# Line 755 | Line 755 | public class ConcurrentHashMapTest exten
755       * remove(null) throws NPE
756       */
757      public void testRemove1_NullPointerException() {
758 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
758 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
759          c.put(one, "asdads");
760          try {
761              c.remove(null);
# Line 767 | Line 767 | public class ConcurrentHashMapTest exten
767       * remove(null, x) throws NPE
768       */
769      public void testRemove2_NullPointerException() {
770 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
770 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
771          c.put(one, "asdads");
772          try {
773              c.remove(null, "whatever");
# Line 779 | Line 779 | public class ConcurrentHashMapTest exten
779       * remove(x, null) returns false
780       */
781      public void testRemove3() {
782 <        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<Item,String>(5);
782 >        ConcurrentHashMap<Item,String> c = new ConcurrentHashMap<>(5);
783          c.put(one, "asdads");
784          assertFalse(c.remove(one, null));
785      }
# Line 803 | Line 803 | public class ConcurrentHashMapTest exten
803      @SuppressWarnings("unchecked")
804      public void testSetValueWriteThrough() {
805          // Adapted from a bug report by Eric Zoerner
806 <        ConcurrentHashMap<Object,Object> map = new ConcurrentHashMap<Object,Object>(2, 5.0f, 1);
806 >        ConcurrentHashMap<Object,Object> map = new ConcurrentHashMap<>(2, 5.0f, 1);
807          assertTrue(map.isEmpty());
808          for (int i = 0; i < 20; i++)
809              map.put(itemFor(i), itemFor(i));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines