[jboss-cvs] JBossAS SVN: r64819 - in trunk/testsuite/src/main/org/jboss/test/cluster: cache/bean and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 23 17:48:59 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-08-23 17:48:59 -0400 (Thu, 23 Aug 2007)
New Revision: 64819
Added:
trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Address.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/CacheObject.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Person.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTester.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterHome.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTester.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterHome.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTester.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterHome.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTester.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterHome.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTester.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterHome.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheMBeanUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheObjectMBeanUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/LocalUnitAopTest.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/PojoCacheMBeanUnitTestCase.java
Log:
[JBAS-4552] Move cache integration tests to cluster package
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Address.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/test/standAloneAop/Address.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Address.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Address.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.aop;
+
+
+
+/**
+ * Test class for TreeCacheAOP.
+ *
+ * @version $Revision$
+ */
+public class Address
+{
+ String street = null;
+ String city = null;
+ int zip = 0;
+
+ public String getStreet()
+ {
+ return street;
+ }
+
+ public void setStreet(String street)
+ {
+ this.street = street;
+ }
+
+ public String getCity()
+ {
+ return city;
+ }
+
+ public void setCity(String city)
+ {
+ this.city = city;
+ }
+
+ public int getZip()
+ {
+ return zip;
+ }
+
+ public void setZip(int zip)
+ {
+ this.zip = zip;
+ }
+
+ public String toString()
+ {
+ return "street=" + getStreet() + ", city=" + getCity() + ", zip=" + getZip();
+ }
+
+// public Object writeReplace() {
+// return this;
+// }
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/CacheObject.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/test/standAloneAop/CacheObject.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/CacheObject.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/CacheObject.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.aop;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * Object to bind in cache
+ */
+public class CacheObject implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 125549282065895229L;
+ private String id;
+ private Set identities;
+
+ public CacheObject(String id)
+ {
+ this.id = id;
+ this.identities = new HashSet();
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Set getIdentities()
+ {
+ return identities;
+ }
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Person.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/test/standAloneAop/Person.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Person.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/aop/Person.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.aop;
+
+import java.util.*;
+
+
+/**
+ * Test class for TreeCacheAOP.
+ * Person is a POJO that will be instrumented with CacheInterceptor
+ *
+ * @version $Revision$
+ */
+public class Person
+{
+ String name = null;
+ int age = 0;
+ Map hobbies = null;
+ Address address = null;
+ Set skills;
+ List languages;
+ // Test for transient field non-replication
+ transient String currentStatus = "Active";
+ // Test swapping out the Collection ref with proxy one
+ // medication will be different when age limit is exceeded.
+ List medication = null;
+ static final int AGE1 = 50;
+ static final int AGE2 = 60;
+
+ public Person() {
+
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public void setCurrentStatus(String status) {
+ currentStatus = status;
+ }
+
+ public String getCurrentStatus() {
+ return currentStatus;
+ }
+
+ public void setName(Object obj)
+ {
+ this.name = (String)obj;
+ }
+
+ public int getAge()
+ {
+ return age;
+ }
+
+ public void setAge(int age)
+ {
+
+ this.age = age;
+
+ // This will swap out the reference dynamically
+ if(age < AGE1) {
+ if(medication != null) {
+ medication.clear();
+ medication=null;
+ }
+ }
+ else {
+ if( age >= AGE1 ) {
+ addMedication("Lipitor");
+ }
+
+ if (age >= AGE2) {
+ addMedication("Vioxx");
+ }
+ }
+
+
+ }
+
+ void addMedication(String name) {
+ if( medication == null )
+ medication = new ArrayList();
+ if(!medication.contains(name))
+ medication.add(name);
+ }
+
+ public Map getHobbies()
+ {
+ return hobbies;
+ }
+
+ public void setHobbies(Map hobbies)
+ {
+ this.hobbies = hobbies;
+ }
+
+ public Address getAddress()
+ {
+ return address;
+ }
+
+ public void setAddress(Address address)
+ {
+ this.address = address;
+ }
+
+ public Set getSkills()
+ {
+ return skills;
+ }
+
+ public void setSkills(Set skills)
+ {
+ this.skills = skills;
+ }
+
+ public List getMedication()
+ {
+ return medication;
+ }
+
+ public void setMedication(List medication)
+ {
+ this.medication = medication;
+ }
+
+ public List getLanguages()
+ {
+ return languages;
+ }
+
+ public void setLanguages(List languages)
+ {
+ this.languages = languages;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb=new StringBuffer();
+ sb.append("name=").append(getName()).append(", age=").append(getAge()).append(", hobbies=")
+ .append(print(getHobbies())).append(", address=").append(getAddress()).append(", skills=")
+ .append(skills).append(", languages=").append(languages).toString();
+ if(medication != null)
+ sb.append(", medication=" + medication);
+ return sb.toString();
+ }
+
+ public String print(Map m)
+ {
+ StringBuffer sb = new StringBuffer();
+ Map.Entry entry;
+ if (m != null) {
+ for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
+ entry = (Map.Entry) it.next();
+ sb.append(entry.getKey()).append(": ").append(entry.getValue());
+ sb.append("\n");
+ }
+ }
+ return sb.toString();
+ }
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTester.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/CacheObjectMeanTester.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTester.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTester.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,16 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Remote interface for CacheObjectMeanTester.
+ */
+public interface CacheObjectMeanTester
+ extends javax.ejb.EJBObject
+{
+
+ public void bind( java.lang.String id )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterBean.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/CacheObjectMeanTesterBean.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterBean.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.bean;
+
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.test.cluster.cache.aop.CacheObject;
+
+/**
+ * @ejb.bean name="CacheObjectMeanTester"
+ * type="Stateless"
+ * view-type="remote"
+ * jndi-name="test/CacheObjectMeanTester"
+ *
+ * @ejb.home pattern="{0}Home"
+ *
+ * @ejb.interface pattern="{0}"
+ */
+public class CacheObjectMeanTesterBean implements SessionBean
+{
+ /** @ejb.interface-method */
+ public void bind(String id) throws Exception
+ {
+ MBeanServer server = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
+ PojoCache cache = (PojoCache)server.getAttribute(new ObjectName("jboss.cache:service=testTreeCacheAop"),
+ "PojoCache");
+ cache.attach(new Fqn(new Object[] {"sessions", id}).toString(), new CacheObject(id));
+ }
+
+ public void ejbCreate() throws CreateException
+ {
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ }
+
+ public void setSessionContext(SessionContext arg0)
+ {
+ }
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterHome.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/CacheObjectMeanTesterHome.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/CacheObjectMeanTesterHome.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,18 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Home interface for CacheObjectMeanTester.
+ */
+public interface CacheObjectMeanTesterHome
+ extends javax.ejb.EJBHome
+{
+ public static final String COMP_NAME="java:comp/env/ejb/CacheObjectMeanTester";
+ public static final String JNDI_NAME="test/CacheObjectMeanTester";
+
+ public CacheObjectMeanTester create()
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTester.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopMBeanTester.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTester.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTester.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,85 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Remote interface for test/TreeCacheAopMBeanTester.
+ */
+public interface TreeCacheAopMBeanTester
+ extends javax.ejb.EJBObject
+{
+
+ public void createPerson( java.lang.String key,java.lang.String name,int age )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void removePerson( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setName( java.lang.String key,java.lang.String name )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.String getName( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setAge( java.lang.String key,int age )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public int getAge( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setStreet( java.lang.String key,java.lang.String street )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.String getStreet( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setCity( java.lang.String key,java.lang.String city )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.String getCity( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setZip( java.lang.String key,int zip )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public int getZip( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.Object getHobby( java.lang.String key,java.lang.Object hobbyKey )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setHobby( java.lang.String key,java.lang.Object hobbyKey,java.lang.Object value )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.Object getLanguage( java.lang.String key,int index )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void addLanguage( java.lang.String key,java.lang.Object language )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void removeLanguage( java.lang.String key,java.lang.Object language )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public int getLanguagesSize( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.util.Set getSkills( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void addSkill( java.lang.String key,java.lang.String skill )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void removeSkill( java.lang.String key,java.lang.String skill )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void printPerson( java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void printCache( )
+ throws java.rmi.RemoteException;
+
+ public java.lang.Object getFieldValue( java.lang.String key,java.lang.String name )
+ throws java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterBean.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopMBeanTesterBean.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterBean.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,366 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.bean;
+
+import java.lang.reflect.Field;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.test.cluster.cache.aop.Address;
+import org.jboss.test.cluster.cache.aop.Person;
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * Proxy to the TreeCacheAop MBean.
+ * The AOP framework requires that classes are loaded by special classloaders (e.g UCL).
+ * This bean is used to execute tests within the server.
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ * @ejb.bean type="Stateful"
+ * name="test/TreeCacheAopMBeanTester"
+ * jndi-name="ejb/test/TreeCacheAopMBeanTester"
+ * view-type="remote"
+ * @ejb.transaction type="Supports"
+ */
+
+public class TreeCacheAopMBeanTesterBean implements SessionBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1285651899817677886L;
+
+ static final String OBJECT_NAME = "jboss.cache:service=testTreeCacheAop";
+ MBeanServer server;
+ ObjectName cacheService;
+
+ SessionContext ctx;
+ PojoCache cache;
+
+ Logger logger_ = Logger.getLogger(TreeCacheAopMBeanTesterBean.class);
+
+ public void ejbActivate() throws EJBException, RemoteException
+ {
+ }
+
+ public void ejbPassivate() throws EJBException, RemoteException
+ {
+ }
+
+ public void ejbRemove() throws EJBException, RemoteException
+ {
+ }
+
+ public void setSessionContext(SessionContext ctx) throws EJBException
+ {
+ this.ctx = ctx;
+ }
+
+ /**
+ * @ejb.create-method
+ */
+ public void ejbCreate() throws CreateException
+ {
+ init();
+ }
+
+ private void init() throws CreateException
+ {
+ init(OBJECT_NAME);
+ }
+
+ private void init(String name) throws CreateException
+ {
+ try {
+ cacheService = new ObjectName(name);
+ server = MBeanServerLocator.locate();
+ } catch (Exception ex) {
+ throw new CreateException(ex.toString());
+ }
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void createPerson(String key, String name, int age) throws Exception
+ {
+ Person p = new Person();
+ p.setName(name);
+ p.setAge(age);
+ p.setAddress(new Address());
+ server.invoke(cacheService, "putObject",
+ new Object[]{key, p},
+ new String[]{String.class.getName(),
+ Object.class.getName()});
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void removePerson(String key) throws Exception
+ {
+ server.invoke(cacheService, "removeObject",
+ new Object[]{key},
+ new String[]{String.class.getName()});
+ }
+
+
+ Object getPerson(String key) throws Exception
+ {
+ return server.invoke(cacheService, "getObject",
+ new Object[]{key},
+ new String[]{String.class.getName()});
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setName(String key, String name) throws Exception
+ {
+ ((Person) getPerson(key)).setName(name);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public String getName(String key) throws Exception
+ {
+ return ((Person) getPerson(key)).getName();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setAge(String key, int age) throws Exception
+ {
+ ((Person) getPerson(key)).setAge(age);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public int getAge(String key) throws Exception
+ {
+ return ((Person) getPerson(key)).getAge();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setStreet(String key, String street) throws Exception
+ {
+ ((Person) getPerson(key)).getAddress().setStreet(street);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public String getStreet(String key) throws Exception
+ {
+ return ((Person) getPerson(key)).getAddress().getStreet();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setCity(String key, String city) throws Exception
+ {
+ ((Person) getPerson(key)).getAddress().setCity(city);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public String getCity(String key) throws Exception
+ {
+ return ((Person) getPerson(key)).getAddress().getCity();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setZip(String key, int zip) throws Exception
+ {
+ ((Person) getPerson(key)).getAddress().setZip(zip);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public int getZip(String key) throws Exception
+ {
+ return ((Person) getPerson(key)).getAddress().getZip();
+ }
+
+ // Map operations
+
+ /**
+ * @ejb.interface-method
+ */
+ public Object getHobby(String key, Object hobbyKey) throws Exception
+ {
+ Map hobbies = ((Person) getPerson(key)).getHobbies();
+ return hobbies == null ? null : hobbies.get(hobbyKey);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setHobby(String key, Object hobbyKey, Object value) throws Exception
+ {
+ Person person = ((Person) getPerson(key));
+ Map hobbies = person.getHobbies();
+ if (hobbies == null) {
+ hobbies = new HashMap();
+ person.setHobbies(hobbies);
+ // NB: it is neccessary to get hobbies again to get advised version
+ hobbies = person.getHobbies();
+ }
+ hobbies.put(hobbyKey, value);
+ }
+
+ // List operations
+
+ /**
+ * @ejb.interface-method
+ */
+ public Object getLanguage(String key, int index) throws Exception
+ {
+ List languages = ((Person) getPerson(key)).getLanguages();
+ return languages == null ? null : languages.get(index);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void addLanguage(String key, Object language) throws Exception
+ {
+ Person person = ((Person) getPerson(key));
+ List languages = person.getLanguages();
+ if (languages == null) {
+ person.setLanguages(new ArrayList());
+ languages = person.getLanguages();
+ }
+ languages.add(language);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void removeLanguage(String key, Object language) throws Exception
+ {
+ List languages = ((Person) getPerson(key)).getLanguages();
+ if (languages == null) return;
+ languages.remove(language);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public int getLanguagesSize(String key) throws Exception
+ {
+ List languages = ((Person) getPerson(key)).getLanguages();
+ return languages == null ? 0 : languages.size();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public Set getSkills(String key) throws Exception
+ {
+ return new HashSet(((Person) getPerson(key)).getSkills());
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void addSkill(String key, String skill) throws Exception
+ {
+ Person person = ((Person) getPerson(key));
+ Set skills = person.getSkills();
+ if (skills == null) {
+ person.setSkills(new HashSet());
+ skills = person.getSkills();
+ }
+ skills.add(skill);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void removeSkill(String key, String skill) throws Exception
+ {
+ Person person = ((Person) getPerson(key));
+ Set skills = person.getSkills();
+ if (skills != null) {
+ skills.remove(skill);
+ }
+ }
+
+
+ /**
+ * @ejb.interface-method
+ */
+ public void printPerson(String key) throws Exception
+ {
+ System.out.println(getPerson(key));
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void printCache()
+ {
+ System.out.println(cache);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public Object getFieldValue(String key, String name)
+ {
+ try {
+ Object object = cache.find(key);
+ Field f = object.getClass().getDeclaredField(name);
+ f.setAccessible(true);
+ return f.get(object);
+ } catch (Exception e) {
+ throw new NestedRuntimeException(e);
+ }
+ }
+
+}
+
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterHome.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopMBeanTesterHome.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopMBeanTesterHome.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,18 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Home interface for test/TreeCacheAopMBeanTester.
+ */
+public interface TreeCacheAopMBeanTesterHome
+ extends javax.ejb.EJBHome
+{
+ public static final String COMP_NAME="java:comp/env/ejb/test/TreeCacheAopMBeanTester";
+ public static final String JNDI_NAME="ejb/test/TreeCacheAopMBeanTester";
+
+ public TreeCacheAopMBeanTester create()
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTester.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopTester.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTester.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTester.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,94 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Remote interface for test/TreeCacheAopTester.
+ */
+public interface TreeCacheAopTester
+ extends javax.ejb.EJBObject
+{
+
+ public void testSetup( )
+ throws java.rmi.RemoteException;
+
+ public void createPerson( java.lang.String key,java.lang.String name,int age )
+ throws java.rmi.RemoteException;
+
+ public void removePerson( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public void setName( java.lang.String key,java.lang.String name )
+ throws java.rmi.RemoteException;
+
+ public java.lang.String getName( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public void setAge( java.lang.String key,int age )
+ throws java.rmi.RemoteException;
+
+ public int getAge( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public void setStreet( java.lang.String key,java.lang.String street )
+ throws java.rmi.RemoteException;
+
+ public java.lang.String getStreet( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public void setCity( java.lang.String key,java.lang.String city )
+ throws java.rmi.RemoteException;
+
+ public java.lang.String getCity( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public void setZip( java.lang.String key,int zip )
+ throws java.rmi.RemoteException;
+
+ public int getZip( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public java.lang.Object getHobby( java.lang.String key,java.lang.Object hobbyKey )
+ throws java.rmi.RemoteException;
+
+ public void setHobby( java.lang.String key,java.lang.Object hobbyKey,java.lang.Object value )
+ throws java.rmi.RemoteException;
+
+ public java.lang.Object getLanguage( java.lang.String key,int index )
+ throws java.rmi.RemoteException;
+
+ public void addLanguage( java.lang.String key,java.lang.Object language )
+ throws java.rmi.RemoteException;
+
+ public void removeLanguage( java.lang.String key,java.lang.Object language )
+ throws java.rmi.RemoteException;
+
+ public int getLanguagesSize( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public java.util.Set getSkills( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public void addSkill( java.lang.String key,java.lang.String skill )
+ throws java.rmi.RemoteException;
+
+ public void removeSkill( java.lang.String key,java.lang.String skill )
+ throws java.rmi.RemoteException;
+
+ public java.lang.Object testSerialization( )
+ throws java.rmi.RemoteException;
+
+ public void testDeserialization( java.lang.String key,java.lang.Object value )
+ throws java.rmi.RemoteException;
+
+ public void printPerson( java.lang.String key )
+ throws java.rmi.RemoteException;
+
+ public void printCache( )
+ throws java.rmi.RemoteException;
+
+ public java.lang.Object getFieldValue( java.lang.String key,java.lang.String name )
+ throws java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterBean.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopTesterBean.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterBean.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,416 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.bean;
+
+import java.lang.reflect.Field;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+import org.jboss.aop.Advised;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheFactory;
+import org.jboss.logging.Logger;
+import org.jboss.test.cluster.cache.aop.Address;
+import org.jboss.test.cluster.cache.aop.Person;
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * Proxy to the TreeCacheAop MBean.
+ * The AOP framework requires that classes are loaded by special classloaders (e.g UCL).
+ * This bean is used to execute tests within the server.
+ *
+ * @author <a href="mailto:harald at gliebe.de">Harald Gliebe</a>
+ * @version $Revision$
+ * @ejb.bean type="Stateful"
+ * name="test/TreeCacheAopTester"
+ * jndi-name="test/TreeCacheAopTester"
+ * view-type="remote"
+ * @ejb.transaction type="Supports"
+ */
+
+public class TreeCacheAopTesterBean implements SessionBean
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -4783977385735822976L;
+ SessionContext ctx;
+ PojoCache cache;
+ PojoCache cache2;
+
+ Logger logger_ = Logger.getLogger(TreeCacheAopTesterBean.class);
+
+ public void ejbActivate() throws EJBException, RemoteException
+ {
+ }
+
+ public void ejbPassivate() throws EJBException, RemoteException
+ {
+ }
+
+ public void ejbRemove() throws EJBException, RemoteException
+ {
+ }
+
+ public void setSessionContext(SessionContext ctx) throws EJBException
+ {
+ this.ctx = ctx;
+ }
+
+ /**
+ * @ejb.create-method
+ */
+ public void ejbCreate(String cluster_name, String props, int caching_mode) throws CreateException
+ {
+ try {
+ Configuration config = new Configuration();
+ config.setClusterName(cluster_name);
+ config.setClusterConfig(props);
+ config.setCacheMode(Configuration.legacyModeToCacheMode(caching_mode));
+ cache = PojoCacheFactory.createCache(config, false);
+ cache.start();
+ cache2 = PojoCacheFactory.createCache(config, false);
+ cache2.start();
+ } catch (Exception e) {
+ throw new CreateException(e.toString());
+ }
+ }
+
+
+ /**
+ * @ejb.interface-method
+ */
+ public void testSetup()
+ {
+ Person p = new Person();
+ if (!(p instanceof Advised)) {
+ logger_.error("testSetup(): p is not an instance of Advised");
+ throw new RuntimeException("Person must be advised!");
+ }
+ Address a = new Address();
+ if (!(a instanceof Advised)) {
+ logger_.error("testSetup(): a is not an instance of Advised");
+ throw new RuntimeException("Address must be advised!");
+ }
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void createPerson(String key, String name, int age)
+ {
+ Person p = new Person();
+ p.setName(name);
+ p.setAge(age);
+ p.setAddress(new Address());
+ try {
+ cache.attach(key, p);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void removePerson(String key)
+ {
+ try {
+ cache.detach(key);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ Object getPerson(String key)
+ {
+ try {
+ return (Person) cache.find(key);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setName(String key, String name)
+ {
+ ((Person) getPerson(key)).setName(name);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public String getName(String key)
+ {
+ return ((Person) getPerson(key)).getName();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setAge(String key, int age)
+ {
+ ((Person) getPerson(key)).setAge(age);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public int getAge(String key)
+ {
+ return ((Person) getPerson(key)).getAge();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setStreet(String key, String street)
+ {
+ ((Person) getPerson(key)).getAddress().setStreet(street);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public String getStreet(String key)
+ {
+ return ((Person) getPerson(key)).getAddress().getStreet();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setCity(String key, String city)
+ {
+ ((Person) getPerson(key)).getAddress().setCity(city);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public String getCity(String key)
+ {
+ return ((Person) getPerson(key)).getAddress().getCity();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setZip(String key, int zip)
+ {
+ ((Person) getPerson(key)).getAddress().setZip(zip);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public int getZip(String key)
+ {
+ return ((Person) getPerson(key)).getAddress().getZip();
+ }
+
+ // Map operations
+
+ /**
+ * @ejb.interface-method
+ */
+ public Object getHobby(String key, Object hobbyKey)
+ {
+ Map hobbies = ((Person) getPerson(key)).getHobbies();
+ return hobbies == null ? null : hobbies.get(hobbyKey);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void setHobby(String key, Object hobbyKey, Object value)
+ {
+ Person person = ((Person) getPerson(key));
+ Map hobbies = person.getHobbies();
+ if (hobbies == null) {
+ hobbies = new HashMap();
+ person.setHobbies(hobbies);
+ // NB: it is neccessary to get hobbies again to get advised version
+ hobbies = person.getHobbies();
+ }
+ hobbies.put(hobbyKey, value);
+ }
+
+ // List operations
+
+ /**
+ * @ejb.interface-method
+ */
+ public Object getLanguage(String key, int index)
+ {
+ List languages = ((Person) getPerson(key)).getLanguages();
+ return languages == null ? null : languages.get(index);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void addLanguage(String key, Object language)
+ {
+ Person person = ((Person) getPerson(key));
+ List languages = person.getLanguages();
+ if (languages == null) {
+ person.setLanguages(new ArrayList());
+ languages = person.getLanguages();
+ }
+ languages.add(language);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void removeLanguage(String key, Object language)
+ {
+ List languages = ((Person) getPerson(key)).getLanguages();
+ if (languages == null) return;
+ languages.remove(language);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public int getLanguagesSize(String key)
+ {
+ List languages = ((Person) getPerson(key)).getLanguages();
+ return languages == null ? 0 : languages.size();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public Set getSkills(String key)
+ {
+ return new HashSet(((Person) getPerson(key)).getSkills());
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void addSkill(String key, String skill)
+ {
+ Person person = ((Person) getPerson(key));
+ Set skills = person.getSkills();
+ if (skills == null) {
+ person.setSkills(new HashSet());
+ skills = person.getSkills();
+ }
+ skills.add(skill);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void removeSkill(String key, String skill)
+ {
+ Person person = ((Person) getPerson(key));
+ Set skills = person.getSkills();
+ if (skills != null) {
+ skills.remove(skill);
+ }
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public Object testSerialization()
+ {
+ try {
+ Person p = new Person();
+ /*
+ if (!(p instanceof Externalizable)) {
+ throw new RuntimeException("p not Externalizable");
+ }
+ */
+ p.setName("Harald Gliebe");
+ Address address = new Address();
+ address.setCity("Mannheim");
+ p.setAddress(address);
+ cache.attach("/person/harald", p);
+ return (Person) cache.find("/person/harald");
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void testDeserialization(String key, Object value)
+ {
+ try {
+ cache.attach(key, value);
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void printPerson(String key)
+ {
+ System.out.println(getPerson(key));
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public void printCache()
+ {
+ System.out.println(cache);
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public Object getFieldValue(String key, String name)
+ {
+ try {
+ Object object = cache.find(key);
+ Field f = object.getClass().getDeclaredField(name);
+ f.setAccessible(true);
+ return f.get(object);
+ } catch (Exception e) {
+ throw new NestedRuntimeException(e);
+ }
+ }
+
+}
+
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterHome.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopTesterHome.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheAopTesterHome.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,18 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Home interface for test/TreeCacheAopTester.
+ */
+public interface TreeCacheAopTesterHome
+ extends javax.ejb.EJBHome
+{
+ public static final String COMP_NAME="java:comp/env/ejb/test/TreeCacheAopTester";
+ public static final String JNDI_NAME="test/TreeCacheAopTester";
+
+ public TreeCacheAopTester create(java.lang.String cluster_name , java.lang.String props , int caching_mode)
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTester.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheMBeanTester.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTester.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTester.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,70 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Remote interface for test/TreeCacheMBeanTester.
+ */
+public interface TreeCacheMBeanTester
+ extends javax.ejb.EJBObject
+{
+
+ public java.util.Vector getMembers( )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public int getCacheMode( )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setCacheMode( int mode )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public boolean getLocking( )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setLocking( boolean flag )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public int getLockingLevel( )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setLocking( int level )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.util.Set getKeys( java.lang.String fqn )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.Object get( java.lang.String fqn,java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public boolean exists( java.lang.String fqn )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void put( java.lang.String fqn,java.util.Map data )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void put( java.lang.String fqn,java.lang.String key,java.lang.Object value )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void remove( java.lang.String fqn )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.Object remove( java.lang.String fqn,java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void releaseAllLocks( java.lang.String fqn )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.String print( java.lang.String fqn )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.util.Set getChildrenNames( java.lang.String fqn )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.String printDetails( )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.String printLockInfo( )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterBean.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheMBeanTesterBean.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterBean.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.bean;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * EJB proxy to the TreeCache MBean service. Used to be able to transport
+ * user transactions from a test client to a TreeCache. Note that TreeCache MBean
+ * is deployed during a test case run and is persistent throughout that run only.
+ *
+ * @author Ben Wang
+ * @version $Revision$
+ * @ejb.bean type="Stateful"
+ * name="test/TreeCacheMBeanTester"
+ * jndi-name="ejb/test/TreeCacheMBeanTester"
+ * view-type="remote"
+ * @ejb.transaction type="Supports"
+ */
+public class TreeCacheMBeanTesterBean implements SessionBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8034966753463280684L;
+ // Use a different service name so that it won't collide with the regular name.
+ static final String OBJECT_NAME = "jboss.cache:service=testTreeCache";
+ MBeanServer server;
+ ObjectName cacheService;
+ PojoCache cache=null;
+
+ /**
+ * @throws CreateException
+ * @ejb.create-method
+ */
+ public void ejbCreate() throws CreateException
+ {
+ log("Creating TreeCache ejb proxy");
+ init();
+ }
+
+ /**
+ * @param name MBean object name.
+ * @throws CreateException
+ * @ejb.create-method
+ */
+ public void ejbCreate(String name) throws CreateException
+ {
+ log("I'm being created");
+ init(name);
+ }
+
+ private void init() throws CreateException
+ {
+ init(OBJECT_NAME);
+ }
+
+ private void init(String name) throws CreateException
+ {
+ try {
+ cacheService = new ObjectName(name);
+ server = MBeanServerLocator.locate();
+ cache=(PojoCache)server.getAttribute(new ObjectName("jboss.cache:service=testTreeCacheAop"),
+ "PojoCache");
+ } catch (Exception ex) {
+ throw new CreateException(ex.toString());
+ }
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ log("I'm being removed");
+ }
+
+ public void setSessionContext(SessionContext ctx)
+ {
+ }
+
+ /**
+ * @return
+ * @ejb.interface-method
+ */
+ public Vector getMembers() throws Exception
+ {
+ // FIXME restore after Cache exposes getMembers
+// return cache.getMembers();
+ throw new UnsupportedOperationException("See FIXME in bean code");
+ }
+
+ /**
+ * @return
+ * @ejb.interface-method
+ */
+ public int getCacheMode() throws Exception
+ {
+ return ((Integer) server.getAttribute(cacheService, "CacheMode")).intValue();
+ }
+
+ /**
+ * @param mode
+ * @ejb.interface-method
+ */
+ public void setCacheMode(int mode) throws Exception
+ {
+ server.setAttribute(cacheService, new Attribute("CacheMode",
+ new Integer(mode)));
+ }
+
+ /**
+ * @return
+ * @ejb.interface-method
+ */
+ public boolean getLocking() throws Exception
+ {
+ return ((Boolean) server.getAttribute(cacheService, "Locking")).booleanValue();
+ }
+
+ /**
+ * @param flag
+ * @ejb.interface-method
+ */
+ public void setLocking(boolean flag) throws Exception
+ {
+ server.setAttribute(cacheService, new Attribute("Locking",
+ new Boolean(flag)));
+ }
+
+ /**
+ * @return
+ * @ejb.interface-method
+ */
+ public int getLockingLevel() throws Exception
+ {
+ return ((Integer) server.getAttribute(cacheService, "LockingLevel")).intValue();
+ }
+
+ /**
+ * @param level
+ * @ejb.interface-method
+ */
+ public void setLocking(int level) throws Exception
+ {
+ server.setAttribute(cacheService, new Attribute("LockingLevel",
+ new Integer(level)));
+ }
+
+ /**
+ * @param fqn
+ * @return
+ * @ejb.interface-method
+ */
+ public Set getKeys(String fqn) throws Exception {
+ return (Set) server.invoke(cacheService, "getKeys",
+ new Object[]{fqn},
+ new String[]{String.class.getName()});
+ }
+
+ /**
+ * @param fqn
+ * @param key
+ * @return
+ * @ejb.interface-method
+ */
+ public Object get(String fqn, String key) throws Exception
+ {
+ return server.invoke(cacheService, "get",
+ new Object[]{fqn, key},
+ new String[]{String.class.getName(),
+ Object.class.getName()});
+ }
+
+ /**
+ * @param fqn
+ * @return
+ * @ejb.interface-method
+ */
+ public boolean exists(String fqn) throws Exception
+ {
+ return ((Boolean) server.invoke(cacheService, "exists",
+ new Object[]{fqn},
+ new String[]{String.class.getName()})).booleanValue();
+ }
+
+ /**
+ * @param fqn
+ * @param data
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public void put(String fqn, Map data) throws Exception
+ {
+ server.invoke(cacheService, "put",
+ new Object[]{fqn, data},
+ new String[]{String.class.getName(),
+ Map.class.getName()});
+ }
+
+ /**
+ * @param fqn
+ * @param key
+ * @param value
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public void put(String fqn, String key, Object value) throws Exception
+ {
+ Object[] args = {fqn, key, value};
+ String[] sig = {String.class.getName(),
+ Object.class.getName(),
+ Object.class.getName()};
+
+ server.invoke(cacheService, "put", args, sig);
+ }
+
+ /**
+ * @param fqn
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public void remove(String fqn) throws Exception
+ {
+ Object[] args = {fqn};
+ String[] sig = {String.class.getName()};
+
+ server.invoke(cacheService, "remove", args, sig);
+ }
+
+
+ /**
+ * @param fqn
+ * @param key
+ * @return
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public Object remove(String fqn, String key) throws Exception
+ {
+ return server.invoke(cacheService, "remove",
+ new Object[]{fqn, key},
+ new String[]{String.class.getName(),
+ String.class.getName()});
+ }
+
+ /**
+ * @param fqn
+ * @ejb.interface-method
+ */
+ public void releaseAllLocks(String fqn) throws Exception
+ {
+ server.invoke(cacheService, "releaseAllLocks",
+ new Object[]{fqn},
+ new String[]{String.class.getName()});
+ }
+
+ /**
+ * @param fqn
+ * @return
+ * @ejb.interface-method
+ */
+ public String print(String fqn) throws Exception
+ {
+ return (String) server.invoke(cacheService, "print",
+ new Object[]{fqn},
+ new String[]{String.class.getName()});
+ }
+
+ /**
+ * @param fqn
+ * @return
+ * @ejb.interface-method
+ */
+ public Set getChildrenNames(String fqn) throws Exception
+ {
+ return (Set) server.invoke(cacheService, "getChildrenNames",
+ new Object[]{fqn},
+ new String[]{String.class.getName()});
+ }
+
+ /**
+ * @return
+ * @ejb.interface-method
+ */
+ public String printDetails() throws Exception
+ {
+ return (String) server.invoke(cacheService, "printDetails",
+ null,
+ null);
+ }
+
+ /**
+ * @return
+ * @ejb.interface-method
+ */
+ public String printLockInfo() throws Exception
+ {
+ return (String) server.invoke(cacheService, "printLockInfo",
+ null,
+ null);
+ }
+
+ private void log(String msg)
+ {
+ System.out.println("-- [" + Thread.currentThread().getName() + "]: " + msg);
+ }
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterHome.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheMBeanTesterHome.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheMBeanTesterHome.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,21 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Home interface for test/TreeCacheMBeanTester.
+ */
+public interface TreeCacheMBeanTesterHome
+ extends javax.ejb.EJBHome
+{
+ public static final String COMP_NAME="java:comp/env/ejb/test/TreeCacheMBeanTester";
+ public static final String JNDI_NAME="ejb/test/TreeCacheMBeanTester";
+
+ public TreeCacheMBeanTester create()
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+ public TreeCacheMBeanTester create(java.lang.String name)
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTester.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheTester.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTester.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTester.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,58 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Remote interface for test/TreeCacheTester.
+ */
+public interface TreeCacheTester
+ extends javax.ejb.EJBObject
+{
+
+ public java.util.Vector getMembers( )
+ throws java.rmi.RemoteException;
+
+ public void setCacheMode( int mode )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void setIsolationLevel( org.jboss.cache.lock.IsolationLevel level )
+ throws java.rmi.RemoteException;
+
+ public java.util.Set getKeys( java.lang.String fqn )
+ throws org.jboss.cache.CacheException, java.rmi.RemoteException;
+
+ public java.lang.Object get( java.lang.String fqn,java.lang.String key )
+ throws org.jboss.cache.CacheException, java.rmi.RemoteException;
+
+ public boolean exists( java.lang.String fqn )
+ throws java.rmi.RemoteException;
+
+ public void put( java.lang.String fqn,java.util.Map data )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.Object put( java.lang.String fqn,java.lang.String key,java.lang.Object value )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void remove( java.lang.String fqn )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public java.lang.Object remove( java.lang.String fqn,java.lang.String key )
+ throws java.lang.Exception, java.rmi.RemoteException;
+
+ public void releaseAllLocks( java.lang.String fqn )
+ throws java.rmi.RemoteException;
+
+ public java.lang.String print( java.lang.String fqn )
+ throws java.rmi.RemoteException;
+
+ public java.util.Set getChildrenNames( java.lang.String fqn )
+ throws org.jboss.cache.CacheException, java.rmi.RemoteException;
+
+ public java.lang.String printDetails( )
+ throws java.rmi.RemoteException;
+
+ public java.lang.String printLockInfo( )
+ throws java.rmi.RemoteException;
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterBean.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheTesterBean.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterBean.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,340 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.cache.bean;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.IsolationLevel;
+
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+
+/**
+ * Proxy to the TreeCache MBean. Mainly used to be able to transport transactions from a test
+ * client to a TreeCache.
+ *
+ * @version $Revision$
+ * @ejb.bean type="Stateful"
+ * name="test/TreeCacheTester"
+ * jndi-name="ejb/test/TreeCacheTester"
+ * view-type="remote"
+ * @ejb.transaction type="Supports"
+ */
+public class TreeCacheTesterBean implements SessionBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 171897143867111119L;
+ Cache cache = null;
+
+ /**
+ * @throws CreateException
+ * @ejb.create-method
+ */
+ public void ejbCreate() throws CreateException
+ {
+ log("I'm being created");
+ }
+
+ /**
+ * @param cluster_name
+ * @param props
+ * @param caching_mode
+ * @throws CreateException
+ * @ejb.create-method
+ */
+ public void ejbCreate(String cluster_name,
+ String props,
+ int caching_mode) throws CreateException
+ {
+ try {
+// cache=new TreeCache(cluster_name, props, 10000);
+ Configuration config = new Configuration();
+ config.setClusterName(cluster_name);
+ config.setClusterConfig(props);
+ config.setCacheMode(Configuration.legacyModeToCacheMode(caching_mode));
+ config.setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
+
+ //cache = DefaultCacheFactory.getInstance().createCache(config);
+
+ } catch (Exception e) {
+ throw new CreateException(e.toString());
+ }
+ }
+
+
+// /**
+// *
+// * @param name
+// * @ejb.create-method
+// */
+// public void ejbCreate(String name) throws CreateException {
+// MBeanServer server=null;
+// ObjectName cache_service;
+//
+// try {
+// this.name=name;
+// cache_service=ObjectName.getInstance(name);
+//
+// // is this the right way to get hold of the JBoss MBeanServer ?
+// List servers=MBeanServerFactory.findMBeanServer(null);
+// if(servers == null || servers.size() == 0)
+// throw new CreateException("TreeCacheTesterBean.ejbCreate(): no MBeanServers found");
+// server=(MBeanServer)servers.get(0);
+// cache=(TreeCacheMBean)MBeanProxy.create(TreeCacheMBean.class, cache_service, server);
+// }
+// catch(Exception ex) {
+// throw new CreateException(ex.toString());
+// }
+// }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ log("I'm being removed");
+ if (cache != null) {
+ cache.stop();
+ cache.destroy();
+ cache = null;
+ }
+ }
+
+ public void setSessionContext(SessionContext ctx)
+ {
+ }
+
+
+ /**
+ * @return
+ * @ejb.interface-method
+ */
+ public Vector getMembers()
+ {
+ List members = cache.getMembers();
+ return members == null ? null : new Vector(members);
+ }
+
+
+ /**
+ * @param mode
+ * @ejb.interface-method
+ */
+ public void setCacheMode(int mode) throws Exception
+ {
+ cache.getConfiguration().setCacheMode(Configuration.legacyModeToCacheMode(mode));
+ }
+
+
+ /**
+ * @param level
+ * @ejb.interface-method
+ */
+ public void setIsolationLevel(IsolationLevel level)
+ {
+ cache.getConfiguration().setIsolationLevel(level);
+ }
+
+
+ /**
+ * @param fqn
+ * @return
+ * @ejb.interface-method
+ */
+ public Set getKeys(String fqn) throws CacheException
+ {
+ Node node = cache.getRoot().getChild(Fqn.fromString(fqn));
+ return node == null ? null : node.getKeys();
+ }
+
+ /**
+ * @param fqn
+ * @param key
+ * @return
+ * @ejb.interface-method
+ */
+ public Object get(String fqn, String key) throws CacheException {
+ return cache.get(Fqn.fromString(fqn), key);
+ }
+
+ /**
+ * @param fqn
+ * @return
+ * @ejb.interface-method
+ */
+ public boolean exists(String fqn)
+ {
+ return cache.getRoot().hasChild(Fqn.fromString(fqn));
+ }
+
+ /**
+ * @param fqn
+ * @param data
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public void put(String fqn, Map data) throws Exception
+ {
+ cache.put(Fqn.fromString(fqn), data);
+ }
+
+ /**
+ * @param fqn
+ * @param key
+ * @param value
+ * @return
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public Object put(String fqn, String key, Object value) throws Exception
+ {
+ return cache.put(Fqn.fromString(fqn), key, value);
+ }
+
+ /**
+ * @param fqn
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public void remove(String fqn) throws Exception
+ {
+ cache.removeNode(Fqn.fromString(fqn));
+ }
+
+ /**
+ * @param fqn
+ * @param key
+ * @return
+ * @throws Exception
+ * @ejb.interface-method
+ */
+ public Object remove(String fqn, String key) throws Exception
+ {
+ return cache.remove(Fqn.fromString(fqn), key);
+ }
+
+// /**
+// * @param fqn
+// * @ejb.interface-method
+// */
+// public void releaseAllLocks(String fqn)
+// {
+// cache.releaseAllLocks(fqn);
+// }
+//
+// /**
+// * @param fqn
+// * @return
+// * @ejb.interface-method
+// */
+// public String print(String fqn)
+// {
+// return cache.print(fqn);
+// }
+
+ /**
+ * @param fqn
+ * @return
+ * @ejb.interface-method
+ */
+ public Set getChildrenNames(String fqn) throws CacheException
+ {
+ Node node = cache.getRoot().getChild(Fqn.fromString(fqn));
+ return (node == null ? null : node.getChildrenNames());
+ }
+
+// /**
+// * @return
+// * @ejb.interface-method
+// */
+// public String printDetails()
+// {
+// return cache.printDetails();
+// }
+//
+// /**
+// * @return
+// * @ejb.interface-method
+// */
+// public String printLockInfo()
+// {
+// return cache.printLockInfo();
+// }
+
+ /**
+ * @ejb.interface-method
+ * @param members
+ * @param method
+ * @param args
+ * @param synchronous
+ * @param exclude_self
+ * @param timeout
+ * @return
+ * @throws Exception
+ */
+// public List callRemoteMethods(Vector members, Method method, Object[] args,
+// boolean synchronous, boolean exclude_self,
+// long timeout) throws Exception {
+// return cache.callRemoteMethods(members, method, args, synchronous,
+// exclude_self, timeout);
+// }
+
+ /**
+ * @param members
+ * @param method_name
+ * @param types
+ * @param args
+ * @param synchronous
+ * @param exclude_self
+ * @param timeout
+ * @return
+ * @throws Exception
+ * @ejb.interface-method
+ */
+// public List callRemoteMethods(Vector members, String method_name, Class[] types,
+// Object[] args, boolean synchronous,
+// boolean exclude_self, long timeout) throws Exception {
+// return cache.callRemoteMethods(members, method_name, types, args,
+// synchronous, exclude_self, timeout);
+// }
+
+ private void log(String msg)
+ {
+ System.out.println("-- [" + Thread.currentThread().getName() + "]: " + msg);
+ }
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterHome.java (from rev 64743, trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheTesterHome.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/cache/bean/TreeCacheTesterHome.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,21 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.jboss.test.cluster.cache.bean;
+
+/**
+ * Home interface for test/TreeCacheTester.
+ */
+public interface TreeCacheTesterHome
+ extends javax.ejb.EJBHome
+{
+ public static final String COMP_NAME="java:comp/env/ejb/test/TreeCacheTester";
+ public static final String JNDI_NAME="ejb/test/TreeCacheTester";
+
+ public TreeCacheTester create()
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+ public TreeCacheTester create(java.lang.String cluster_name , java.lang.String props , int caching_mode)
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheMBeanUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheMBeanUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheMBeanUnitTestCase.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,221 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.cache.test;
+
+import junit.framework.Test;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.cluster.cache.bean.TreeCacheMBeanTester;
+import org.jboss.test.cluster.cache.bean.TreeCacheMBeanTesterHome;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+import javax.transaction.UserTransaction;
+import java.util.Properties;
+
+/**
+ * Tests transactional access to a local TreeCache MBean service.
+ *
+ * @version $Revision$
+ */
+public class CacheMBeanUnitTestCase extends JBossTestCase
+{
+ TreeCacheMBeanTesterHome cache_home;
+ TreeCacheMBeanTester cache1 = null, cache2 = null;
+ Properties p_ = new Properties();
+
+
+ public CacheMBeanUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ mySetup();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ if (cache2 != null)
+ cache2.remove(); // calls stop()
+ if (cache1 != null)
+ cache1.remove();
+ }
+
+ public void mySetup() throws Exception
+ {
+ Object obj;
+
+ p_.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ p_.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
+ p_.put(Context.PROVIDER_URL, "localhost:1099");
+ obj = new InitialContext(p_).lookup(TreeCacheMBeanTesterHome.JNDI_NAME);
+ cache_home = (TreeCacheMBeanTesterHome) PortableRemoteObject.narrow(obj, TreeCacheMBeanTesterHome.class);
+ }
+
+
+ public void testSetup()
+ {
+ assertNotNull("TreeCacheMBeanTesterHome ", cache_home);
+ }
+
+ public void testPutTx()
+ {
+ UserTransaction tx = null;
+
+ try {
+ tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
+ assertNotNull("UserTransaction should not be null ", tx);
+ // Note that to set tree cache properties, you can do it here
+ // or go to transient-cache-service.xml.
+ cache1 = cache_home.create();
+
+ tx.begin();
+ cache1.put("/a/b/c", "age", new Integer(38));
+ assertEquals(new Integer(38), cache1.get("/a/b/c", "age"));
+
+ cache1.put("/a/b/c", "age", new Integer(39));
+ tx.commit();
+
+ tx.begin();
+ assertEquals(new Integer(39), cache1.get("/a/b/c", "age"));
+ tx.commit();
+
+ // Need to do cleanup ...
+ tx.begin();
+ cache1.remove("/a/b/c");
+ cache1.remove("/a/b");
+ cache1.remove("/a");
+ tx.commit();
+
+ } catch (Throwable t) {
+ fail(t.toString());
+ try {
+ tx.rollback();
+ } catch (Throwable t2) {
+ ;
+ }
+ fail(t.toString());
+ }
+ }
+
+
+ public void testRollbackTx()
+ {
+ UserTransaction tx = null;
+
+ try {
+ tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
+ // Note that to set tree cache properties, you can do it here
+ // or go to transient-cache-service.xml.
+ assertNotNull("UserTransaction should not be null ", tx);
+ cache1 = cache_home.create();
+ // cache1.setLocking(true);
+
+ tx.begin();
+ cache1.put("/a/b/c", "age", new Integer(38));
+ cache1.put("/a/b/c", "age", new Integer(39));
+ tx.rollback();
+
+ tx.begin();
+ Integer val = (Integer) cache1.get("/a/b/c", "age");
+ tx.commit();
+ assertNull(val);
+ } catch (Throwable t) {
+//t.printStackTrace();
+ fail(t.toString());
+ try {
+ tx.rollback();
+ } catch (Throwable t2) {
+ ;
+ }
+ fail(t.toString());
+ }
+ }
+
+ public void testReplicatedPutTx()
+ {
+ UserTransaction tx = null;
+
+ try {
+ tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
+ assertNotNull("UserTransaction should not be null ", tx);
+ // Note that to set tree cache properties, you can do it here
+ // or go to transient-cache-service.xml.
+ cache1 = cache_home.create();
+ cache2 = cache_home.create();
+
+ tx.begin();
+ cache1.put("/a/b/c", "age", new Integer(38));
+ assertEquals(new Integer(38), cache1.get("/a/b/c", "age"));
+
+ cache1.put("/a/b/c", "age", new Integer(39));
+ tx.commit();
+
+ tx.begin();
+ assertEquals(new Integer(39), cache2.get("/a/b/c", "age"));
+ tx.commit();
+
+ // Need to do cleanup ...
+ tx.begin();
+ cache1.remove("/a/b/c");
+ cache1.remove("/a/b");
+ cache1.remove("/a");
+ tx.commit();
+
+ } catch (Throwable t) {
+ fail(t.toString());
+ try {
+ tx.rollback();
+ } catch (Throwable t2) {
+ ;
+ }
+ fail(t.toString());
+ }
+ }
+
+ void log(String msg)
+ {
+ getLog().info("-- [" + Thread.currentThread() + "]: " + msg);
+ }
+
+
+ public static Test suite() throws Exception
+ {
+// return getDeploySetup(MBeanUnitTestCase.class, "cachetest.sar");
+ // Deploy the package recursively. The jar contains ejb and the sar file contains
+ // tree cache MBean service
+ return getDeploySetup(getDeploySetup(CacheMBeanUnitTestCase.class, "cachetest.jar"),
+ "cachetest.sar");
+// return new TestSuite(MBeanUnitTestCase.class);
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+
+}
Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheMBeanUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheObjectMBeanUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheObjectMBeanUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheObjectMBeanUnitTestCase.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.cache.test;
+
+import junit.framework.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Hashtable;
+import org.jboss.test.cluster.cache.bean.CacheObjectMeanTester;
+import org.jboss.test.cluster.cache.bean.CacheObjectMeanTesterHome;
+import org.jboss.test.JBossTestCase;
+
+/**
+ *
+ *
+ * @author Andrew D. May
+ */
+public class CacheObjectMBeanUnitTestCase extends JBossTestCase
+{
+
+ public static void main(String[] args) throws Exception
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Constructor for CacheObjectMBeanUnitTestCase.
+ * @param arg0
+ */
+ public CacheObjectMBeanUnitTestCase(String arg0)
+ {
+ super(arg0);
+ }
+
+ public void testBinding() throws Exception
+ {
+ Hashtable props = new Hashtable();
+ props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ props.put(Context.PROVIDER_URL, "localhost:1099");
+ Context ctx = new InitialContext(props);
+ CacheObjectMeanTesterHome home = (CacheObjectMeanTesterHome)ctx.lookup(
+ CacheObjectMeanTesterHome.JNDI_NAME);
+ CacheObjectMeanTester cacheTest = home.create();
+ cacheTest.bind("id12345");
+ }
+
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(getDeploySetup(CacheObjectMBeanUnitTestCase.class, "cachetest.jar"),
+ "cacheAoptest.sar");
+ }
+
+}
Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/CacheObjectMBeanUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/LocalUnitAopTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/LocalUnitAopTest.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/LocalUnitAopTest.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.cache.test;
+
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.aop.Advised;
+import org.jboss.aop.InstanceAdvisor;
+import org.jboss.cache.pojo.interceptors.AbstractInterceptor;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.cluster.cache.bean.TreeCacheAopTester;
+import org.jboss.test.cluster.cache.bean.TreeCacheAopTesterHome;
+import org.jboss.test.cluster.cache.aop.Person;
+
+
+/**
+ * LocalUnitTestCase.java
+ * <p/>
+ * <p/>
+ * Created: Mon May 05 17:30:11 2003
+ *
+ * @version $Id$
+ */
+
+//public class LocalUnitAopTest extends TestCase
+public class LocalUnitAopTest extends JBossTestCase
+{
+
+// Logger log = getLog();
+ Logger log = Logger.getLogger(LocalUnitAopTest.class);
+ TreeCacheAopTester tester;
+
+
+ public LocalUnitAopTest(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ log.info("setUp() ....");
+ TreeCacheAopTesterHome home = (TreeCacheAopTesterHome)
+ getInitialContext().lookup(TreeCacheAopTesterHome.JNDI_NAME);
+ tester = home.create(null, // no need for cluster name
+ null, // no need for properties
+ 1);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ tester.remove();
+ }
+
+ public void testDummy()
+ {
+ }
+
+ public void XtestSetup()
+ {
+ log.info("testSetup() ....");
+ try {
+ tester.testSetup();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("testSetup(): fails. " + ex.toString());
+ }
+ }
+
+ public void XtestSimple() throws Exception
+ {
+ log.info("testSimple() ....");
+ tester.createPerson("/person/test1", "Harald Gliebe", 32);
+ assertEquals(tester.getName("/person/test1"), "Harald Gliebe");
+ assertTrue(tester.getAge("/person/test1") == 32);
+ tester.removePerson("/person/test1");
+ }
+
+ public void XtestModification() throws Exception
+ {
+ tester.createPerson("/person/test2", "Harald", 32);
+ tester.setName("/person/test2", "Harald Gliebe");
+ assertEquals(tester.getName("/person/test2"), "Harald Gliebe");
+ tester.removePerson("/person/test2");
+ }
+
+ public void XtestRemove() throws Exception
+ {
+ tester.createPerson("/person/test3", "Harald", 32);
+ tester.removePerson("/person/test3");
+ try {
+ tester.getName("/person/test3");
+ fail("Object wasn't removed");
+ } catch (Exception e) {
+ // should be thrown
+ }
+ }
+
+ public void XtestDependent() throws Exception
+ {
+ tester.createPerson("/person/test4", "Harald Gliebe", 32);
+ tester.setCity("/person/test4", "Mannheim");
+ assertEquals(tester.getCity("/person/test4"), "Mannheim");
+ }
+
+
+ public void XtestSerialization() throws Throwable
+ {
+
+ Person p = (Person) tester.testSerialization();
+ if (p instanceof Advised) {
+ InstanceAdvisor advisor = ((Advised) p)._getInstanceAdvisor();
+ org.jboss.aop.advice.Interceptor[] interceptors = advisor.getInterceptors();
+ for (int i = 0; i < interceptors.length; i++) {
+ assertTrue("CacheInterceptor shouldn't be serialized",
+ !(interceptors[i] instanceof AbstractInterceptor));
+ }
+ }
+ assertEquals("Harald Gliebe", p.getName());
+ assertEquals("Mannheim", p.getAddress().getCity());
+ }
+
+ public void XtestDeserialization() throws Throwable
+ {
+
+ Person p = new Person();
+ p.setName("test6");
+ tester.testDeserialization("/person/test6", p);
+ String name = tester.getName("/person/test6");
+ assertEquals("test6", name);
+ }
+
+ public void XtestMap() throws Throwable
+ {
+ tester.createPerson("/person/test5", "Harald Gliebe", 32);
+ tester.setHobby("/person/test5", "music", "guitar");
+ Object val = tester.getHobby("/person/test5", "music");
+ assertEquals("guitar", val);
+ tester.setHobby("/person/test5", "a", "b");
+ tester.getHobby("/person/test5", "a");
+ tester.printPerson("/person/test5");
+ }
+
+ public void XtestList() throws Throwable
+ {
+ tester.createPerson("/person/test6", "p6", 50);
+ tester.addLanguage("/person/test6", "German");
+ tester.addLanguage("/person/test6", "English");
+ tester.addLanguage("/person/test6", "French");
+ int size = tester.getLanguagesSize("/person/test6");
+ assertTrue(size == 3);
+ tester.printCache();
+ tester.addLanguage("/person/test6", "asdf");
+ tester.printCache();
+ tester.removeLanguage("/person/test6", "asdf");
+ tester.printCache();
+ size = tester.getLanguagesSize("/person/test6");
+ // assertTrue(size==3);
+ for (int i = 0; i < size; i++) {
+ log.debug("" + i + " : " + tester.getLanguage("/person/test6", i));
+ }
+ assertEquals(new Integer(3), new Integer(size));
+ String language = (String) tester.getLanguage("/person/test6", 1);
+ assertEquals("English", language);
+ }
+
+ public void XtestSet() throws Throwable
+ {
+ tester.createPerson("/person/test7", "p7", 27);
+ tester.addSkill("/person/test7", "Java");
+ tester.addSkill("/person/test7", "Java");
+ tester.addSkill("/person/test7", "Java");
+ Set skills = tester.getSkills("/person/test7");
+ assertEquals(new Integer(1), new Integer(skills.size()));
+ tester.removeSkill("/person/test7", "Java");
+ skills = tester.getSkills("/person/test7");
+ assertTrue(skills.isEmpty());
+ tester.addSkill("/person/test7", "Java");
+ tester.addSkill("/person/test7", "J2EE");
+ tester.addSkill("/person/test7", "JBoss");
+ skills = tester.getSkills("/person/test7");
+ assertEquals(new Integer(3), new Integer(skills.size()));
+ }
+
+ public void XtestFieldSynchronization() throws Throwable
+ {
+ String key = "/person/test8";
+ tester.createPerson(key, "p8", 8);
+ assertEquals(tester.getName(key), tester.getFieldValue(key, "name"));
+ assertEquals(new Integer(tester.getAge(key)), tester.getFieldValue(key, "age"));
+ tester.setName(key, "p8x");
+ assertEquals(tester.getName(key), tester.getFieldValue(key, "name"));
+ tester.setAge(key, 18);
+ assertEquals(new Integer(tester.getAge(key)), tester.getFieldValue(key, "age"));
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(getDeploySetup(LocalUnitAopTest.class,
+ "cachetest.jar"),
+ "cachetest.aop");
+// return new TestSuite(LocalUnitAopTest.class);
+ }
+
+
+ public static void main(String[] args) throws Exception
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+}
+
Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/LocalUnitAopTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/PojoCacheMBeanUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/PojoCacheMBeanUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/PojoCacheMBeanUnitTestCase.java 2007-08-23 21:48:59 UTC (rev 64819)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.cache.test;
+
+import junit.framework.Test;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.cluster.cache.bean.TreeCacheAopMBeanTester;
+import org.jboss.test.cluster.cache.bean.TreeCacheAopMBeanTesterHome;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+import javax.transaction.UserTransaction;
+import java.util.Properties;
+
+/**
+ * Tests transactional access to a local TreeCache MBean service.
+ *
+ * @version $Revision$
+ */
+public class PojoCacheMBeanUnitTestCase extends JBossTestCase
+{
+ TreeCacheAopMBeanTesterHome cache_home;
+ TreeCacheAopMBeanTester cache1 = null, cache2 = null;
+ Properties p_ = new Properties();
+
+
+ public PojoCacheMBeanUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ mySetup();
+ }
+
+ public void tearDown() throws Exception
+ {
+ if (cache2 != null)
+ cache2.remove(); // calls stop()
+ if (cache1 != null)
+ cache1.remove();
+ }
+
+ public void mySetup() throws Exception
+ {
+ Object obj;
+
+ p_.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ p_.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
+ p_.put(Context.PROVIDER_URL, "localhost:1099");
+ obj = new InitialContext(p_).lookup(TreeCacheAopMBeanTesterHome.JNDI_NAME);
+ cache_home = (TreeCacheAopMBeanTesterHome) PortableRemoteObject.narrow(obj, TreeCacheAopMBeanTesterHome.class);
+ }
+
+
+ public void testSetup()
+ {
+ assertNotNull("TreeCacheAopTesterHome ", cache_home);
+ }
+
+ public void testPutObjectTx()
+ {
+ UserTransaction tx = null;
+
+ try {
+ tx = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
+ assertNotNull("UserTransaction should not be null ", tx);
+ // Note that to set tree cache properties, you can do it here
+ // or go to transient-cache-service.xml.
+ cache1 = cache_home.create();
+
+// tx.begin();
+ log("Create person ...");
+ cache1.createPerson("/aop/person", "Benito", 38);
+// tx.commit();
+
+// tx.begin();
+ log("check equalityu ...");
+ assertEquals(38, cache1.getAge("/aop/person"));
+// tx.commit();
+
+ } catch (Throwable t) {
+ fail(t.toString());
+ try {
+ tx.rollback();
+ } catch (Throwable t2) {
+ ;
+ }
+ fail(t.toString());
+ }
+ }
+
+
+ void _sleep(long timeout)
+ {
+ try {
+ Thread.sleep(timeout);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ void log(String msg)
+ {
+ getLog().info("-- [" + Thread.currentThread() + "]: " + msg);
+ }
+
+
+ public static Test suite() throws Exception
+ {
+// return getDeploySetup(MBeanUnitTestCase.class, "cachetest.sar");
+ // Deploy the package recursively. The jar contains ejb and the sar file contains
+ // tree cache MBean service
+ return getDeploySetup(getDeploySetup(PojoCacheMBeanUnitTestCase.class, "cachetest.jar"),
+ "cacheAoptest.sar");
+// return new TestSuite(MBeanUnitTestCase.class);
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+
+}
Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/cache/test/PojoCacheMBeanUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list