--- jsr166/src/test/tck/ConcurrentHashMap8Test.java 2013/12/01 12:19:59 1.17 +++ jsr166/src/test/tck/ConcurrentHashMap8Test.java 2015/01/15 18:34:19 1.21 @@ -4,13 +4,26 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import junit.framework.*; -import java.util.*; -import static java.util.Spliterator.*; -import java.util.function.*; -import java.util.concurrent.atomic.LongAdder; +import static java.util.Spliterator.CONCURRENT; +import static java.util.Spliterator.DISTINCT; +import static java.util.Spliterator.NONNULL; + +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.Spliterator; +import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentHashMap.KeySetView; +import java.util.concurrent.atomic.LongAdder; +import java.util.function.BiFunction; + +import junit.framework.Test; +import junit.framework.TestSuite; public class ConcurrentHashMap8Test extends JSR166TestCase { public static void main(String[] args) { @@ -167,12 +180,12 @@ public class ConcurrentHashMap8Test exte return a; } - /* + /** * replaceAll replaces all matching values. */ public void testReplaceAll() { ConcurrentHashMap map = map5(); - map.replaceAll((x, y) -> {return x > 3 ? "Z" : y;}); + map.replaceAll((x, y) -> { return x > 3 ? "Z" : y; }); assertEquals("A", map.get(one)); assertEquals("B", map.get(two)); assertEquals("C", map.get(three)); @@ -197,8 +210,8 @@ public class ConcurrentHashMap8Test exte Set set1 = map.keySet(); Set set2 = map.keySet(true); set2.add(six); - assertTrue(((KeySetView)set2).getMap() == map); - assertTrue(((KeySetView)set1).getMap() == map); + assertTrue(((ConcurrentHashMap.KeySetView)set2).getMap() == map); + assertTrue(((ConcurrentHashMap.KeySetView)set1).getMap() == map); assertEquals(set2.size(), map.size()); assertEquals(set1.size(), map.size()); assertTrue((Boolean)map.get(six)); @@ -210,7 +223,6 @@ public class ConcurrentHashMap8Test exte assertFalse(set2.contains(six)); } - /** * keySet.addAll adds each element from the given collection */ @@ -290,7 +302,7 @@ public class ConcurrentHashMap8Test exte map.keySet(null); shouldThrow(); } catch (NullPointerException e) {} - KeySetView set = map.keySet(one); + ConcurrentHashMap.KeySetView set = map.keySet(one); set.add(one); set.add(six); set.add(seven); @@ -990,9 +1002,11 @@ public class ConcurrentHashMap8Test exte public void testSearchValuesSequentially() { ConcurrentHashMap m = longMap(); Long r; - r = m.searchValues(Long.MAX_VALUE, (Long x) -> x.longValue() == (long)(SIZE/2)? x : null); + r = m.searchValues(Long.MAX_VALUE, + (Long x) -> (x.longValue() == (long)(SIZE/2)) ? x : null); assertEquals((long)r, (long)(SIZE/2)); - r = m.searchValues(Long.MAX_VALUE, (Long x) -> x.longValue() < 0L ? x : null); + r = m.searchValues(Long.MAX_VALUE, + (Long x) -> (x.longValue() < 0L) ? x : null); assertNull(r); }