commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r909006 - in /commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines: AbstractCalendarValidatorTest.java AbstractNumberValidatorTest.java
Date Thu, 11 Feb 2010 14:46:53 GMT
Author: niallp
Date: Thu Feb 11 14:46:51 2010
New Revision: 909006

URL: http://svn.apache.org/viewvc?rev=909006&view=rev
Log:
add serialization tests

Modified:
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractNumberValidatorTest.java

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java?rev=909006&r1=909005&r2=909006&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java
(original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java
Thu Feb 11 14:46:51 2010
@@ -17,6 +17,11 @@
 package org.apache.commons.validator.routines;
 
 import junit.framework.TestCase;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Date;
 import java.util.Calendar;
 import java.util.Locale;
@@ -183,6 +188,35 @@
     }
 
     /**
+     * Test validator serialization.
+     */
+    public void testSerialization() {
+        // Serialize the check digit routine
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(validator);
+            oos.flush();
+            oos.close();
+        } catch (Exception e) {
+            fail(validator.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(validator.getClass().getName() + " error during deserialization: " + e);
+        }
+        assertNotNull(result);
+    }
+
+    /**
      * Create a calendar instance for a specified time zone, date and time.
      * 
      * @param zone The time zone

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractNumberValidatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractNumberValidatorTest.java?rev=909006&r1=909005&r2=909006&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractNumberValidatorTest.java
(original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/AbstractNumberValidatorTest.java
Thu Feb 11 14:46:51 2010
@@ -20,6 +20,10 @@
 
 import java.util.Locale;
 import java.text.DecimalFormat;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.math.BigDecimal;
 /**
  * Base Number Test Case.
@@ -208,4 +212,33 @@
         assertFalse("maxValue() > max",    strictValidator.maxValue(number21 , number20));
     }
 
+    /**
+     * Test validator serialization.
+     */
+    public void testSerialization() {
+        // Serialize the check digit routine
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(validator);
+            oos.flush();
+            oos.close();
+        } catch (Exception e) {
+            fail(validator.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(validator.getClass().getName() + " error during deserialization: " + e);
+        }
+        assertNotNull(result);
+    }
+
 }



Mime
View raw message