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.66 by jsr166, Wed Jan 27 02:55:18 2021 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines