[jboss-svn-commits] JBoss Common SVN: r4456 - shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat May 29 19:09:34 EDT 2010


Author: ALRubinger
Date: 2010-05-29 19:09:34 -0400 (Sat, 29 May 2010)
New Revision: 4456

Modified:
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/SerializationTestCase.java
Log:
[SHRINKWRAP-178] Added tests for wire compatibility in both directions

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/SerializationTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/SerializationTestCase.java	2010-05-29 22:50:43 UTC (rev 4455)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/SerializationTestCase.java	2010-05-29 23:09:34 UTC (rev 4456)
@@ -32,6 +32,8 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
+import junit.framework.TestCase;
+
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.ArchivePath;
 import org.jboss.shrinkwrap.api.Node;
@@ -149,10 +151,11 @@
     * which uses the {@link SpoofingObjectOutputStream}.
     * @throws Exception
     */
-   //   @Test
-   public void wireProtocolCurrentToOriginal() throws Exception
+   @Test
+   public void zipWireProtocolCurrentToOriginal() throws Exception
    {
-      //TODO
+      final SerializableView currentWireFormat = this.payload.as(SerializableView.class);
+      this.testWireProtocol(currentWireFormat, ZipSerializableOriginalImpl.class);
    }
 
    /**
@@ -163,24 +166,35 @@
     * which uses the {@link SpoofingObjectOutputStream}.
     * @throws Exception
     */
-   //   @Test
-   public void wireProtocolOriginalToCurrent() throws Exception
+   @Test
+   public void zipWireProtocolOriginalToCurrent() throws Exception
    {
-      //TODO
+      final SerializableView originalWireFormat = new ZipSerializableOriginalImpl(payload);
+      this.testWireProtocol(originalWireFormat, ZipSerializableViewImpl.class);
    }
 
-   //TODO Add tests for backwards-compatibility wire protocol, nested archives
-
-   /*
-    * Note: looks like nested archives aren't represented in toString(verbose);
-    * investigate if necessary and open a JIRA
-    */
-
    //-------------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    /**
+    * Ensures that the specified client object may be serialized to the specified type
+    * 
+    * @param clientObject The object to be serialized
+    * @param targetType The type we should be represented as
+    * @throws IOException
+    */
+   private void testWireProtocol(final SerializableView clientObject, final Class<? extends SerializableView> targetType)
+         throws IOException
+   {
+      // Roundtrip the object, now representing as the target type
+      final SerializableView roundtrip = serializeAndDeserialize(clientObject, targetType);
+
+      // The type of the object put through roundtrip serialization must be of the type specified
+      TestCase.assertEquals(targetType, roundtrip.getClass());
+   }
+
+   /**
     * Roundtrip serializes/deserializes the specified {@link Archive}
     * 
     * @param archive
@@ -228,8 +242,7 @@
       {
          final Object obj = oin.readObject();
          oin.close();
-         log.info("Original invocation type " + archive.getClass().getName() + " now represented as "
-               + obj.getClass().getName());
+         log.info("Original type " + archive.getClass().getName() + " now represented as " + obj.getClass().getName());
          return targetType.cast(obj);
       }
       catch (ClassNotFoundException e)



More information about the jboss-svn-commits mailing list