[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/marshall ...
Manik Surtani
msurtani at belmont.prod.atl2.jboss.com
Wed Aug 30 11:03:33 EDT 2006
User: msurtani
Date: 06/08/30 11:03:33
Modified: tests/functional/org/jboss/cache/marshall
AsyncReplTest.java BaseTreeCacheMarshallerTest.java
LocalTest.java SyncReplTest.java
Added: tests/functional/org/jboss/cache/marshall
RegionBasedMarshallingBaseTest.java
Log:
Fixed failing tests, enhanced large string tests
Revision Changes Path
1.9 +9 -17 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.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- AsyncReplTest.java 29 Aug 2006 12:24:41 -0000 1.8
+++ AsyncReplTest.java 30 Aug 2006 15:03:33 -0000 1.9
@@ -10,7 +10,6 @@
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.TreeCache;
@@ -29,9 +28,9 @@
* Test marshalling for async mode.
*
* @author Ben Wang
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
-public class AsyncReplTest extends TestCase
+public class AsyncReplTest extends RegionBasedMarshallingBaseTest
{
TreeCache cache1, cache2;
String props = null;
@@ -39,11 +38,6 @@
Address addr_;
Throwable ex_;
- public AsyncReplTest(String name)
- {
- super(name);
- }
-
public void setUp() throws Exception
{
super.setUp();
@@ -124,7 +118,7 @@
fail("Test fails with exception " + ex);
}
- Class claz = clb.loadClass("org.jboss.cache.marshall.Address");
+ Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
{
Class[] types = {String.class};
@@ -134,7 +128,7 @@
}
{
- Class clasz1 = clb.loadClass("org.jboss.cache.marshall.Person");
+ Class clasz1 = clb.loadClass(PERSON_CLASSNAME);
Class[] types = {claz};
Method setValue = clasz1.getMethod("setAddress", types);
Object[] margs = {add};
@@ -169,7 +163,7 @@
cache1.put("/aop/1", "person", ben_);
TestingUtil.sleepThread(1000);
- Object ben2 = null;
+ Object ben2;
try
{
// Can't cast it to Person. CCE will resutl.
@@ -219,7 +213,7 @@
fail("Test fails with exception " + ex);
}
- Class claz = clb.loadClass("org.jboss.cache.marshall.Address");
+ Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
{
Class[] types = {String.class};
@@ -229,7 +223,7 @@
}
{
- Class clasz1 = clb.loadClass("org.jboss.cache.marshall.Person");
+ Class clasz1 = clb.loadClass(PERSON_CLASSNAME);
Class[] types = {claz};
Method setValue = clasz1.getMethod("setAddress", types);
Object[] margs = {add};
@@ -261,14 +255,12 @@
{
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
mgr.begin();
- Transaction tx = mgr.getTransaction();
- return tx;
+ return mgr.getTransaction();
}
protected ClassLoader getClassLoader() throws Exception
{
- String[] includesClasses = {"org.jboss.cache.marshall.Person",
- "org.jboss.cache.marshall.Address"};
+ String[] includesClasses = {PERSON_CLASSNAME, ADDRESS_CLASSNAME};
String [] excludesClasses = {};
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return new SelectedClassnameClassLoader(includesClasses, excludesClasses, cl);
1.3 +34 -22 JBossCache/tests/functional/org/jboss/cache/marshall/BaseTreeCacheMarshallerTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BaseTreeCacheMarshallerTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/BaseTreeCacheMarshallerTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- BaseTreeCacheMarshallerTest.java 30 Aug 2006 13:40:34 -0000 1.2
+++ BaseTreeCacheMarshallerTest.java 30 Aug 2006 15:03:33 -0000 1.3
@@ -137,42 +137,54 @@
public void testLargeString() throws Exception
{
- StringBuilder sb = new StringBuilder();
- int stringSize = 32767;
-
- for (int i = 0; i < stringSize; i++) sb.append('a');
-
- String largeString = sb.toString();
-
- assertEquals(stringSize, largeString.length());
-
- byte[] buf = marshaller.objectToByteBuffer(largeString);
-
- assertEquals(largeString, marshaller.objectFromByteBuffer(buf));
+ doLargeStringTest(32767, false);
}
public void testLargerString() throws Exception
{
- StringBuilder sb = new StringBuilder();
- int stringSize = 32768;
+ doLargeStringTest(32768, false);
+ }
+
+ public void test64KString() throws Exception
+ {
+ doLargeStringTest((int) Math.pow(2, 16) - 10, false);
+ doLargeStringTest((int) Math.pow(2, 16) + 10, false);
+ }
- for (int i = 0; i < stringSize; i++) sb.append('a');
+ public void test128KString() throws Exception
+ {
+ doLargeStringTest((int) Math.pow(2, 17) - 10, false);
+ doLargeStringTest((int) Math.pow(2, 17) + 10, false);
+ }
- String largeString = sb.toString();
+ public void testLargeStringMultiByte() throws Exception
+ {
+ doLargeStringTest(32767, true);
+ }
- assertEquals(stringSize, largeString.length());
+ public void testLargerStringMultiByte() throws Exception
+ {
+ doLargeStringTest(32768, true);
+ }
- byte[] buf = marshaller.objectToByteBuffer(largeString);
+ public void test64KStringMultiByte() throws Exception
+ {
+ doLargeStringTest((int) Math.pow(2, 16) - 10, true);
+ doLargeStringTest((int) Math.pow(2, 16) + 10, true);
+ }
- assertEquals(largeString, marshaller.objectFromByteBuffer(buf));
+ public void test128KStringMultiByte() throws Exception
+ {
+ doLargeStringTest((int) Math.pow(2, 17) - 10, true);
+ doLargeStringTest((int) Math.pow(2, 17) + 10, true);
}
- public void testEvenLargerString() throws Exception
+ protected void doLargeStringTest(int stringSize, boolean multiByteChars) throws Exception
{
StringBuilder sb = new StringBuilder();
- int stringSize = 32769;
- for (int i = 0; i < stringSize; i++) sb.append('a');
+ int startingChar = multiByteChars ? 210 : 65;
+ for (int i = 0; i < stringSize; i++) sb.append((char) (startingChar + (i % 26)));
String largeString = sb.toString();
1.8 +5 -7 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.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- LocalTest.java 29 Aug 2006 12:24:41 -0000 1.7
+++ LocalTest.java 30 Aug 2006 15:03:33 -0000 1.8
@@ -1,7 +1,6 @@
package org.jboss.cache.marshall;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
@@ -19,9 +18,9 @@
* Simple functional tests for LegacyTreeCacheMarshaller
*
* @author Ben Wang
- * @version $Id: LocalTest.java,v 1.7 2006/08/29 12:24:41 msurtani Exp $
+ * @version $Id: LocalTest.java,v 1.8 2006/08/30 15:03:33 msurtani Exp $
*/
-public class LocalTest extends TestCase
+public class LocalTest extends RegionBasedMarshallingBaseTest
{
TreeCache cache = null;
Transaction tx = null;
@@ -65,12 +64,12 @@
URL[] cp0 = {jar0.toURL()};
URLClassLoader ucl0 = new URLClassLoader(cp0);
Thread.currentThread().setContextClassLoader(ucl0);
- Class clasz1 = ucl0.loadClass("org.jboss.cache.marshall.Person");
+ Class clasz1 = ucl0.loadClass(PERSON_CLASSNAME);
StringBuffer buffer = new StringBuffer("Person Info");
Debug.displayClassInfo(clasz1, buffer, false);
log(buffer.toString());
Object ben = clasz1.newInstance();
- Object value = null;
+ Object value;
try
{
{
@@ -99,8 +98,7 @@
assertEquals(cache.get("/a/b/c", "ben"), ben);
Object obj = cache.get("/a/b/c", "ben");
- URLClassLoader ucl1 = new URLClassLoader(cp0);
- Class claszAddr = ucl0.loadClass("org.jboss.cache.marshall.Address");
+ Class claszAddr = ucl0.loadClass(ADDRESS_CLASSNAME);
buffer = new StringBuffer("Address Info");
Debug.displayClassInfo(claszAddr, buffer, false);
log(buffer.toString());
1.8 +16 -24 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.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- SyncReplTest.java 29 Aug 2006 12:24:41 -0000 1.7
+++ SyncReplTest.java 30 Aug 2006 15:03:33 -0000 1.8
@@ -10,7 +10,6 @@
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Configuration;
@@ -30,9 +29,9 @@
* Test case for marshalling using Sync mode.
*
* @author Ben Wang
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
-public class SyncReplTest extends TestCase
+public class SyncReplTest extends RegionBasedMarshallingBaseTest
{
TreeCache cache1, cache2;
String props = null;
@@ -40,11 +39,6 @@
Address addr_;
Throwable ex_;
- public SyncReplTest(String name)
- {
- super(name);
- }
-
public void setUp() throws Exception
{
super.setUp();
@@ -114,10 +108,9 @@
cache2.registerClassLoader("/aop", cl);
cache1.put("/aop", "person", ben_);
- Person ben2 = null;
try
{
- ben2 = (Person) cache2.get("/aop", "person");
+ Person ben2 = (Person) cache2.get("/aop", "person");
}
catch (ClassCastException ex)
{
@@ -136,7 +129,7 @@
cache1.put("/aop", "person", ben_);
- Object ben2 = null;
+ Object ben2;
// Can't cast it to Person. CCE will resutl.
ben2 = cache2.get("/aop", "person");
assertEquals(ben_.toString(), ben2.toString());
@@ -151,12 +144,12 @@
cache1.put("/aop", "person", ben_);
- Object ben2 = null;
+ Object ben2;
// Can't cast it to Person. CCE will resutl.
ben2 = cache2.get("/aop", "person");
assertEquals(ben_.toString(), ben2.toString());
- Class claz = clb.loadClass("org.jboss.cache.marshall.Address");
+ Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
{
Class[] types = {String.class};
@@ -166,7 +159,7 @@
}
{
- Class clasz1 = clb.loadClass("org.jboss.cache.marshall.Person");
+ Class clasz1 = clb.loadClass(PERSON_CLASSNAME);
Class[] types = {claz};
Method setValue = clasz1.getMethod("setAddress", types);
Object[] margs = {add};
@@ -188,12 +181,12 @@
cache1.put("/aop", "person", ben_);
- Object ben2 = null;
+ Object ben2;
// Can't cast it to Person. CCE will resutl.
ben2 = cache2.get("/aop", "person");
assertEquals(ben_.toString(), ben2.toString());
- Class claz = clb.loadClass("org.jboss.cache.marshall.Address");
+ Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
{
Class[] types = {String.class};
@@ -203,7 +196,7 @@
}
{
- Class clasz1 = clb.loadClass("org.jboss.cache.marshall.Person");
+ Class clasz1 = clb.loadClass(PERSON_CLASSNAME);
Class[] types = {claz};
Method setValue = clasz1.getMethod("setAddress", types);
Object[] margs = {add};
@@ -228,7 +221,7 @@
cache1.put("/aop/1", "person", ben_);
cache1.put("/aop/1", "person", ben_);
- Object ben2 = null;
+ Object ben2;
// Can't cast it to Person. CCE will resutl.
ben2 = cache2.get("/aop/1", "person");
assertEquals(ben_.toString(), ben2.toString());
@@ -307,12 +300,12 @@
cache1.put("/aop", "person", ben_);
tx.commit();
- Object ben2 = null;
+ Object ben2;
// Can't cast it to Person. CCE will resutl.
ben2 = cache2.get("/aop", "person");
assertEquals(ben_.toString(), ben2.toString());
- Class claz = clb.loadClass("org.jboss.cache.marshall.Address");
+ Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
{
Class[] types = {String.class};
@@ -322,7 +315,7 @@
}
{
- Class clasz1 = clb.loadClass("org.jboss.cache.marshall.Person");
+ Class clasz1 = clb.loadClass(PERSON_CLASSNAME);
Class[] types = {claz};
Method setValue = clasz1.getMethod("setAddress", types);
Object[] margs = {add};
@@ -345,13 +338,12 @@
{
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
mgr.begin();
- Transaction tx = mgr.getTransaction();
- return tx;
+ return mgr.getTransaction();
}
protected ClassLoader getClassLoader() throws Exception
{
- String[] includesClasses = {"org.jboss.cache.marshall.Person",
+ String[] includesClasses = {PERSON_CLASSNAME,
"org.jboss.cache.marshall.Address"};
String [] excludesClasses = {};
ClassLoader cl = Thread.currentThread().getContextClassLoader();
1.1 date: 2006/08/30 15:03:33; author: msurtani; state: Exp;JBossCache/tests/functional/org/jboss/cache/marshall/RegionBasedMarshallingBaseTest.java
Index: RegionBasedMarshallingBaseTest.java
===================================================================
package org.jboss.cache.marshall;
import junit.framework.TestCase;
public abstract class RegionBasedMarshallingBaseTest 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";
}
More information about the jboss-cvs-commits
mailing list