[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/aop/collection ...
Manik Surtani
msurtani at jboss.com
Wed Sep 6 11:30:56 EDT 2006
User: msurtani
Date: 06/09/06 11:30:56
Modified: tests/functional/org/jboss/cache/aop/collection
ReplicatedSyncListTest.java
ReplicatedSyncMapTest.java
ReplicatedSyncSetTest.java
Log:
Removed TreeCache dependency on ServiceMBeanSupport
Revision Changes Path
1.6 +34 -28 JBossCache/tests/functional/org/jboss/cache/aop/collection/ReplicatedSyncListTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ReplicatedSyncListTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/collection/ReplicatedSyncListTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ReplicatedSyncListTest.java 20 Jul 2006 11:14:16 -0000 1.5
+++ ReplicatedSyncListTest.java 6 Sep 2006 15:30:56 -0000 1.6
@@ -16,12 +16,13 @@
/**
* Test object graph handling in aop, e.g., circular reference, multiple reference, link, etc.
+ *
* @author Ben Wang
*/
public class ReplicatedSyncListTest extends TestCase
{
- Log log=LogFactory.getLog(ReplicatedSyncListTest.class);
+ Log log = LogFactory.getLog(ReplicatedSyncListTest.class);
PojoCache cache1;
PojoCache cache2;
@@ -46,12 +47,13 @@
cache2.stop();
}
- private PojoCache createCache(String name) throws Exception {
- PojoCache tree=new PojoCache();
+ private PojoCache createCache(String name) throws Exception
+ {
+ PojoCache tree = new PojoCache();
tree.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml"));
tree.getConfiguration().setClusterName(name);
- tree.createService();
- tree.startService();
+ tree.create();
+ tree.start();
return tree;
}
@@ -68,6 +70,7 @@
/**
* Test attachment and then detachment and attachment.
+ *
* @throws Exception
*/
public void testAttachDetach() throws Exception
@@ -89,21 +92,22 @@
// Pure list
cache1.putObject("/list", list1);
- list1 = (List)cache1.getObject("/list");
+ list1 = (List) cache1.getObject("/list");
list1.add(addr2);
cache1.removeObject("/list");
assertEquals("Detached list should still be", 2, list1.size());
list1.add(addr3);
cache1.putObject("/list", list1);
- List list2 = (List)cache2.getObject("/list");
+ List list2 = (List) cache2.getObject("/list");
assertTrue("List size should not be 0 ", (list2.size() != 0));
- assertEquals("Both list values should be equal ", ((Address)list1.get(0)).getZip(),
- ((Address)list2.get(0)).getZip());
+ assertEquals("Both list values should be equal ", ((Address) list1.get(0)).getZip(),
+ ((Address) list2.get(0)).getZip());
}
/**
* Two different keys share same list.
+ *
* @throws Exception
*/
public void testRelationshipWithSharedList1() throws Exception
@@ -118,16 +122,16 @@
// Pure list
cache1.putObject("/list", list1);
// We specifically need to use Proxy otherwise it won't work with multiple references
- list1 = (List)cache1.getObject("/list");
+ list1 = (List) cache1.getObject("/list");
cache1.putObject("/alias", list1);
- List list2 = (List)cache1.getObject("/alias");
- Address add1 = (Address)list2.get(0);
+ List list2 = (List) cache1.getObject("/alias");
+ Address add1 = (Address) list2.get(0);
assertNotNull("Address should not be null", add1);
assertEquals("Zip ", 95123, add1.getZip());
- list1 = (List)cache2.getObject("/list");
- list2 = (List)cache2.getObject("/alias");
+ list1 = (List) cache2.getObject("/list");
+ list2 = (List) cache2.getObject("/alias");
assertTrue("List size should not be 0 ", (list2.size() != 0));
assertEquals("Both lists should be equal ", list1, list2);
assertEquals("Both list values should be equal ", list1.get(0), list2.get(0));
@@ -135,6 +139,7 @@
/**
* Shared object between two list item.
+ *
* @throws Exception
*/
public void testRelationshipWithSharedList2() throws Exception
@@ -152,14 +157,15 @@
cache1.putObject("/list1", list1);
cache1.putObject("/list2", list2);
- Address add2 = (Address)((List)cache2.getObject("/list2")).get(0);
- Address add1 = (Address)((List)cache2.getObject("/list1")).get(0);
+ Address add2 = (Address) ((List) cache2.getObject("/list2")).get(0);
+ Address add1 = (Address) ((List) cache2.getObject("/list1")).get(0);
assertEquals("Address should be the same", add1, add2);
assertEquals("Both shared object should be equal ", add2.getZip(), add1.getZip());
}
/**
* Shared object between regular POJO and List item.
+ *
* @throws Exception
*/
public void testRelationshipWithSharedList3() throws Exception
@@ -177,8 +183,8 @@
cache1.putObject("/address", addr);
cache1.putObject("/list1", list1);
- Address add1 = (Address)((List)cache2.getObject("/list1")).get(0);
- Address add2 = (Address)cache2.getObject("/address");
+ Address add1 = (Address) ((List) cache2.getObject("/list1")).get(0);
+ Address add2 = (Address) cache2.getObject("/address");
assertEquals("Address should be the same", add1, add2);
assertEquals("Both shared object should be equal ", 95123, add1.getZip());
}
@@ -195,13 +201,13 @@
// Pure set
cache1.putObject("/list", list1);
// We specifically need to use Proxy otherwise it won't work with multiple references
- list1 = (List)cache1.getObject("/list");
+ list1 = (List) cache1.getObject("/list");
cache1.putObject("/alias", list1);
- List list2 = (List)cache1.getObject("/alias");
+ List list2 = (List) cache1.getObject("/alias");
- list1 = (List)cache2.getObject("/list");
- list2 = (List)cache2.getObject("/alias");
+ list1 = (List) cache2.getObject("/list");
+ list2 = (List) cache2.getObject("/alias");
assertTrue("List size should not be 0 ", (list2.size() != 0));
assertEquals("Both listss should be equal ", list1, list2);
@@ -218,10 +224,10 @@
assertTrue("index of null ", list2.indexOf(null) == 1);
assertTrue("last index of null ", list2.lastIndexOf(null) == 3);
- list1.set(0,null); // set first element to null
- assertTrue("set first item to null",list2.get(0) == null);
- list1.set(0,"element 0");
- assertTrue("set first item to 'element 0'",list2.get(0).equals("element 0"));
+ list1.set(0, null); // set first element to null
+ assertTrue("set first item to null", list2.get(0) == null);
+ list1.set(0, "element 0");
+ assertTrue("set first item to 'element 0'", list2.get(0).equals("element 0"));
ListIterator listIter = list1.listIterator();
1.7 +42 -38 JBossCache/tests/functional/org/jboss/cache/aop/collection/ReplicatedSyncMapTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ReplicatedSyncMapTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/collection/ReplicatedSyncMapTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- ReplicatedSyncMapTest.java 20 Jul 2006 11:48:25 -0000 1.6
+++ ReplicatedSyncMapTest.java 6 Sep 2006 15:30:56 -0000 1.7
@@ -18,13 +18,14 @@
/**
* Test replicated Map
+ *
* @author Ben Wang
* @author Scott Marlow
*/
public class ReplicatedSyncMapTest extends TestCase
{
- Log log=LogFactory.getLog(ReplicatedSyncMapTest.class);
+ Log log = LogFactory.getLog(ReplicatedSyncMapTest.class);
PojoCache cache1;
PojoCache cache2;
@@ -49,12 +50,13 @@
cache2.stop();
}
- private PojoCache createCache(String name) throws Exception {
- PojoCache tree=new PojoCache();
+ private PojoCache createCache(String name) throws Exception
+ {
+ PojoCache tree = new PojoCache();
tree.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml"));
tree.getConfiguration().setClusterName(name);
- tree.createService();
- tree.startService();
+ tree.create();
+ tree.start();
return tree;
}
@@ -72,6 +74,7 @@
/**
* Test attachment and then detachment and attachment.
+ *
* @throws Exception
*/
public void testAttachDetach() throws Exception
@@ -81,7 +84,7 @@
Address addr = new Address();
addr.setCity("San Jose");
addr.setZip(95123);
- map1.put("key1",addr);
+ map1.put("key1", addr);
Address addr2 = new Address();
addr2.setCity("Santa Clara");
@@ -93,14 +96,14 @@
// Pure list
cache1.putObject("/map", map1);
- map1 = (Map)cache1.getObject("/map");
- map1.put("key2",addr2);
+ map1 = (Map) cache1.getObject("/map");
+ map1.put("key2", addr2);
cache1.removeObject("/map");
assertEquals("Detached map should still be", 2, map1.size());
map1.put("key3", addr3);
cache1.putObject("/map", map1);
- Map map2 = (Map)cache2.getObject("/map");
+ Map map2 = (Map) cache2.getObject("/map");
assertEquals("Map size should be ", 3, map2.size());
}
@@ -116,19 +119,19 @@
// Pure set
cache1.putObject("/map", map1);
// We specifically need to use Proxy otherwise it won't work with multiple references
- map1 = (Map)cache1.getObject("/map");
+ map1 = (Map) cache1.getObject("/map");
cache1.putObject("/alias", map1);
- Map map2 = (Map)cache1.getObject("/alias");
- Address add1 = (Address)((Map.Entry)map2.entrySet().iterator().next()).getValue();
+ Map map2 = (Map) cache1.getObject("/alias");
+ Address add1 = (Address) ((Map.Entry) map2.entrySet().iterator().next()).getValue();
assertNotNull("Address should not be null", add1);
assertEquals("Zip ", 95123, add1.getZip());
- map1 = (Map)cache2.getObject("/map");
- map2 = (Map)cache2.getObject("/alias");
+ map1 = (Map) cache2.getObject("/map");
+ map2 = (Map) cache2.getObject("/alias");
assertTrue("Map size should not be 0 ", (map2.size() != 0));
assertEquals("Both maps should be equal ", map1, map2);
- add1 = (Address)((Map.Entry)map2.entrySet().iterator().next()).getValue();
+ add1 = (Address) ((Map.Entry) map2.entrySet().iterator().next()).getValue();
assertNotNull("Address should not be null", add1);
assertEquals("Zip ", 95123, add1.getZip());
}
@@ -137,19 +140,19 @@
{
log.info("testNullWithSharedMap1() ....");
Map map1 = new HashMap();
- map1.put("null value test",null);
- map1.put(null,"null key test");
+ map1.put("null value test", null);
+ map1.put(null, "null key test");
// Pure set
cache1.putObject("/map", map1);
// We specifically need to use Proxy otherwise it won't work with multiple references
- map1 = (Map)cache1.getObject("/map");
+ map1 = (Map) cache1.getObject("/map");
cache1.putObject("/alias", map1);
- Map map2 = (Map)cache1.getObject("/alias");
+ Map map2 = (Map) cache1.getObject("/alias");
- map1 = (Map)cache2.getObject("/map");
- map2 = (Map)cache2.getObject("/alias");
+ map1 = (Map) cache2.getObject("/map");
+ map2 = (Map) cache2.getObject("/alias");
assertTrue("Map size should not be 0 ", (map2.size() != 0));
assertEquals("Both maps should be equal ", map1, map2);
@@ -161,18 +164,18 @@
assertTrue("containsKey test for null key", map2.containsKey(null));
assertTrue("containsValue test for null value", map2.containsValue(null));
- assertTrue("values (positive) null test",map2.values().contains(null));
+ assertTrue("values (positive) null test", map2.values().contains(null));
Collection walk = map1.values();
assertTrue(walk.remove(null));
- assertFalse("values (negative) null test",map2.values().contains(null));
+ assertFalse("values (negative) null test", map2.values().contains(null));
- assertTrue("values (positive) null test",map2.values().contains("null key test"));
+ assertTrue("values (positive) null test", map2.values().contains("null key test"));
assertTrue(walk.remove("null key test"));
- assertFalse("values (negative) null test",map2.values().contains("null key test"));
+ assertFalse("values (negative) null test", map2.values().contains("null key test"));
- map1.put("null value test",null);
- map1.put(null,"null key test");
+ map1.put("null value test", null);
+ map1.put(null, "null key test");
assertTrue("remove null item test", map1.remove(null).equals("null key test"));
@@ -196,11 +199,11 @@
cache2.putObject("/map1", map1);
cache2.putObject("/map2", map2);
- map1 = (Map)cache2.getObject("/map1");
- map2 = (Map)cache2.getObject("/map2");
+ map1 = (Map) cache2.getObject("/map1");
+ map2 = (Map) cache2.getObject("/map2");
assertTrue("Map size should not be 0 ", (map2.size() != 0));
assertEquals("Both maps should be equal ", map1.get("key1"), map2.get("key2"));
- Address add1 = (Address)((Map.Entry)map2.entrySet().iterator().next()).getValue();
+ Address add1 = (Address) ((Map.Entry) map2.entrySet().iterator().next()).getValue();
assertNotNull("Address should not be null", add1);
assertEquals("Zip ", 95123, add1.getZip());
}
@@ -214,7 +217,7 @@
addr.setZip(95123);
map1.put("key1_map1", addr);
map1.put("key2_map1", null);
- map1.put(null,"null value test");
+ map1.put(null, "null value test");
Map map2 = new HashMap();
map2.put("key1_map2", addr);
map2.put("key2_map2", "round");
@@ -225,8 +228,8 @@
cache2.putObject("/map1", map1);
cache2.putObject("/map2", map2);
- map1 = (Map)cache1.getObject("/map1");
- map2 = (Map)cache1.getObject("/map2");
+ map1 = (Map) cache1.getObject("/map1");
+ map2 = (Map) cache1.getObject("/map2");
assertTrue("key1 exists", map1.containsKey("key1_map1"));
assertTrue("null key exists", map1.containsKey(null));
@@ -234,19 +237,20 @@
Set set = map1.keySet();
Iterator iter = set.iterator();
- while(iter.hasNext()) {
+ while (iter.hasNext())
+ {
Object o = iter.next();
System.out.println("testKeySetRemoveWithSharedMap1 iter.next returned: " + o);
- if(o == null || "key1_map1".equals(o))
+ if (o == null || "key1_map1".equals(o))
iter.remove();
}
assertTrue("key2 exists", map1.containsKey("key2_map1"));
assertFalse("key1 doesn't exist", map1.containsKey("key1_map1"));
assertFalse("null key doesn't exist", map1.containsKey(null));
- map1 = (Map)cache2.getObject("/map1");
- map2 = (Map)cache2.getObject("/map2");
+ map1 = (Map) cache2.getObject("/map1");
+ map2 = (Map) cache2.getObject("/map2");
assertTrue("key2 exists", map1.containsKey("key2_map1"));
assertFalse("key1 doesn't exist", map1.containsKey("key1_map1"));
1.6 +31 -24 JBossCache/tests/functional/org/jboss/cache/aop/collection/ReplicatedSyncSetTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ReplicatedSyncSetTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/collection/ReplicatedSyncSetTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ReplicatedSyncSetTest.java 20 Jul 2006 09:03:52 -0000 1.5
+++ ReplicatedSyncSetTest.java 6 Sep 2006 15:30:56 -0000 1.6
@@ -17,12 +17,13 @@
/**
* Test object graph handling in aop, e.g., circular reference, multiple reference, link, etc.
+ *
* @author Ben Wang
*/
public class ReplicatedSyncSetTest extends TestCase
{
- Log log=LogFactory.getLog(ReplicatedSyncSetTest.class);
+ Log log = LogFactory.getLog(ReplicatedSyncSetTest.class);
PojoCache cache1;
PojoCache cache2;
@@ -47,14 +48,15 @@
cache2.stop();
}
- private PojoCache createCache(String name) throws Exception {
- PojoCache tree=new PojoCache();
+ private PojoCache createCache(String name) throws Exception
+ {
+ PojoCache tree = new PojoCache();
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = parser.parseFile("META-INF/replSync-service.xml"); // read in generic replAsync xml
tree.setConfiguration(c);
c.setClusterName(name);
- tree.createService();
- tree.startService();
+ tree.create();
+ tree.start();
return tree;
}
@@ -71,6 +73,7 @@
/**
* Test attachment and then detachment and attachment.
+ *
* @throws Exception
*/
public void testAttachDetach() throws Exception
@@ -92,14 +95,14 @@
// Pure list
cache1.putObject("/set", set1);
- set1 = (Set)cache1.getObject("/set");
+ set1 = (Set) cache1.getObject("/set");
set1.add(addr2);
cache1.removeObject("/set");
assertEquals("Detached set should still be", 2, set1.size());
set1.add(addr3);
cache1.putObject("/set", set1);
- Set set2 = (Set)cache2.getObject("/set");
+ Set set2 = (Set) cache2.getObject("/set");
assertEquals("Set size should be ", 3, set2.size());
}
@@ -115,19 +118,19 @@
// Pure set
cache1.putObject("/set", set1);
// We specifically need to use Proxy otherwise it won't work with multiple references
- set1 = (Set)cache1.getObject("/set");
+ set1 = (Set) cache1.getObject("/set");
cache1.putObject("/alias", set1);
- Set set2 = (Set)cache1.getObject("/alias");
- Address add1 = (Address)set2.iterator().next();
+ Set set2 = (Set) cache1.getObject("/alias");
+ Address add1 = (Address) set2.iterator().next();
assertNotNull("Address should not be null", add1);
assertEquals("Zip ", 95123, add1.getZip());
- set1 = (Set)cache2.getObject("/set");
- set2 = (Set)cache2.getObject("/alias");
+ set1 = (Set) cache2.getObject("/set");
+ set2 = (Set) cache2.getObject("/alias");
assertTrue("Set size should not be 0 ", (set2.size() != 0));
assertEquals("Both sets should be equal ", set1, set2);
- add1 = (Address)set2.iterator().next();
+ add1 = (Address) set2.iterator().next();
assertNotNull("Address should not be null", add1);
assertEquals("Zip ", 95123, add1.getZip());
}
@@ -146,8 +149,8 @@
cache1.putObject("/set1", set1);
cache1.putObject("/set2", set2);
- Address add2 = (Address)((Set)cache2.getObject("/set2")).iterator().next();
- Address add1 = (Address)((Set)cache2.getObject("/set1")).iterator().next();
+ Address add2 = (Address) ((Set) cache2.getObject("/set2")).iterator().next();
+ Address add1 = (Address) ((Set) cache2.getObject("/set1")).iterator().next();
assertEquals("Address should be the same", add1, add2);
assertEquals("Both shared object should be equal ", add2.getZip(), add1.getZip());
}
@@ -161,34 +164,38 @@
set1.add("element 2");
assertTrue("contains test for null value", set1.contains(null));
Object a1[] = set1.toArray();
- for(int looper =0; looper < a1.length; looper++){
+ for (int looper = 0; looper < a1.length; looper++)
+ {
System.out.println("contained values:" + a1[looper]);
}
// Pure set
cache1.putObject("/set", set1);
// We specifically need to use Proxy otherwise it won't work with multiple references
- set1 = (Set)cache1.getObject("/set");
+ set1 = (Set) cache1.getObject("/set");
cache1.putObject("/alias", set1);
- Set set2 = (Set)cache1.getObject("/alias");
+ Set set2 = (Set) cache1.getObject("/alias");
- set1 = (Set)cache2.getObject("/set");
- set2 = (Set)cache2.getObject("/alias");
+ set1 = (Set) cache2.getObject("/set");
+ set2 = (Set) cache2.getObject("/alias");
assertTrue("Set size should not be 0 ", (set2.size() != 0));
assertEquals("Both sets should be equal ", set1, set2);
a1 = set1.toArray();
- for(int looper =0; looper < a1.length; looper++){
+ for (int looper = 0; looper < a1.length; looper++)
+ {
System.out.println("contained values:" + a1[looper]);
}
assertTrue("contains test for null value", set1.contains(null));
assertTrue("contains test for null value", set2.contains(null));
Iterator iter = set1.iterator();
- while(iter.hasNext()) {
+ while (iter.hasNext())
+ {
Object val = iter.next();
- if("element 2".equals(val)) {
+ if ("element 2".equals(val))
+ {
iter.remove(); // remove element 2
}
}
More information about the jboss-cvs-commits
mailing list