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.13 by jsr166, Mon Jul 22 15:55:43 2013 UTC

# 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 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 <      * keySet.add throws UnsupportedOperationException if no default
284 <      * mapped value
285 <      */
286 <     public void testAdd4() {
287 <         Set full = map5().keySet();
288 <         try {
289 <             full.add(three);
290 <             shouldThrow();
291 <         } catch (UnsupportedOperationException e){}
292 <     }
293 <    
294 <     /**
295 <      * keySet.add throws NullPointerException if the specified key is
296 <      * null
297 <      */
298 <     public void testAdd5() {
299 <         Set full = populatedSet(3);
300 <         try {
301 <             full.add(null);
302 <             shouldThrow();
303 <         } catch (NullPointerException e){}
304 <     }
305 <    
306 <     /**
307 <      * KeySetView.getMappedValue returns the map's mapped value
308 <      */
309 <     public void testGetMappedValue() {
310 <         ConcurrentHashMap map = map5();
311 <         assertNull(map.keySet().getMappedValue());
312 <         try {
313 <             map.keySet(null);
314 <             shouldThrow();
315 <         } catch (NullPointerException e) {}
316 <         KeySetView set = map.keySet(one);
317 <         set.add(one);
295 <         set.add(six);
296 <         set.add(seven);
297 <         assertTrue(set.getMappedValue() == one);
298 <         assertTrue(map.get(one) != one);
299 <         assertTrue(map.get(six) == one);
300 <         assertTrue(map.get(seven) == one);
301 <     }
302 <    
303 <     /**
304 <      * KeySetView.spliterator returns spliterator over the elements in this set
305 <      */
306 <     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 <
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