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.36 by dl, Sun Jul 21 22:24:18 2013 UTC vs.
Revision 1.39 by jsr166, Tue Sep 24 17:26:27 2013 UTC

# Line 103 | Line 103 | public class ConcurrentHashMapTest exten
103       * class are found.
104       */
105      public void testComparableFamily() {
106 +        int size = 500;         // makes measured test run time -> 60ms
107          ConcurrentHashMap<BI, Boolean> m =
108              new ConcurrentHashMap<BI, Boolean>();
109 <        for (int i = 0; i < 1000; i++) {
109 >        for (int i = 0; i < size; i++) {
110              assertTrue(m.put(new CI(i), true) == null);
111          }
112 <        for (int i = 0; i < 1000; i++) {
112 >        for (int i = 0; i < size; i++) {
113              assertTrue(m.containsKey(new CI(i)));
114              assertTrue(m.containsKey(new DI(i)));
115          }
# Line 119 | Line 120 | public class ConcurrentHashMapTest exten
120       * on Comparable can be inserted and found.
121       */
122      public void testGenericComparable() {
123 +        int size = 120;         // makes measured test run time -> 60ms
124          ConcurrentHashMap<Object, Boolean> m =
125              new ConcurrentHashMap<Object, Boolean>();
126 <        for (int i = 0; i < 1000; i++) {
126 >        for (int i = 0; i < size; i++) {
127              BI bi = new BI(i);
128              BS bs = new BS(String.valueOf(i));
129              LexicographicList<BI> bis = new LexicographicList<BI>(bi);
# Line 132 | Line 134 | public class ConcurrentHashMapTest exten
134                  assertTrue(m.containsKey(bss));
135              assertTrue(m.containsKey(bis));
136          }
137 <        for (int i = 0; i < 1000; i++) {
138 <            assertTrue(m.containsKey(new ArrayList(Collections.singleton(new BI(i)))));
137 >        for (int i = 0; i < size; i++) {
138 >            assertTrue(m.containsKey(Collections.singletonList(new BI(i))));
139          }
140      }
141  
# Line 143 | Line 145 | public class ConcurrentHashMapTest exten
145       * inserted and found.
146       */
147      public void testGenericComparable2() {
148 +        int size = 500;         // makes measured test run time -> 60ms
149          ConcurrentHashMap<Object, Boolean> m =
150              new ConcurrentHashMap<Object, Boolean>();
151 <        for (int i = 0; i < 1000; i++) {
152 <            m.put(new ArrayList(Collections.singleton(new BI(i))), true);
151 >        for (int i = 0; i < size; i++) {
152 >            m.put(Collections.singletonList(new BI(i)), true);
153          }
154  
155 <        for (int i = 0; i < 1000; i++) {
155 >        for (int i = 0; i < size; i++) {
156              LexicographicList<BI> bis = new LexicographicList<BI>(new BI(i));
157              assertTrue(m.containsKey(bis));
158          }
# Line 160 | Line 163 | public class ConcurrentHashMapTest exten
163       * can be inserted and found.
164       */
165      public void testMixedComparable() {
166 <        int size = 10000;
166 >        int size = 1200;        // makes measured test run time -> 35ms
167          ConcurrentHashMap<Object, Object> map =
168              new ConcurrentHashMap<Object, Object>();
169 <        Random rng = new Random(1370014958369218000L);
169 >        Random rng = new Random();
170          for (int i = 0; i < size; i++) {
171              Object x;
172              switch (rng.nextInt(4)) {
# Line 212 | Line 215 | public class ConcurrentHashMapTest exten
215          assertFalse(map2.equals(map1));
216      }
217  
215
218      /**
219 <      * hashCode() equals sum of each key.hashCode ^ value.hashCode
220 <      */
219 >     * hashCode() equals sum of each key.hashCode ^ value.hashCode
220 >     */
221      public void testHashCode() {
222          ConcurrentHashMap<Integer,String> map = map5();
223          int sum = 0;
# Line 525 | Line 527 | public class ConcurrentHashMapTest exten
527          try {
528              new ConcurrentHashMap(-1, .75f);
529              shouldThrow();
530 <        } catch (IllegalArgumentException e) {}        
531 <        
530 >        } catch (IllegalArgumentException e) {}
531 >
532          try {
533              new ConcurrentHashMap(16, -1);
534              shouldThrow();
535 <        } catch (IllegalArgumentException e) {}        
535 >        } catch (IllegalArgumentException e) {}
536      }
537 <    
538 <     /**
539 <      * Constructor (initialCapacity, loadFactor, concurrencyLevel)
540 <      * throws IllegalArgumentException if any argument is negative
541 <      */
537 >
538 >    /**
539 >     * Constructor (initialCapacity, loadFactor, concurrencyLevel)
540 >     * throws IllegalArgumentException if any argument is negative
541 >     */
542      public void testConstructor3() {
543 <         try {
544 <             new ConcurrentHashMap(-1, .75f, 1);
545 <             shouldThrow();
546 <         } catch (IllegalArgumentException e) {}        
547 <
548 <         try {
549 <             new ConcurrentHashMap(16, -1, 1);
550 <             shouldThrow();
551 <         } catch (IllegalArgumentException e) {}
552 <        
553 <         try {
554 <             new ConcurrentHashMap(16, .75f, -1);
555 <             shouldThrow();
556 <         } catch (IllegalArgumentException e) {}
557 <     }
543 >        try {
544 >            new ConcurrentHashMap(-1, .75f, 1);
545 >            shouldThrow();
546 >        } catch (IllegalArgumentException e) {}
547 >
548 >        try {
549 >            new ConcurrentHashMap(16, -1, 1);
550 >            shouldThrow();
551 >        } catch (IllegalArgumentException e) {}
552 >
553 >        try {
554 >            new ConcurrentHashMap(16, .75f, -1);
555 >            shouldThrow();
556 >        } catch (IllegalArgumentException e) {}
557 >    }
558  
559      /**
560       * ConcurrentHashMap(map) throws NullPointerException if the given

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines