Author: luc
Date: Mon Jul 20 19:50:12 2009
New Revision: 795975

URL: http://svn.apache.org/viewvc?rev=795975&view=rev
Log:
checked serialization of DefaultTransformer and added a test for it

Modified:
    
commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java
    
commons/proper/math/trunk/src/test/org/apache/commons/math/util/DefaultTransformerTest.java

Modified: 
commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java?rev=795975&r1=795974&r2=795975&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java
 (original)
+++ 
commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java
 Mon Jul 20 19:50:12 2009
@@ -30,8 +30,6 @@
  * @version $Revision$ $Date$
  */
 public class DefaultTransformer implements NumberTransformer, Serializable {
-    // TODO: Add Serializable documentation
-    // TODO: Check Serializable implementation
    
     /** Serializable version identifier */
     private static final long serialVersionUID = 4019938025047800455L;
@@ -60,4 +58,23 @@
                                     "Conversion Exception in Transformation: 
{0}", e.getMessage());
         }
     }
+
+    /** {...@inheritdoc} */
+    public boolean equals(Object other) {
+        if (this == other) { 
+            return true;
+        }
+        if (other == null) {
+            return false;
+        }
+        return other instanceof DefaultTransformer;
+    }
+    
+    /** {...@inheritdoc} */
+    @Override
+    public int hashCode() {
+        // some arbitrary number ...
+        return 401993047;
+    }
+
 }

Modified: 
commons/proper/math/trunk/src/test/org/apache/commons/math/util/DefaultTransformerTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/util/DefaultTransformerTest.java?rev=795975&r1=795974&r2=795975&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/test/org/apache/commons/math/util/DefaultTransformerTest.java
 (original)
+++ 
commons/proper/math/trunk/src/test/org/apache/commons/math/util/DefaultTransformerTest.java
 Mon Jul 20 19:50:12 2009
@@ -19,9 +19,11 @@
 
 import java.math.BigDecimal;
 
-import org.apache.commons.math.MathException;
 import junit.framework.TestCase;
 
+import org.apache.commons.math.MathException;
+import org.apache.commons.math.TestUtils;
+
 /**
  * @version $Revision$ $Date$
  */
@@ -92,4 +94,9 @@
             // expected
         }
     }
+
+    public void testSerial() {
+        assertEquals(new DefaultTransformer(), 
TestUtils.serializeAndRecover(new DefaultTransformer()));
+    }
+
 }


Reply via email to