[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/marshall ...
Manik Surtani
msurtani at jboss.com
Tue Sep 5 08:30:26 EDT 2006
User: msurtani
Date: 06/09/05 08:30:26
Modified: tests/functional/org/jboss/cache/marshall
AsyncReplTest.java LocalTest.java SyncReplTest.java
TreeCacheMarshaller140Test.java
TreeCacheMarshaller200Test.java
Added: tests/functional/org/jboss/cache/marshall
RegionBasedMarshallingTestBase.java
TreeCacheMarshallerTestBase.java
Removed: tests/functional/org/jboss/cache/marshall
BaseTreeCacheMarshallerTest.java
RegionBasedMarshallingBaseTest.java
Log:
Renamed base classes to prevent cruise control attempting to run them
Revision Changes Path
1.10 +2 -2 JBossCache/tests/functional/org/jboss/cache/marshall/AsyncReplTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AsyncReplTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/AsyncReplTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- AsyncReplTest.java 30 Aug 2006 15:03:33 -0000 1.9
+++ AsyncReplTest.java 5 Sep 2006 12:30:26 -0000 1.10
@@ -28,9 +28,9 @@
* Test marshalling for async mode.
*
* @author Ben Wang
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
-public class AsyncReplTest extends RegionBasedMarshallingBaseTest
+public class AsyncReplTest extends RegionBasedMarshallingTestBase
{
TreeCache cache1, cache2;
String props = null;
1.9 +2 -2 JBossCache/tests/functional/org/jboss/cache/marshall/LocalTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LocalTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/LocalTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- LocalTest.java 30 Aug 2006 15:03:33 -0000 1.8
+++ LocalTest.java 5 Sep 2006 12:30:26 -0000 1.9
@@ -18,9 +18,9 @@
* Simple functional tests for LegacyTreeCacheMarshaller
*
* @author Ben Wang
- * @version $Id: LocalTest.java,v 1.8 2006/08/30 15:03:33 msurtani Exp $
+ * @version $Id: LocalTest.java,v 1.9 2006/09/05 12:30:26 msurtani Exp $
*/
-public class LocalTest extends RegionBasedMarshallingBaseTest
+public class LocalTest extends RegionBasedMarshallingTestBase
{
TreeCache cache = null;
Transaction tx = null;
1.9 +2 -2 JBossCache/tests/functional/org/jboss/cache/marshall/SyncReplTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SyncReplTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/SyncReplTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- SyncReplTest.java 30 Aug 2006 15:03:33 -0000 1.8
+++ SyncReplTest.java 5 Sep 2006 12:30:26 -0000 1.9
@@ -29,9 +29,9 @@
* Test case for marshalling using Sync mode.
*
* @author Ben Wang
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
-public class SyncReplTest extends RegionBasedMarshallingBaseTest
+public class SyncReplTest extends RegionBasedMarshallingTestBase
{
TreeCache cache1, cache2;
String props = null;
1.3 +1 -1 JBossCache/tests/functional/org/jboss/cache/marshall/TreeCacheMarshaller140Test.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheMarshaller140Test.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/TreeCacheMarshaller140Test.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- TreeCacheMarshaller140Test.java 30 Aug 2006 19:09:56 -0000 1.2
+++ TreeCacheMarshaller140Test.java 5 Sep 2006 12:30:26 -0000 1.3
@@ -9,7 +9,7 @@
/**
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
-public class TreeCacheMarshaller140Test extends BaseTreeCacheMarshallerTest
+public class TreeCacheMarshaller140Test extends TreeCacheMarshallerTestBase
{
public TreeCacheMarshaller140Test()
{
1.2 +1 -1 JBossCache/tests/functional/org/jboss/cache/marshall/TreeCacheMarshaller200Test.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheMarshaller200Test.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/TreeCacheMarshaller200Test.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- TreeCacheMarshaller200Test.java 30 Aug 2006 11:23:55 -0000 1.1
+++ TreeCacheMarshaller200Test.java 5 Sep 2006 12:30:26 -0000 1.2
@@ -6,7 +6,7 @@
*/
package org.jboss.cache.marshall;
-public class TreeCacheMarshaller200Test extends BaseTreeCacheMarshallerTest
+public class TreeCacheMarshaller200Test extends TreeCacheMarshallerTestBase
{
public TreeCacheMarshaller200Test()
{
1.1 date: 2006/09/05 12:30:26; author: msurtani; state: Exp;JBossCache/tests/functional/org/jboss/cache/marshall/RegionBasedMarshallingTestBase.java
Index: RegionBasedMarshallingTestBase.java
===================================================================
package org.jboss.cache.marshall;
import junit.framework.TestCase;
public abstract class RegionBasedMarshallingTestBase extends TestCase
{
protected static final String ADDRESS_CLASSNAME = "org.jboss.cache.marshall.data.Address";
protected static final String PERSON_CLASSNAME = "org.jboss.cache.marshall.data.Person";
}
1.1 date: 2006/09/05 12:30:26; author: msurtani; state: Exp;JBossCache/tests/functional/org/jboss/cache/marshall/TreeCacheMarshallerTestBase.java
Index: TreeCacheMarshallerTestBase.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.marshall;
import junit.framework.TestCase;
import org.jboss.cache.Fqn;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
public abstract class TreeCacheMarshallerTestBase extends TestCase
{
protected String currentVersion;
protected int currentVersionShort;
protected Class expectedMarshallerClass;
protected VersionAwareMarshaller marshaller;
protected void setUp()
{
marshaller = new VersionAwareMarshaller(new RegionManager(), false, false, currentVersion);
}
protected void tearDown()
{
marshaller = null;
}
protected void assertMethodCallsEquals(MethodCall call1, MethodCall call2)
{
if (call1 == call2) return;
assertEquals("Method IDs should match", call1.getMethodId(), call2.getMethodId());
assertEquals("Method names should match", call1.getName(), call2.getName());
assertEquals("Method reflection objects should match", call1.getMethod(), call2.getMethod());
if (call1.getArgs() == null || call2.getArgs() == null)
{
assertNull("Both args should be null", call1.getArgs());
assertNull("Both args should be null", call2.getArgs());
}
else
{
Object[] call1Args = call1.getArgs();
Object[] call2Args = call2.getArgs();
assertObjectArraysAreEqual(call1Args, call2Args);
}
}
protected void assertObjectArraysAreEqual(Object[] a1, Object[] a2)
{
assertEquals("Number of args should match", a1.length, a2.length);
for (int i = 0; i < a1.length; i++)
{
if (a1[i] instanceof MethodCall && a2[i] instanceof MethodCall)
{
assertMethodCallsEquals((MethodCall) a1[i], (MethodCall) a2[i]);
}
else if (a1[i] instanceof List && a2[i] instanceof List)
{
Object[] a1Elements = ((List) a1[i]).toArray();
Object[] a2Elements = ((List) a2[i]).toArray();
assertObjectArraysAreEqual(a1Elements, a2Elements);
}
else
{
assertEquals("Argument # " + i + " should be equal", a1[i], a2[i]);
}
}
}
public void testGetMarshaller()
{
assertEquals("Only one marshaller should be in the map by this stage", 1, marshaller.marshallers.size());
assertEquals(expectedMarshallerClass, marshaller.getMarshaller(currentVersionShort).getClass());
assertEquals(LegacyTreeCacheMarshaller.class, marshaller.getMarshaller(15).getClass());
assertEquals(LegacyTreeCacheMarshaller.class, marshaller.getMarshaller(1).getClass());
assertEquals(LegacyTreeCacheMarshaller.class, marshaller.getMarshaller(-1).getClass());
assertEquals(LegacyTreeCacheMarshaller.class, marshaller.getMarshaller(0).getClass());
assertEquals("Two marshallers should be in the map by this stage", 2, marshaller.marshallers.size());
}
public void testStringBasedFqn() throws Exception
{
Fqn fqn = new Fqn(new Object[]{"JSESSIONID", "1010.10.5:3000", "1234567890", "1"});
byte[] asBytes = marshaller.objectToByteBuffer(fqn);
System.out.println("Marshalled to " + asBytes.length + " bytes");
Object o2 = marshaller.objectFromByteBuffer(asBytes);
assertEquals(fqn, o2);
}
public void testNonStringBasedFqn() throws Exception
{
Fqn fqn = new Fqn(new Object[]{3, false});
byte[] asBytes = marshaller.objectToByteBuffer(fqn);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
assertEquals(fqn, o2);
}
public void testMethodCall() throws Exception
{
Fqn fqn = new Fqn(new Object[]{3, false});
MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, fqn, "key", "value", true);
byte[] asBytes = marshaller.objectToByteBuffer(call);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
assertTrue("Unmarshalled object should be a method call", o2 instanceof MethodCall);
MethodCall m2 = (MethodCall) o2;
assertMethodCallsEquals(call, m2);
}
public void testNestedMethodCall() throws Exception
{
Fqn fqn = new Fqn(new Object[]{3, false});
MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, fqn, "key", "value", true);
MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, call);
byte[] asBytes = marshaller.objectToByteBuffer(replicateCall);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
assertTrue("Unmarshalled object should be a method call", o2 instanceof MethodCall);
MethodCall m2 = (MethodCall) o2;
assertMethodCallsEquals(replicateCall, m2);
}
public void testLargeString() throws Exception
{
doLargeStringTest(32767, false);
}
public void testLargerString() throws Exception
{
doLargeStringTest(32768, false);
}
public void test64KString() throws Exception
{
doLargeStringTest((int) Math.pow(2, 16) - 10, false);
doLargeStringTest((int) Math.pow(2, 16) + 10, false);
}
public void test128KString() throws Exception
{
doLargeStringTest((int) Math.pow(2, 17) - 10, false);
doLargeStringTest((int) Math.pow(2, 17) + 10, false);
}
public void testLargeStringMultiByte() throws Exception
{
doLargeStringTest(32767, true);
}
public void testLargerStringMultiByte() throws Exception
{
doLargeStringTest(32768, true);
}
public void test64KStringMultiByte() throws Exception
{
doLargeStringTest((int) Math.pow(2, 16) - 10, true);
doLargeStringTest((int) Math.pow(2, 16) + 10, true);
}
public void test128KStringMultiByte() throws Exception
{
doLargeStringTest((int) Math.pow(2, 17) - 10, true);
doLargeStringTest((int) Math.pow(2, 17) + 10, true);
}
protected void doLargeStringTest(int stringSize, boolean multiByteChars) throws Exception
{
StringBuilder sb = new StringBuilder();
int startingChar = multiByteChars ? 210 : 65;
for (int i = 0; i < stringSize; i++) sb.append((char) (startingChar + (i % 26)));
String largeString = sb.toString();
assertEquals(stringSize, largeString.length());
byte[] buf = marshaller.objectToByteBuffer(largeString);
assertEquals(largeString, marshaller.objectFromByteBuffer(buf));
}
public void testReplicationQueue() throws Exception
{
doReplicationQueueTest();
}
public void testReplicationQueueWithRegionBasedMarshalling() throws Exception
{
marshaller = new VersionAwareMarshaller(new RegionManager(), false, true, currentVersion);
doReplicationQueueTest();
}
protected void doReplicationQueueTest() throws Exception
{
// replication queue takes a list of replicate() MethodCalls and wraps them in a single replicate call.
List<MethodCall> calls = new ArrayList<MethodCall>();
Fqn f = new Fqn(new Object[]{"BlahBlah", 3, false});
String k = "key", v = "value";
MethodCall actualCall = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, f, k, v, true);
MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, actualCall);
calls.add(replicateCall);
actualCall = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, f, k, v, true);
replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, actualCall);
calls.add(replicateCall);
MethodCall call = MethodCallFactory.create(MethodDeclarations.replicateAllMethod, calls);
byte[] buf = marshaller.objectToByteBuffer(call);
assertMethodCallsEquals(call, (MethodCall) marshaller.objectFromByteBuffer(buf));
}
public void testHandleLegacyStream() throws Exception
{
// create a 'legacy' stream.
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bout);
out.writeObject("hello");
Object unmarshalled = marshaller.objectFromByteBuffer(bout.toByteArray());
assertEquals("hello", unmarshalled);
}
}
More information about the jboss-cvs-commits
mailing list