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

Comparing jsr166/src/test/tck/ConcurrentHashMap8Test.java (file contents):
Revision 1.12 by dl, Sun Jul 21 22:24:18 2013 UTC vs.
Revision 1.14 by jsr166, Mon Jul 22 18:11:56 2013 UTC

# Line 54 | Line 54 | public class ConcurrentHashMap8Test exte
54      }
55  
56      /**
57 <     * computeIfAbsent does not replace  if the key is already present
57 >     * computeIfAbsent does not replace if the key is already present
58       */
59      public void testComputeIfAbsent2() {
60          ConcurrentHashMap map = map5();
# Line 71 | Line 71 | public class ConcurrentHashMap8Test exte
71      }
72  
73      /**
74 <     * computeIfPresent does not replace  if the key is already present
74 >     * computeIfPresent does not replace if the key is already present
75       */
76      public void testComputeIfPresent() {
77          ConcurrentHashMap map = map5();
# Line 88 | Line 88 | public class ConcurrentHashMap8Test exte
88      }
89  
90      /**
91 <     * compute does not replace  if the function returns null
91 >     * compute does not replace if the function returns null
92       */
93      public void testCompute() {
94          ConcurrentHashMap map = map5();
# Line 255 | Line 255 | public class ConcurrentHashMap8Test exte
255          assertTrue(full.contains(three));
256      }
257  
258 +    /**
259 +     * keySet.add throws UnsupportedOperationException if no default
260 +     * mapped value
261 +     */
262 +    public void testAdd4() {
263 +        Set full = map5().keySet();
264 +        try {
265 +            full.add(three);
266 +            shouldThrow();
267 +        } catch (UnsupportedOperationException e){}
268 +    }
269  
270 <      /**
271 <      * keySet.add throws UnsupportedOperationException if no default
272 <      * mapped value
273 <      */
274 <     public void testAdd4() {
275 <         Set full = map5().keySet();
276 <         try {
277 <             full.add(three);
278 <             shouldThrow();
279 <         } catch (UnsupportedOperationException e){}
280 <     }
281 <    
282 <     /**
283 <      * keySet.add throws NullPointerException if the specified key is
284 <      * null
285 <      */
286 <     public void testAdd5() {
287 <         Set full = populatedSet(3);
288 <         try {
289 <             full.add(null);
290 <             shouldThrow();
291 <         } catch (NullPointerException e){}
292 <     }
293 <    
294 <     /**
295 <      * KeySetView.getMappedValue returns the map's mapped value
296 <      */
297 <     public void testGetMappedValue() {
298 <         ConcurrentHashMap map = map5();
299 <         assertNull(map.keySet().getMappedValue());
300 <         try {
301 <             map.keySet(null);
302 <             shouldThrow();
303 <         } catch (NullPointerException e) {}
304 <         KeySetView set = map.keySet(one);
305 <         set.add(one);
306 <         set.add(six);
307 <         set.add(seven);
308 <         assertTrue(set.getMappedValue() == one);
309 <         assertTrue(map.get(one) != one);
310 <         assertTrue(map.get(six) == one);
311 <         assertTrue(map.get(seven) == one);
312 <     }
313 <    
314 <     /**
315 <      * KeySetView.spliterator returns spliterator over the elements in this set
316 <      */
317 <     public void testKeySetSpliterator() {
307 <         LongAdder adder = new LongAdder();
308 <         ConcurrentHashMap map = map5();
309 <         Set set = map.keySet();
310 <         Spliterator<Integer> sp = set.spliterator();
311 <         assertEquals(sp.estimateSize(), map.size());
312 <         Spliterator<Integer> sp2 = sp.trySplit();
313 <         sp.forEachRemaining((Integer x) -> adder.add(x.longValue()));
314 <         long v = adder.sumThenReset();
315 <         sp2.forEachRemaining((Integer x) -> adder.add(x.longValue()));
316 <         long v2 = adder.sum();
317 <         assertEquals(v + v2, 15);
318 <     }
319 <
270 >    /**
271 >     * keySet.add throws NullPointerException if the specified key is
272 >     * null
273 >     */
274 >    public void testAdd5() {
275 >        Set full = populatedSet(3);
276 >        try {
277 >            full.add(null);
278 >            shouldThrow();
279 >        } catch (NullPointerException e){}
280 >    }
281 >
282 >    /**
283 >     * KeySetView.getMappedValue returns the map's mapped value
284 >     */
285 >    public void testGetMappedValue() {
286 >        ConcurrentHashMap map = map5();
287 >        assertNull(map.keySet().getMappedValue());
288 >        try {
289 >            map.keySet(null);
290 >            shouldThrow();
291 >        } catch (NullPointerException e) {}
292 >        KeySetView set = map.keySet(one);
293 >        set.add(one);
294 >        set.add(six);
295 >        set.add(seven);
296 >        assertTrue(set.getMappedValue() == one);
297 >        assertTrue(map.get(one) != one);
298 >        assertTrue(map.get(six) == one);
299 >        assertTrue(map.get(seven) == one);
300 >    }
301 >
302 >    /**
303 >     * KeySetView.spliterator returns spliterator over the elements in this set
304 >     */
305 >    public void testKeySetSpliterator() {
306 >        LongAdder adder = new LongAdder();
307 >        ConcurrentHashMap map = map5();
308 >        Set set = map.keySet();
309 >        Spliterator<Integer> sp = set.spliterator();
310 >        assertEquals(sp.estimateSize(), map.size());
311 >        Spliterator<Integer> sp2 = sp.trySplit();
312 >        sp.forEachRemaining((Integer x) -> adder.add(x.longValue()));
313 >        long v = adder.sumThenReset();
314 >        sp2.forEachRemaining((Integer x) -> adder.add(x.longValue()));
315 >        long v2 = adder.sum();
316 >        assertEquals(v + v2, 15);
317 >    }
318  
319      /**
320       * keyset.clear removes all elements from the set

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines