You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directmemory.apache.org by ol...@apache.org on 2012/02/22 11:58:32 UTC

svn commit: r1292234 - in /incubator/directmemory/trunk: ./ directmemory-tests/src/main/java/org/apache/directmemory/test/ directmemory-tests/src/test/java/org/apache/directmemory/test/ serializers/ serializers/protobuf/ serializers/protostuff/src/test...

Author: olamy
Date: Wed Feb 22 10:58:31 2012
New Revision: 1292234

URL: http://svn.apache.org/viewvc?rev=1292234&view=rev
Log:
add 'tck' serializer test in protostuff

Added:
    incubator/directmemory/trunk/directmemory-tests/src/main/java/org/apache/directmemory/test/AbstractSerializerTest.java   (with props)
    incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/StandardSerializerTest.java
      - copied, changed from r1292232, incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java
    incubator/directmemory/trunk/serializers/protostuff/src/test/java/org/apache/directmemory/serialization/protostuff/ProtostufSerializerTest.java   (contents, props changed)
      - copied, changed from r1292232, incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java
Removed:
    incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java
Modified:
    incubator/directmemory/trunk/pom.xml
    incubator/directmemory/trunk/serializers/pom.xml
    incubator/directmemory/trunk/serializers/protobuf/pom.xml

Added: incubator/directmemory/trunk/directmemory-tests/src/main/java/org/apache/directmemory/test/AbstractSerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/directmemory-tests/src/main/java/org/apache/directmemory/test/AbstractSerializerTest.java?rev=1292234&view=auto
==============================================================================
--- incubator/directmemory/trunk/directmemory-tests/src/main/java/org/apache/directmemory/test/AbstractSerializerTest.java (added)
+++ incubator/directmemory/trunk/directmemory-tests/src/main/java/org/apache/directmemory/test/AbstractSerializerTest.java Wed Feb 22 10:58:31 2012
@@ -0,0 +1,54 @@
+package org.apache.directmemory.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import static  junit.framework.Assert.*;
+import org.apache.directmemory.serialization.Serializer;
+import org.apache.directmemory.serialization.SerializerFactory;
+import org.junit.Test;
+
+/**
+ * A kind of tck test for serializer.
+ */
+public abstract class AbstractSerializerTest
+{
+    public abstract String getSerializerClassName();
+
+    @Test
+    public void factoryWithFQDN() throws Exception
+    {
+        assertEquals( getSerializerClassName(), SerializerFactory.createNewSerializer( getSerializerClassName() ).getClass().getName() );
+    }
+
+    @Test
+    public void simpleSerialization() throws Exception
+    {
+       Wine wine = new Wine( "Gevrey-Chambertin", "nice French wine from Bourgogne");
+        Serializer serializer = SerializerFactory.createNewSerializer( getSerializerClassName() );
+
+        byte[] bytes = serializer.serialize( wine );
+
+      Wine newWine = serializer.deserialize( bytes, Wine.class );
+
+      assertEquals( wine.getName(), newWine.getName() );
+        assertEquals( wine.getDescription(), newWine.getDescription() );
+
+    }
+}

Propchange: incubator/directmemory/trunk/directmemory-tests/src/main/java/org/apache/directmemory/test/AbstractSerializerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/directmemory/trunk/directmemory-tests/src/main/java/org/apache/directmemory/test/AbstractSerializerTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/StandardSerializerTest.java (from r1292232, incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java)
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/StandardSerializerTest.java?p2=incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/StandardSerializerTest.java&p1=incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java&r1=1292232&r2=1292234&rev=1292234&view=diff
==============================================================================
--- incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java (original)
+++ incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/StandardSerializerTest.java Wed Feb 22 10:58:31 2012
@@ -1,5 +1,4 @@
 package org.apache.directmemory.test;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,39 +18,16 @@ package org.apache.directmemory.test;
  * under the License.
  */
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.apache.directmemory.serialization.StandardSerializer;
 
 /**
- * Unit test for simple App.
+ * @author Olivier Lamy
  */
-public class AppTest 
-    extends TestCase
+public class StandardSerializerTest    extends AbstractSerializerTest
 {
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public AppTest( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite()
-    {
-        return new TestSuite( AppTest.class );
-    }
-
-    /**
-     * Rigourous Test :-)
-     */
-    public void testApp()
+    @Override
+    public String getSerializerClassName()
     {
-        assertTrue( true );
+        return StandardSerializer.class.getName();
     }
 }

Modified: incubator/directmemory/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/pom.xml?rev=1292234&r1=1292233&r2=1292234&view=diff
==============================================================================
--- incubator/directmemory/trunk/pom.xml (original)
+++ incubator/directmemory/trunk/pom.xml Wed Feb 22 10:58:31 2012
@@ -193,8 +193,8 @@ under the License.
   <modules>
     <module>directmemory-cache</module>
     <module>directmemory-tests</module>
-    <module>platforms</module>
     <module>server</module>
+    <module>platforms</module>
     <module>integrations</module>
     <module>serializers</module>
     <module>itests</module>

Modified: incubator/directmemory/trunk/serializers/pom.xml
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/serializers/pom.xml?rev=1292234&r1=1292233&r2=1292234&view=diff
==============================================================================
--- incubator/directmemory/trunk/serializers/pom.xml (original)
+++ incubator/directmemory/trunk/serializers/pom.xml Wed Feb 22 10:58:31 2012
@@ -28,7 +28,6 @@
     <version>0.6.0-SNAPSHOT</version>
   </parent>
 
-  <groupId>org.apache.directmemory</groupId>
   <artifactId>directmemory-serializers</artifactId>
   <packaging>pom</packaging>
   <name>Apache DirectMemory :: Serializers</name>
@@ -44,11 +43,16 @@
     <dependency>
       <groupId>${project.parent.groupId}</groupId>
       <artifactId>directmemory-cache</artifactId>
-      <version>${project.parent.version}</version>
       <scope>provided</scope>
     </dependency>
 
     <dependency>
+      <groupId>${project.parent.groupId}</groupId>
+      <artifactId>directmemory-tests</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
       <groupId>org.kohsuke.metainf-services</groupId>
       <artifactId>metainf-services</artifactId>
       <version>1.3</version>

Modified: incubator/directmemory/trunk/serializers/protobuf/pom.xml
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/serializers/protobuf/pom.xml?rev=1292234&r1=1292233&r2=1292234&view=diff
==============================================================================
--- incubator/directmemory/trunk/serializers/protobuf/pom.xml (original)
+++ incubator/directmemory/trunk/serializers/protobuf/pom.xml Wed Feb 22 10:58:31 2012
@@ -59,6 +59,7 @@ under the License.
       <groupId>com.google.protobuf</groupId>
       <artifactId>protobuf-java</artifactId>
     </dependency>
+
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>

Copied: incubator/directmemory/trunk/serializers/protostuff/src/test/java/org/apache/directmemory/serialization/protostuff/ProtostufSerializerTest.java (from r1292232, incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java)
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/serializers/protostuff/src/test/java/org/apache/directmemory/serialization/protostuff/ProtostufSerializerTest.java?p2=incubator/directmemory/trunk/serializers/protostuff/src/test/java/org/apache/directmemory/serialization/protostuff/ProtostufSerializerTest.java&p1=incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java&r1=1292232&r2=1292234&rev=1292234&view=diff
==============================================================================
--- incubator/directmemory/trunk/directmemory-tests/src/test/java/org/apache/directmemory/test/AppTest.java (original)
+++ incubator/directmemory/trunk/serializers/protostuff/src/test/java/org/apache/directmemory/serialization/protostuff/ProtostufSerializerTest.java Wed Feb 22 10:58:31 2012
@@ -1,5 +1,4 @@
-package org.apache.directmemory.test;
-
+package org.apache.directmemory.serialization.protostuff;
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,39 +18,18 @@ package org.apache.directmemory.test;
  * under the License.
  */
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.apache.directmemory.test.AbstractSerializerTest;
 
 /**
- * Unit test for simple App.
+ * @author Olivier Lamy
  */
-public class AppTest 
-    extends TestCase
+public class ProtostufSerializerTest
+    extends AbstractSerializerTest
 {
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public AppTest( String testName )
-    {
-        super( testName );
-    }
 
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite()
-    {
-        return new TestSuite( AppTest.class );
-    }
 
-    /**
-     * Rigourous Test :-)
-     */
-    public void testApp()
+    public String getSerializerClassName()
     {
-        assertTrue( true );
+        return ProtoStuffWithLinkedBufferSerializer.class.getName();
     }
 }

Propchange: incubator/directmemory/trunk/serializers/protostuff/src/test/java/org/apache/directmemory/serialization/protostuff/ProtostufSerializerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/directmemory/trunk/serializers/protostuff/src/test/java/org/apache/directmemory/serialization/protostuff/ProtostufSerializerTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision