OpenJDK / jdk / hs
changeset 45179:5c2ed400440a
8180391: move SerializationUtils to top level testlibrary
Reviewed-by: psandoz
author | iignatyev |
---|---|
date | Thu, 18 May 2017 15:43:44 -0700 |
parents | 9ff621041842 |
children | 636b3e3f9976 |
files | jdk/test/java/lang/String/CompactString/SerializationTest.java jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java jdk/test/lib/testlibrary/jdk/testlibrary/SerializationUtils.java |
diffstat | 4 files changed, 9 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/test/java/lang/String/CompactString/SerializationTest.java Thu May 18 12:53:19 2017 -0700 +++ b/jdk/test/java/lang/String/CompactString/SerializationTest.java Thu May 18 15:43:44 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,14 +24,13 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static jdk.testlibrary.SerializationUtils.*; +import static jdk.test.lib.util.SerializationUtils.*; import static org.testng.Assert.assertEquals; /* * @test * @bug 8077559 - * @library /lib/testlibrary - * @build jdk.testlibrary.SerializationUtils + * @library /test/lib * @summary Tests Compact String. This one is testing String serialization * among -XX:+CompactStrings/-XX:-CompactStrings/LegacyString * @run testng/othervm -XX:+CompactStrings SerializationTest
--- a/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java Thu May 18 12:53:19 2017 -0700 +++ b/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java Thu May 18 15:43:44 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,14 +26,13 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static jdk.testlibrary.SerializationUtils.*; +import static jdk.test.lib.util.SerializationUtils.*; import static org.testng.Assert.*; /* * @test * @bug 8077559 - * @library /lib/testlibrary - * @build jdk.testlibrary.SerializationUtils + * @library /test/lib * @summary Tests Compact String. This one is testing StringBuffer serialization * among -XX:+CompactStrings/-XX:-CompactStrings/LegacyStringBuffer * @run testng/othervm -XX:+CompactStrings CompactStringBufferSerialization
--- a/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java Thu May 18 12:53:19 2017 -0700 +++ b/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java Thu May 18 15:43:44 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,14 +26,13 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static jdk.testlibrary.SerializationUtils.*; +import static jdk.test.lib.util.SerializationUtils.*; import static org.testng.Assert.*; /* * @test * @bug 8077559 - * @library /lib/testlibrary - * @build jdk.testlibrary.SerializationUtils + * @library /test/lib * @summary Tests Compact String. This one is testing StringBuilder serialization * among -XX:+CompactStrings/-XX:-CompactStrings/LegacyStringBuilder * @run testng/othervm -XX:+CompactStrings CompactStringBuilderSerialization
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/SerializationUtils.java Thu May 18 12:53:19 2017 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.testlibrary; - -import java.io.*; - -/** - * Common library for various test serialization utility functions. - */ -public final class SerializationUtils { - /* - * Serialize an object into byte array. - */ - public static byte[] serialize(Object obj) throws Exception { - try (ByteArrayOutputStream bs = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(bs);) { - out.writeObject(obj); - return bs.toByteArray(); - } - } - - /* - * Deserialize an object from byte array. - */ - public static Object deserialize(byte[] ba) throws Exception { - try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba));) { - return in.readObject(); - } - } -}