commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r371398 - in /jakarta/commons/sandbox/id/trunk/src: java/org/apache/commons/id/serial/ test-serialization/org.apache.commons.id.serial.LongGenerator/ test/org/apache/commons/id/serial/
Date Sun, 22 Jan 2006 21:49:51 GMT
Author: joehni
Date: Sun Jan 22 13:49:41 2006
New Revision: 371398

URL: http://svn.apache.org/viewcvs?rev=371398&view=rev
Log:
LongGenerator is serializable.

Added:
    jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.LongGenerator/
    jakarta/commons/sandbox/id/trunk/src/test-serialization/org.apache.commons.id.serial.LongGenerator/20060122.ser
  (with props)
    jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/LongGeneratorTest.java
  (with props)
Modified:
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/LongGenerator.java

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

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

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

Added: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/LongGeneratorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/LongGeneratorTest.java?rev=371398&view=auto
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/LongGeneratorTest.java
(added)
+++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/LongGeneratorTest.java
Sun Jan 22 13:49:41 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 LongGeneratorTest extends TestCase {
+    
+    /**
+     * {@link TestSuite} for SessionIdGenerator. Ensures serialization.
+     * 
+     * @return the TestSuite
+     */
+    public static TestSuite suite() {
+        final TestSuite suite = new TestSuite(LongGeneratorTest.class);
+        suite.addTest(AssertSerialization.createSerializationTestSuite(new SerializationTestContext()
{
+
+            public void verify(Object serialized, long uid) {
+                LongGenerator test = (LongGenerator)serialized;
+                LongGenerator idGenerator = (LongGenerator)createReference();
+                assertEquals(idGenerator.maxValue(), test.maxValue());
+                assertEquals(idGenerator.minValue(), test.minValue());
+                assertEquals(idGenerator.isWrap(), test.isWrap());
+                assertEquals(new Long(3), test.nextLongIdentifier());
+            }
+
+            public Serializable createReference() {
+                return new LongGenerator(false, 3);
+            }
+
+            public Class getType() {
+                return LongGenerator.class;
+            }
+        }));
+        return suite;
+    }
+}

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

Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/LongGeneratorTest.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