checked serialization of DefaultTransformer and added a test for it

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@795975 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2009-07-20 19:50:12 +00:00
parent d7f7b629b8
commit 77b5519151
2 changed files with 27 additions and 3 deletions

View File

@ -30,8 +30,6 @@ import org.apache.commons.math.MathException;
* @version $Revision$ $Date$ * @version $Revision$ $Date$
*/ */
public class DefaultTransformer implements NumberTransformer, Serializable { public class DefaultTransformer implements NumberTransformer, Serializable {
// TODO: Add Serializable documentation
// TODO: Check Serializable implementation
/** Serializable version identifier */ /** Serializable version identifier */
private static final long serialVersionUID = 4019938025047800455L; private static final long serialVersionUID = 4019938025047800455L;
@ -60,4 +58,23 @@ public class DefaultTransformer implements NumberTransformer, Serializable {
"Conversion Exception in Transformation: {0}", e.getMessage()); "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;
}
} }

View File

@ -19,9 +19,11 @@ package org.apache.commons.math.util;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.apache.commons.math.MathException;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.commons.math.MathException;
import org.apache.commons.math.TestUtils;
/** /**
* @version $Revision$ $Date$ * @version $Revision$ $Date$
*/ */
@ -92,4 +94,9 @@ public class DefaultTransformerTest extends TestCase {
// expected // expected
} }
} }
public void testSerial() {
assertEquals(new DefaultTransformer(), TestUtils.serializeAndRecover(new DefaultTransformer()));
}
} }