commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r371343 - in /jakarta/commons/sandbox/id/trunk/src: java/org/apache/commons/id/serial/ test-serialization/org.apache.commons.id.serial.AlphanumericGenerator/ test-serialization/org.apache.commons.id.serial.NumericGenerator/ test/org/apache/...
Date Sun, 22 Jan 2006 18:32:18 GMT
Author: joehni
Date: Sun Jan 22 10:32:05 2006
New Revision: 371343

URL: http://svn.apache.org/viewcvs?rev=371343&view=rev
Log:
Add serialization for AlphanumericIdGenerator and NumericIdGenerator.

Added:
    jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.AlphanumericGenerator/
    jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.AlphanumericGenerator/20060120.ser
  (with props)
    jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.NumericGenerator/
    jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.NumericGenerator/20060121.ser
  (with props)
    jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/AlphanumericGeneratorTest.java
  (with props)
    jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/NumericGeneratorTest.java
  (with props)
Modified:
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/AlphanumericGenerator.java
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/NumericGenerator.java

Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/AlphanumericGenerator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/AlphanumericGenerator.java?rev=371343&r1=371342&r2=371343&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/AlphanumericGenerator.java
(original)
+++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/AlphanumericGenerator.java
Sun Jan 22 10:32:05 2006
@@ -18,6 +18,8 @@
 
 import org.apache.commons.id.AbstractStringIdentifierGenerator;
 
+import java.io.Serializable;
+
 /**
  * <code>AlphanumericGenerator</code> is an identifier generator
  * that generates an incrementing number in base 36 as a String
@@ -34,7 +36,12 @@
  * @author Commons-Id team
  * @version $Id$
  */
-public class AlphanumericGenerator extends AbstractStringIdentifierGenerator {
+public class AlphanumericGenerator extends AbstractStringIdentifierGenerator implements Serializable
{
+
+    /**
+     * <code>serialVersionUID</code> is the serializable UID for the binary version
of the class.
+     */
+    private static final long serialVersionUID = 20060120L;
 
     /**
      * Should the counter wrap.

Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/NumericGenerator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/NumericGenerator.java?rev=371343&r1=371342&r2=371343&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/NumericGenerator.java
(original)
+++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/NumericGenerator.java
Sun Jan 22 10:32:05 2006
@@ -18,6 +18,8 @@
 
 import org.apache.commons.id.AbstractStringIdentifierGenerator;
 
+import java.io.Serializable;
+
 /**
  * <p><code>NumericIdentifierGenerator</code> is an Identifier Generator
  * that generates an incrementing number as a String object.</p>
@@ -30,8 +32,13 @@
  * @author Commons-Id team
  * @version $Id$
  */
-public class NumericGenerator extends AbstractStringIdentifierGenerator {
+public class NumericGenerator extends AbstractStringIdentifierGenerator implements Serializable
{
 
+    /**
+     * <code>serialVersionUID</code> is the serializable UID for the binary version
of the class.
+     */
+    private static final long serialVersionUID = 20060121L;
+    
     /** Should the counter wrap. */
     private boolean wrapping;
     /** The counter. */

Added: jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.AlphanumericGenerator/20060120.ser
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.AlphanumericGenerator/20060120.ser?rev=371343&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.AlphanumericGenerator/20060120.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.NumericGenerator/20060121.ser
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.NumericGenerator/20060121.ser?rev=371343&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.NumericGenerator/20060121.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/AlphanumericGeneratorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/AlphanumericGeneratorTest.java?rev=371343&view=auto
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/AlphanumericGeneratorTest.java
(added)
+++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/AlphanumericGeneratorTest.java
Sun Jan 22 10:32:05 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.id.serial;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.id.SerializationTestContext;
+import org.apache.commons.id.test.AssertSerialization;
+
+import java.io.Serializable;
+
+/**
+ * @author Commons-Uid team
+ * @version $Id$
+ */
+public class AlphanumericGeneratorTest extends TestCase {
+    
+    /**
+     * {@link TestSuite} for SessionIdGenerator. Ensures serialization.
+     * 
+     * @return the TestSuite
+     */
+    public static TestSuite suite() {
+        final TestSuite suite = new TestSuite(AlphanumericGeneratorTest.class);
+        suite.addTest(AssertSerialization.createSerializationTestSuite(new SerializationTestContext()
{
+
+            public void verify(Object serialized, long uid) {
+                AlphanumericGenerator test = (AlphanumericGenerator)serialized;
+                AlphanumericGenerator idGenerator = (AlphanumericGenerator)createReference();
+                assertEquals(idGenerator.maxLength(), test.maxLength());
+                assertEquals(idGenerator.minLength(), test.minLength());
+                assertEquals(idGenerator.isWrap(), test.isWrap());
+                assertEquals("4", test.nextStringIdentifier());
+            }
+
+            public Serializable createReference() {
+                return new AlphanumericGenerator(false, "3");
+            }
+
+            public Class getType() {
+                return AlphanumericGenerator.class;
+            }
+        }));
+        return suite;
+    }
+}

Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/AlphanumericGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/AlphanumericGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/NumericGeneratorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/NumericGeneratorTest.java?rev=371343&view=auto
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/NumericGeneratorTest.java
(added)
+++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/NumericGeneratorTest.java
Sun Jan 22 10:32:05 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.id.serial;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.id.SerializationTestContext;
+import org.apache.commons.id.test.AssertSerialization;
+
+import java.io.Serializable;
+
+/**
+ * @author Commons-Uid team
+ * @version $Id$
+ */
+public class NumericGeneratorTest extends TestCase {
+    
+    /**
+     * {@link TestSuite} for SessionIdGenerator. Ensures serialization.
+     * 
+     * @return the TestSuite
+     */
+    public static TestSuite suite() {
+        final TestSuite suite = new TestSuite(NumericGeneratorTest.class);
+        suite.addTest(AssertSerialization.createSerializationTestSuite(new SerializationTestContext()
{
+
+            public void verify(Object serialized, long uid) {
+                NumericGenerator test = (NumericGenerator)serialized;
+                NumericGenerator idGenerator = (NumericGenerator)createReference();
+                assertEquals(idGenerator.maxLength(), test.maxLength());
+                assertEquals(idGenerator.minLength(), test.minLength());
+                assertEquals(idGenerator.isWrap(), test.isWrap());
+                assertEquals("3", test.nextStringIdentifier());
+            }
+
+            public Serializable createReference() {
+                return new NumericGenerator(false, 3);
+            }
+
+            public Class getType() {
+                return NumericGenerator.class;
+            }
+        }));
+        return suite;
+    }
+}

Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/NumericGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/NumericGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message