harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r430213 - /incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Date Thu, 10 Aug 2006 02:20:34 GMT
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());
+    }
 }



Mime
View raw message