[infinispan-commits] Infinispan SVN: r1646 - trunk/core/src/test/java/org/infinispan/marshall.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Mar 31 10:42:43 EDT 2010


Author: galder.zamarreno at jboss.com
Date: 2010-03-31 10:42:42 -0400 (Wed, 31 Mar 2010)
New Revision: 1646

Modified:
   trunk/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java
Log:
[JBMAR-106] (StreamCorruptedException when reading nested subclasses) Added unit test on the Infinispan side as well for VAM.

Modified: trunk/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java	2010-03-31 13:11:26 UTC (rev 1645)
+++ trunk/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java	2010-03-31 14:42:42 UTC (rev 1646)
@@ -81,6 +81,7 @@
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.io.Serializable;
 import java.util.*;
 
 @Test(groups = "functional", testName = "marshall.VersionAwareMarshallerTest")
@@ -463,6 +464,19 @@
       }
       
    }
+
+   public void testMarshallingSerializableSubclass() throws Exception {
+      Child1 child1Obj = new Child1(1234, "1234");
+      byte[] bytes = marshaller.objectToByteBuffer(child1Obj);
+      marshaller.objectFromByteBuffer(bytes);
+   }
+
+   public void testMarshallingNestedSerializableSubclass() throws Exception {
+      Child1 child1Obj = new Child1(1234, "1234");
+      Child2 child2Obj = new Child2(2345, "2345", child1Obj);
+      byte[] bytes = marshaller.objectToByteBuffer(child2Obj);
+      marshaller.objectFromByteBuffer(bytes);
+   }
    
    protected void marshallAndAssertEquality(Object writeObj) throws Exception {
       byte[] bytes = marshaller.objectToByteBuffer(writeObj);
@@ -507,4 +521,40 @@
          deserializationCount++;
       }
    }
+
+   static class Parent implements Serializable {
+       private String id;
+       private Child1 child1Obj;
+
+       public Parent(String id, Child1 child1Obj) {
+           this.id = id;
+           this.child1Obj = child1Obj;
+       }
+
+       public String getId() {
+           return id;
+       }
+       public Child1 getChild1Obj() {
+           return child1Obj;
+       }
+   }
+
+   static class Child1 extends Parent {
+       private int someInt;
+
+       public Child1(int someInt, String parentStr) {
+           super(parentStr, null);
+           this.someInt = someInt;
+       }
+
+   }
+
+   static class Child2 extends Parent {
+       private int someInt;
+
+       public Child2(int someInt, String parentStr, Child1 child1Obj) {
+           super(parentStr, child1Obj);
+           this.someInt = someInt;
+       }
+   }
 }



More information about the infinispan-commits mailing list