[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/aop ...
Ben Wang
bwang at jboss.com
Wed Nov 15 21:53:35 EST 2006
User: bwang
Date: 06/11/15 21:53:35
Modified: tests/functional/org/jboss/cache/aop Tag:
Branch_JBossCache_1_4_0 NewLocalAopTest.java
Log:
JBCACHE-850 findObjects cce
Revision Changes Path
No revision
No revision
1.8.2.1 +106 -0 JBossCache/tests/functional/org/jboss/cache/aop/Attic/NewLocalAopTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NewLocalAopTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/Attic/NewLocalAopTest.java,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -b -r1.8 -r1.8.2.1
--- NewLocalAopTest.java 9 Apr 2006 12:33:49 -0000 1.8
+++ NewLocalAopTest.java 16 Nov 2006 02:53:35 -0000 1.8.2.1
@@ -6,9 +6,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.PropertyConfigurator;
+import org.jboss.cache.TreeCacheListener;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.aop.test.Person;
+import org.jboss.aop.proxy.ClassProxy;
+import org.jgroups.View;
import java.util.Map;
+import java.util.ArrayList;
/**
@@ -35,6 +41,8 @@
cache_ = new PojoCache();
PropertyConfigurator config = new PropertyConfigurator();
config.configure(cache_, configFile); // read in generic replSync xml
+ MyListener listener = new MyListener();
+ cache_.addTreeCacheListener(listener);
cache_.start();
}
@@ -89,6 +97,27 @@
assertEquals("Age should be updated as ", 20, test.getAge());
}
+ public void testRemoveProxy() throws Exception
+ {
+ log_.info("testRemoveProxy() ....");
+ Person test = new Person();
+ test.setName("Ben");
+ test.setAge(10);
+ ArrayList list = new ArrayList();
+ list.add("English");
+ list.add("Taiwanese");
+ test.setLanguages(list);
+ cache_.putObject("/a", test);
+ Person result = (Person)cache_.getObject("/a");
+ assertEquals(" ", test, result);
+
+ assertTrue("Instance of proxyclass ", result.getLanguages() instanceof ClassProxy);
+
+ cache_.removeObject("/a");
+
+ assertFalse("Instance of proxyclass ", result.getLanguages() instanceof ClassProxy);
+ }
+
public void testPutRemoveNodeExistence() throws Exception
{
log_.info("testPutRemove() ....");
@@ -130,6 +159,43 @@
assertEquals("Objects size should be ", 2, map.size());
}
+ public void testFindObjectsWithGenericFqn() throws Exception
+ {
+ log_.info("testFindObjectsWithGenericFqn() ....");
+ Map map = cache_.findObjects("/");
+ assertEquals("Objects size should be ", 0, map.size());
+ Person ben = new Person();
+ ben.setName("Ben");
+ ben.setAge(10);
+ cache_.putObject("/a/b/c", ben);
+ cache_.putObject("/e", ben); // multiple keys, same pojo
+ Person joe = new Person();
+ joe.setName("Joe");
+ joe.setAge(10);
+ Fqn base = Fqn.fromString("/a");
+ Fqn fqn = new Fqn(base, new Long(3));
+ cache_.putObject(fqn, joe);
+ map = cache_.findObjects("/");
+ assertEquals("Objects size should be ", 3, map.size());
+
+ map = cache_.findObjects("/a");
+ assertEquals("Objects size should be ", 2, map.size());
+ cache_.removeObject("/e");
+ map = cache_.findObjects("/");
+ assertEquals("Objects size should be ", 2, map.size());
+ }
+
+ public void testNotification() throws Exception
+ {
+ log_.info("testNotification() ....");
+ Person test = new Person();
+ test.setName("Ben");
+ test.setAge(10);
+ cache_.putObject("/a", test);
+ Person result = (Person)cache_.getObject("/a");
+ assertEquals(" ", test, result);
+ }
+
public static Test suite() throws Exception
{
return new TestSuite(NewLocalAopTest.class);
@@ -141,5 +207,45 @@
junit.textui.TestRunner.run(suite());
}
+ public class MyListener implements TreeCacheListener
+ {
+
+ public void nodeCreated(Fqn fqn) {
+ System.out.println("**** Node created : " +fqn);
+ }
+
+ public void nodeRemoved(Fqn fqn) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void nodeLoaded(Fqn fqn) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void nodeEvicted(Fqn fqn) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void nodeModified(Fqn fqn) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void nodeVisited(Fqn fqn) {
+ System.out.println("**** Node visited : " +fqn);
+ }
+
+ public void cacheStarted(TreeCache cache) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void cacheStopped(TreeCache cache) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void viewChange(View new_view) // might be MergeView after merging
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list