commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r909004 - in /commons/proper/validator/trunk/src: main/java/org/apache/commons/validator/routines/checkdigit/ test/java/org/apache/commons/validator/routines/checkdigit/
Date Thu, 11 Feb 2010 14:45:04 GMT
Author: niallp
Date: Thu Feb 11 14:44:57 2010
New Revision: 909004

URL: http://svn.apache.org/viewvc?rev=909004&view=rev
Log:
Fix ModulusCheckDigit serialization - make abstract ModulusCheckDigit class implement Serializable
(otherwise concrete implementations throw an InvalidClassException complaining there is no
default constructor)

Modified:
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ABANumberCheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -41,7 +41,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public final class ABANumberCheckDigit extends ModulusCheckDigit implements Serializable
{
+public final class ABANumberCheckDigit extends ModulusCheckDigit {
 
     /** Singleton Routing Transit Number Check Digit instance */
     public static final CheckDigit INSTANCE = new ABANumberCheckDigit();

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -39,7 +39,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public final class CUSIPCheckDigit extends ModulusCheckDigit implements Serializable {
+public final class CUSIPCheckDigit extends ModulusCheckDigit {
 
     /** Singleton CUSIP Check Digit instance */
     public static final CheckDigit INSTANCE = new CUSIPCheckDigit();

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/EAN13CheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -42,7 +42,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public final class EAN13CheckDigit extends ModulusCheckDigit implements Serializable {
+public final class EAN13CheckDigit extends ModulusCheckDigit {
 
     /** Singleton EAN-13 Check Digit instance */
     public static final CheckDigit INSTANCE = new EAN13CheckDigit();

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISBN10CheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -44,7 +44,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public final class ISBN10CheckDigit extends ModulusCheckDigit implements Serializable {
+public final class ISBN10CheckDigit extends ModulusCheckDigit {
 
     /** Singleton ISBN-10 Check Digit instance */
     public static final CheckDigit INSTANCE = new ISBN10CheckDigit();

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -37,7 +37,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public final class ISINCheckDigit extends ModulusCheckDigit implements Serializable {
+public final class ISINCheckDigit extends ModulusCheckDigit {
 
     /** Singleton ISIN Check Digit instance */
     public static final CheckDigit INSTANCE = new ISINCheckDigit();

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -38,7 +38,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public final class LuhnCheckDigit extends ModulusCheckDigit implements Serializable {
+public final class LuhnCheckDigit extends ModulusCheckDigit {
 
     /** Singleton Luhn Check Digit instance */
     public static final CheckDigit INSTANCE = new LuhnCheckDigit();

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.validator.routines.checkdigit;
 
+import java.io.Serializable;
+
 /**
  * Abstract <b>Modulus</b> Check digit calculation/validation.
  * <p>
@@ -31,7 +33,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public abstract class ModulusCheckDigit implements CheckDigit {
+public abstract class ModulusCheckDigit implements CheckDigit, Serializable {
 
     private final int modulus;
 

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/checkdigit/SedolCheckDigit.java
Thu Feb 11 14:44:57 2010
@@ -38,7 +38,7 @@
  * @version $Revision$ $Date$
  * @since Validator 1.4
  */
-public final class SedolCheckDigit extends ModulusCheckDigit implements Serializable {
+public final class SedolCheckDigit extends ModulusCheckDigit {
 
     /** Singleton ISBN-10 check digit instance */
     public static final CheckDigit INSTANCE = new SedolCheckDigit();

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java?rev=909004&r1=909003&r2=909004&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
(original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
Thu Feb 11 14:44:57 2010
@@ -16,6 +16,10 @@
  */
 package org.apache.commons.validator.routines.checkdigit;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -205,6 +209,35 @@
     }
 
     /**
+     * Test check digit serialization.
+     */
+    public void testSerialization() {
+        // Serialize the check digit routine
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(routine);
+            oos.flush();
+            oos.close();
+        } catch (Exception e) {
+            fail(routine.getClass().getName() + " error during serialization: " + e);
+        }
+
+        // Deserialize the test object
+        Object result = null;
+        try {
+            ByteArrayInputStream bais =
+                new ByteArrayInputStream(baos.toByteArray());
+            ObjectInputStream ois = new ObjectInputStream(bais);
+            result = ois.readObject();
+            bais.close();
+        } catch (Exception e) {
+            fail(routine.getClass().getName() + " error during deserialization: " + e);
+        }
+        assertNotNull(result);
+    }
+
+    /**
      * Returns an array of codes with invalid check digits.
      *
      * @param codes Codes with valid check digits



Mime
View raw message