--- jsr166/src/test/jtreg/util/Collections/EmptyCollectionSerialization.java 2015/09/09 22:05:28 1.3 +++ jsr166/src/test/jtreg/util/Collections/EmptyCollectionSerialization.java 2018/01/08 03:12:03 1.5 @@ -29,14 +29,22 @@ * @run testng EmptyCollectionSerialization */ -import java.util.*; -import java.util.function.Supplier; -import java.io.*; -import org.testng.annotations.Test; import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.function.Supplier; -import static org.testng.Assert.fail; import static org.testng.Assert.assertSame; +import static org.testng.Assert.fail; public class EmptyCollectionSerialization { private static Object patheticDeepCopy(Object o) throws Exception { @@ -58,7 +66,7 @@ public class EmptyCollectionSerializatio Object singleton = o.get(); assertSame(o.get(), singleton, description + ": broken Supplier not returning singleton"); Object copy = patheticDeepCopy(singleton); - assertSame( copy, singleton, description + ": " + + assertSame(copy, singleton, description + ": " + copy.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(copy)) + " is not the singleton " + singleton.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(singleton))); @@ -73,27 +81,28 @@ public class EmptyCollectionSerializatio } public static Collection makeSingletons() { - return Arrays.asList( - new Object[]{"Collections.EMPTY_LIST", - (Supplier) () -> {return Collections.EMPTY_LIST;}}, - new Object[]{"Collections.EMPTY_MAP", - (Supplier) () -> {return Collections.EMPTY_MAP;}}, - new Object[]{"Collections.EMPTY_SET", - (Supplier) () -> {return Collections.EMPTY_SET;}}, - new Object[]{"Collections.singletonMap()", - (Supplier) () -> {return Collections.emptyList();}}, - new Object[]{"Collections.emptyMap()", - (Supplier) () -> {return Collections.emptyMap();}}, - new Object[]{"Collections.emptySet()", - (Supplier) () -> {return Collections.emptySet();}}, - new Object[]{"Collections.emptySortedSet()", - (Supplier) () -> {return Collections.emptySortedSet();}}, - new Object[]{"Collections.emptySortedMap()", - (Supplier) () -> {return Collections.emptySortedMap();}}, - new Object[]{"Collections.emptyNavigableSet()", - (Supplier) () -> {return Collections.emptyNavigableSet();}}, - new Object[]{"Collections.emptyNavigableMap()", - (Supplier) () -> {return Collections.emptyNavigableMap();}} - ); + Object[][] params = { + {"Collections.EMPTY_LIST", + (Supplier) () -> Collections.EMPTY_LIST}, + {"Collections.EMPTY_MAP", + (Supplier) () -> Collections.EMPTY_MAP}, + {"Collections.EMPTY_SET", + (Supplier) () -> Collections.EMPTY_SET}, + {"Collections.emptyList()", + (Supplier) () -> Collections.emptyList()}, + {"Collections.emptyMap()", + (Supplier) () -> Collections.emptyMap()}, + {"Collections.emptySet()", + (Supplier) () -> Collections.emptySet()}, + {"Collections.emptySortedSet()", + (Supplier) () -> Collections.emptySortedSet()}, + {"Collections.emptySortedMap()", + (Supplier) () -> Collections.emptySortedMap()}, + {"Collections.emptyNavigableSet()", + (Supplier) () -> Collections.emptyNavigableSet()}, + {"Collections.emptyNavigableMap()", + (Supplier) () -> Collections.emptyNavigableMap()}, + }; + return Arrays.asList(params); } }