diff options
author | Narayan Kamath <narayan@google.com> | 2013-11-13 11:23:45 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2013-11-13 12:41:57 +0000 |
commit | 9aab36ec35b4591cb9ba9ae0e4586cb642c39587 (patch) | |
tree | 258b58933db983ae3a8ef12f9541874d203a74b7 /support/src | |
parent | cb318c6f4fe5b0e20099fa85f1b95ccb2d24119f (diff) | |
download | libcore-9aab36ec35b4591cb9ba9ae0e4586cb642c39587.zip libcore-9aab36ec35b4591cb9ba9ae0e4586cb642c39587.tar.gz libcore-9aab36ec35b4591cb9ba9ae0e4586cb642c39587.tar.bz2 |
Add serialization golden files, fix tests.
- Moves a few golden files from luni/ to harmony-tests/
- Delete dead code in SerializationTester
- Fix a bug in SerializationTest (not sure how this
ever worked for resources with "." in their name)
Change-Id: Ia5b1376f4ada9b9c706a266ae077debeea5b1f29
Diffstat (limited to 'support/src')
-rw-r--r-- | support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java | 7 | ||||
-rw-r--r-- | support/src/test/java/tests/util/SerializationTester.java | 41 |
2 files changed, 5 insertions, 43 deletions
diff --git a/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java b/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java index 8d0c3a4..4f0b90b 100644 --- a/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java +++ b/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java @@ -22,6 +22,7 @@ package org.apache.harmony.testframework.serialization; +import junit.framework.TestCase; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -38,7 +39,6 @@ import java.security.PermissionCollection; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import junit.framework.TestCase; /** * Framework for serialization testing. Subclasses only need to override @@ -98,7 +98,6 @@ public abstract class SerializationTest extends TestCase { */ public void testGolden() throws Throwable { - verifyGolden(this, getData()); } @@ -427,7 +426,9 @@ public abstract class SerializationTest extends TestCase { path.append(test.getClass().getName().replace('.', File.separatorChar)); path.append(toAppend); - InputStream in = SerializationTest.class.getResourceAsStream(path.toString()); + String pathString = path.toString(); + + InputStream in = SerializationTest.class.getResourceAsStream(pathString); assertNotNull("Failed to load serialization resource file: " + path, in); return getObjectFromStream(in); } diff --git a/support/src/test/java/tests/util/SerializationTester.java b/support/src/test/java/tests/util/SerializationTester.java index 93bff70..22635e1 100644 --- a/support/src/test/java/tests/util/SerializationTester.java +++ b/support/src/test/java/tests/util/SerializationTester.java @@ -32,32 +32,10 @@ import java.net.URL; * This class simplifies the serialization test. */ public class SerializationTester { - - /* - * -------------------------------------------------------------------- - * Class variables - * -------------------------------------------------------------------- - */ - - // the last deserialized object - private static Object lastOutput = null; - - /* - * ------------------------------------------------------------------- - * Constructors - * ------------------------------------------------------------------- - */ - private SerializationTester() { } - /* - * ------------------------------------------------------------------- - * Methods - * ------------------------------------------------------------------- - */ - /** * Serialize an object and then deserialize it. * @@ -74,7 +52,6 @@ public class SerializationTester { ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); Object outputObject = ois.readObject(); - lastOutput = outputObject; ois.close(); return outputObject; } @@ -142,8 +119,7 @@ public class SerializationTester { throws Exception { InputStream input = null; ObjectInputStream oinput = null; - URL url = SerializationTester.class.getClassLoader().getResource( - fileName); + URL url = SerializationTester.class.getClassLoader().getResource(fileName); if (null == url) { // serialization file does not exist, create one in the current dir writeObject(obj, new File(fileName).getName()); @@ -213,19 +189,4 @@ public class SerializationTester { } } } - - /** - * Gets the last deserialized object. - * - * @return the last deserialized object - */ - public static Object getLastOutput() { - return lastOutput; - } - - /* - * For test purpose. - */ - public static void main(String[] args) { - } } |