[jboss-cvs] JBossCache/tests-50/functional/org/jboss/cache/pojo ...
Manik Surtani
msurtani at jboss.com
Sat Dec 30 12:49:58 EST 2006
User: msurtani
Date: 06/12/30 12:49:58
Modified: tests-50/functional/org/jboss/cache/pojo
TestingUtil.java CircularGraphTest.java
NewLocalTest.java NewReplicatedTest.java
Log:
Major changes to restructure cache and node object model
Revision Changes Path
1.4 +8 -8 JBossCache/tests-50/functional/org/jboss/cache/pojo/TestingUtil.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TestingUtil.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/TestingUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- TestingUtil.java 9 Oct 2006 08:14:51 -0000 1.3
+++ TestingUtil.java 30 Dec 2006 17:49:58 -0000 1.4
@@ -7,8 +7,7 @@
package org.jboss.cache.pojo;
-import org.jboss.cache.TreeCache;
-import org.jboss.cache.TreeCacheProxyImpl;
+import org.jboss.cache.CacheImpl;
import java.util.Vector;
@@ -16,7 +15,7 @@
* Utilities for unit testing JBossCache.
*
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class TestingUtil
{
@@ -47,7 +46,7 @@
{
long failTime = System.currentTimeMillis() + timeout;
- TreeCache tcache = ((TreeCacheProxyImpl)cache.getCache()).getTreeCache();
+ CacheImpl tcache = (CacheImpl) cache.getCache();
while (System.currentTimeMillis() < failTime)
{
org.jboss.cache.pojo.TestingUtil.sleepThread(100);
@@ -60,7 +59,7 @@
/**
* Checks each cache to see if the number of elements in the array
- * returned by {@link org.jboss.cache.TreeCache#getMembers()} matches the size of
+ * returned by {@link org.jboss.cache.CacheImpl#getMembers()} matches the size of
* the <code>caches</code> parameter.
*
* @param caches caches that should form a View
@@ -75,7 +74,7 @@
for (int i = 0; i < memberCount; i++)
{
- TreeCache cache = ((TreeCacheProxyImpl)caches[i].getCache()).getTreeCache();
+ CacheImpl cache = (CacheImpl) caches[i].getCache();
return org.jboss.cache.pojo.TestingUtil.isCacheViewComplete(cache, memberCount);
}
@@ -88,13 +87,14 @@
* @param cache
* @param memberCount
*/
- public static boolean isCacheViewComplete(TreeCache cache, int memberCount)
+ public static boolean isCacheViewComplete(CacheImpl cache, int memberCount)
{
Vector members = cache.getMembers();
if (members == null || memberCount > members.size())
{
return false;
- } else if (memberCount < members.size())
+ }
+ else if (memberCount < members.size())
{
// This is an exceptional condition
StringBuffer sb = new StringBuffer("Cache at address ");
1.5 +12 -12 JBossCache/tests-50/functional/org/jboss/cache/pojo/CircularGraphTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CircularGraphTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/CircularGraphTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- CircularGraphTest.java 31 Oct 2006 11:07:17 -0000 1.4
+++ CircularGraphTest.java 30 Dec 2006 17:49:58 -0000 1.5
@@ -7,18 +7,19 @@
package org.jboss.cache.pojo;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.pojo.test.Person;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
import org.jboss.cache.pojo.test.Link;
import org.jboss.cache.pojo.test.NodeManager;
-import org.jboss.cache.DataNode;
+import org.jboss.cache.pojo.test.Person;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* Test object graph handling in PojoCache, e.g., circular reference, multiple reference, link, etc.
@@ -116,8 +117,8 @@
Link link = (Link) cache_.detach("/link/parent");
cache_.detach("/link/child");
assertEquals("child", link.getLink().getName());
- assertNull("Cache should be null ", ((DataNode) cache_.getCache().get("/link/parent")));
- assertNull("Cache should be null ", ((DataNode) cache_.getCache().get("/link/child")));
+ assertNull("Cache should be null ", (cache_.getCache().getRoot().getChild(Fqn.fromString("/link/parent"))));
+ assertNull("Cache should be null ", (cache_.getCache().getRoot().getChild(Fqn.fromString("/link/child"))));
}
/**
@@ -139,8 +140,8 @@
cache_.detach("/link/child");
Link link = (Link) cache_.detach("/link/parent");
assertEquals("child", link.getLink().getName());
- assertNull("Cache should be null ", ((DataNode) cache_.getCache().get("/link/parent")));
- assertNull("Cache should be null ", ((DataNode) cache_.getCache().get("/link/child")));
+ assertNull("Cache should be null ", (cache_.getCache().getRoot().getChild(Fqn.fromString("/link/parent"))));
+ assertNull("Cache should be null ", (cache_.getCache().getRoot().getChild(Fqn.fromString("/link/child"))));
}
/**
@@ -161,7 +162,7 @@
assertEquals("child", ((Link) cache_.find("/link/parent")).getLink().getName());
Link link = (Link) cache_.detach("/link/parent");
assertEquals("child", link.getLink().getName());
- assertNull("Cache should be null ", ((DataNode) cache_.getCache().get("/parent")));
+ assertNull("Cache should be null ", ((Node) cache_.getCache().getRoot().getChild(Fqn.fromString("/parent"))));
}
/**
@@ -184,7 +185,7 @@
assertEquals("parent", ((Link) cache_.find("/link/child")).getLink().getName());
Link link = (Link) cache_.detach("/link/parent");
assertEquals("child", link.getLink().getName());
- assertNull("Cache should be null ", ((DataNode) cache_.getCache().get("/parent")));
+ assertNull("Cache should be null ", ((Node) cache_.getCache().getRoot().getChild(Fqn.fromString("/parent"))));
}
/**
@@ -207,7 +208,7 @@
assertEquals("parent", ((Link) cache_.find("/link/child")).getLink().getName());
Link link = (Link) cache_.detach("/link/parent");
assertEquals("child", link.getLink().getName());
- assertNull("Cache should be null ", ((DataNode) cache_.getCache().get("/parent")));
+ assertNull("Cache should be null ", (cache_.getCache().getRoot().getChild(Fqn.fromString("/parent"))));
// re-attach
cache_.attach("/link/parent", parent);
@@ -240,7 +241,6 @@
}
/**
- *
* @throws Exception
*/
public void testCircularReference8() throws Exception
1.12 +16 -14 JBossCache/tests-50/functional/org/jboss/cache/pojo/NewLocalTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NewLocalTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/NewLocalTest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- NewLocalTest.java 16 Nov 2006 06:45:55 -0000 1.11
+++ NewLocalTest.java 30 Dec 2006 17:49:58 -0000 1.12
@@ -5,14 +5,14 @@
import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.pojo.test.Person;
-import org.jboss.cache.pojo.InternalConstant;
import org.jboss.aop.proxy.ClassProxy;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.pojo.test.Person;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.HashMap;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
/**
* Additional basic tests
@@ -63,7 +63,8 @@
{
cache_.attach(InternalConstant.JBOSS_INTERNAL_STRING, test);
fail("putObject under JBoss_Internal should fail");
- } catch (IllegalArgumentException iex)
+ }
+ catch (IllegalArgumentException iex)
{
// ok
}
@@ -72,7 +73,8 @@
{
cache_.detach(InternalConstant.JBOSS_INTERNAL_STRING);
fail("putObject under JBoss_Internal should fail");
- } catch (IllegalArgumentException iex)
+ }
+ catch (IllegalArgumentException iex)
{
// ok
}
@@ -107,7 +109,7 @@
assertNull("Object should be null ", cache_.find("person"));
assertEquals("Age should be updated as ", 20, test.getAge());
- assertNull("DataNode should not exisit ", cache_.getCache().get("person"));
+ assertNull("DataNode should not exisit ", cache_.getCache().getRoot().getChild(Fqn.fromString("person")));
}
public void testRemoveProxyList() throws Exception
@@ -121,12 +123,12 @@
list.add("Taiwanese");
test.setLanguages(list);
cache_.attach("/a", test);
- Person result = (Person)cache_.find("/a");
+ Person result = (Person) cache_.find("/a");
assertEquals(" ", test, result);
assertTrue("Instance of proxyclass ", result.getLanguages() instanceof ClassProxy);
- Person r1 = (Person)cache_.detach("/a");
+ Person r1 = (Person) cache_.detach("/a");
assertEquals("Same instance ", result, r1);
assertFalse("Instance of proxyclass ", result.getLanguages() instanceof ClassProxy);
@@ -144,12 +146,12 @@
set.add("Cooking");
test.setSkills(set);
cache_.attach("/a", test);
- Person result = (Person)cache_.find("/a");
+ Person result = (Person) cache_.find("/a");
assertEquals(" ", test, result);
assertTrue("Instance of proxyclass ", result.getSkills() instanceof ClassProxy);
- Person r1 = (Person)cache_.detach("/a");
+ Person r1 = (Person) cache_.detach("/a");
assertEquals("Same instance ", result, r1);
assertFalse("Instance of proxyclass ", result.getSkills() instanceof ClassProxy);
@@ -169,12 +171,12 @@
test.setHobbies(map);
cache_.attach("/a", test);
- Person result = (Person)cache_.find("/a");
+ Person result = (Person) cache_.find("/a");
assertEquals(" ", test, result);
assertTrue("Instance of proxyclass ", result.getHobbies() instanceof ClassProxy);
- Person r1 = (Person)cache_.detach("/a");
+ Person r1 = (Person) cache_.detach("/a");
assertEquals("Same instance ", result, r1);
assertFalse("Instance of proxyclass ", result.getHobbies() instanceof ClassProxy);
1.8 +8 -7 JBossCache/tests-50/functional/org/jboss/cache/pojo/NewReplicatedTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NewReplicatedTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/NewReplicatedTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- NewReplicatedTest.java 3 Dec 2006 10:30:30 -0000 1.7
+++ NewReplicatedTest.java 30 Dec 2006 17:49:58 -0000 1.8
@@ -5,9 +5,9 @@
import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.pojo.test.Person;
import org.jboss.cache.pojo.test.SpecialSerializedAddress;
-import org.jboss.cache.Fqn;
import javax.naming.Context;
import java.util.Properties;
@@ -130,7 +130,8 @@
{
remote.getAge();
fail("Should throw out exception here.");
- } catch (PojoCacheAlreadyDetachedException pe)
+ }
+ catch (PojoCacheAlreadyDetachedException pe)
{
}
}
@@ -171,10 +172,10 @@
public void testPutArray1() throws Exception
{
log_.info("testPutArray1() ....");
- long[] arr = new long[] {1, 2};
+ long[] arr = new long[]{1, 2};
cache_.attach("array", arr);
- long[] a2 = (long[])cache1_.find("array");
+ long[] a2 = (long[]) cache1_.find("array");
assertEquals("arr 0", 1, a2[0]);
}
@@ -188,11 +189,11 @@
Person p2 = new Person();
p2.setName("Joe");
p2.setAge(20);
- Person[] arr = new Person[] {p1, p2};
+ Person[] arr = new Person[]{p1, p2};
cache_.attach("array", arr);
- Person[] a2 = (Person[])cache1_.find("array");
+ Person[] a2 = (Person[]) cache1_.find("array");
assertEquals("arr 0", "Ben", a2[0].getName());
}
@@ -214,7 +215,7 @@
// restart cache1_
cache1_.stop();
- cache1_.getCache().remove("/a");
+ cache1_.getCache().removeNode(Fqn.fromString("/a"));
cache1_.start();
// Start from scratch for initial state transfer
Person remote = (Person) cache1_.find("/a");
More information about the jboss-cvs-commits
mailing list