You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/08/10 04:20:34 UTC
svn commit: r430213 -
/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Author: smishura
Date: Wed Aug 9 19:20:34 2006
New Revision: 430213
URL: http://svn.apache.org/viewvc?rev=430213&view=rev
Log:
Add createGoldenFile() method
Modified:
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java?rev=430213&r1=430212&r2=430213&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java Wed Aug 9 19:20:34 2006
@@ -516,4 +516,42 @@
return (Serializable)getObjectFromStream(in);
}
+
+ /**
+ * Creates golden file.
+ *
+ * The folder for created file is: <code>root + test's package name</code>.
+ * The file name is: <code>test's name + "golden.ser"</code>
+ *
+ * @param root -
+ * root directory for serialization resource files
+ * @param test -
+ * test case
+ * @param object -
+ * object to be serialized
+ * @throws IOException -
+ * if I/O error
+ */
+ public static void createGoldenFile(String root, TestCase test,
+ Object object) throws IOException {
+
+ String goldenPath = test.getClass().getName().replace('.',
+ File.separatorChar)
+ + ".golden.ser";
+
+ if (root != null) {
+ goldenPath = root + File.separatorChar + goldenPath;
+ }
+
+
+ File goldenFile = new File(goldenPath);
+ goldenFile.getParentFile().mkdirs();
+ goldenFile.createNewFile();
+
+ putObjectToStream(object, new FileOutputStream(goldenFile));
+
+ // don't forget to remove it from test case after using
+ Assert.fail("Generating golden file.\nGolden file name:"
+ + goldenFile.getAbsolutePath());
+ }
}