[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/jmx ...
Brian Stansberry
brian.stansberry at jboss.com
Mon Jun 4 18:56:11 EDT 2007
User: bstansberry
Date: 07/06/04 18:56:11
Modified: tests/functional/org/jboss/cache/jmx NotificationTest.java
Log:
[JBCACHE-1089] PojoCacheJmxWrapper should implement NotificationEmitter
Revision Changes Path
1.4 +56 -36 JBossCache/tests/functional/org/jboss/cache/jmx/NotificationTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NotificationTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/jmx/NotificationTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- NotificationTest.java 23 May 2007 10:28:53 -0000 1.3
+++ NotificationTest.java 4 Jun 2007 22:56:10 -0000 1.4
@@ -26,16 +26,16 @@
* Functional tests for CacheJmxWrapper broadcast of cache event notifications
*
* @author Jerry Gauthier
- * @version $Id: NotificationTest.java,v 1.3 2007/05/23 10:28:53 msurtani Exp $
+ * @version $Id: NotificationTest.java,v 1.4 2007/06/04 22:56:10 bstansberry Exp $
*/
public class NotificationTest extends TestCase
{
- private static final String CLUSTER_NAME = "NotificationTestCluster";
+ protected static final String CLUSTER_NAME = "NotificationTestCluster";
- private static final String CAPITAL = "capital";
- private static final String CURRENCY = "currency";
- private static final String POPULATION = "population";
- private static final String EUROPE_NODE = "Europe";
+ protected static final String CAPITAL = "capital";
+ protected static final String CURRENCY = "currency";
+ protected static final String POPULATION = "population";
+ protected static final String EUROPE_NODE = "Europe";
public enum Type
{
@@ -45,24 +45,31 @@
POSTPASSIVATE, VIEWCHANGE
}
- private MBeanServer m_server;
- private EnumSet<Type> events = EnumSet.noneOf(Type.class);
+ protected MBeanServer m_server;
+ protected EnumSet<Type> events = EnumSet.noneOf(Type.class);
- CacheImpl cache = null;
- boolean optimistic = false;
+ protected CacheImpl cache = null;
+ protected boolean optimistic = false;
protected void setUp() throws Exception
{
super.setUp();
m_server = MBeanServerFactory.createMBeanServer();
- cache = createCache(CLUSTER_NAME);
+
+ Object cacheMBean = createCacheAndJmxWrapper();
+
// bind manually for now.
ObjectName mgmt = getWrapperObjectName();
- CacheJmxWrapper cacheMBean = new CacheJmxWrapper(cache);
m_server.registerMBean(cacheMBean, mgmt);
}
+ protected Object createCacheAndJmxWrapper() throws Exception
+ {
+ cache = createCache(CLUSTER_NAME);
+ return new CacheJmxWrapper(cache);
+ }
+
protected void tearDown() throws Exception
{
try
@@ -79,17 +86,11 @@
}
}
- private void cleanup() throws Exception
+ protected void cleanup() throws Exception
{
events.clear();
- if (cache != null)
- {
- // stop the cache before the listener is unregistered
- //cache1.stop();
- cache.destroy();
- cache = null;
- }
+ destroyCache();
if (m_server != null)
{
@@ -99,7 +100,18 @@
}
}
- private ObjectName getWrapperObjectName() throws Exception
+ protected void destroyCache()
+ {
+ if (cache != null)
+ {
+ // stop the cache before the listener is unregistered
+ //cache1.stop();
+ cache.destroy();
+ cache = null;
+ }
+ }
+
+ protected ObjectName getWrapperObjectName() throws Exception
{
return new ObjectName(JmxUtil.PREFIX + CLUSTER_NAME);
}
@@ -264,24 +276,32 @@
private CacheImpl createCache(String clusterName) throws Exception
{
- CacheImpl cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
- cache.setConfiguration(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC));
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig("location=" + getTempDir()));
- cache.getConfiguration().setExposeManagementStatistics(true);
- cache.getConfiguration().setClusterName(clusterName);
- if (optimistic)
- {
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
- }
+ Configuration config = createConfiguration(clusterName);
+ CacheImpl cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(config, false);
+
cache.create();
// start the cache after the listener has been registered
//cache.start();
return cache;
}
- private String getTempDir()
+ protected Configuration createConfiguration(String clusterName) throws Exception
+ {
+ Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
+ config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ config.setCacheLoaderConfig(getCacheLoaderConfig("location=" + getTempDir()));
+ config.setExposeManagementStatistics(true);
+ config.setClusterName(clusterName);
+ if (optimistic)
+ {
+ config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ config.setNodeLockingScheme("OPTIMISTIC");
+ }
+
+ return config;
+ }
+
+ private static String getTempDir()
{
return System.getProperty("java.io.tempdir", "/tmp");
}
@@ -296,7 +316,7 @@
return (Boolean) parms[1];
}
- private static CacheLoaderConfig getCacheLoaderConfig(String properties) throws Exception
+ protected static CacheLoaderConfig getCacheLoaderConfig(String properties) throws Exception
{
String xml = "<config>\n" +
"<passivation>true</passivation>\n" +
More information about the jboss-cvs-commits
mailing list