public void testPojoCacheJmxIntegration() throws Exception
{
log.debug("+++ testPojoCacheJmxIntegration()");
mbeanServer = MBeanServerFactory.createMBeanServer("pojoCacheTest");
PojoCacheJmxWrapper wrapper = null;
try
{
// Register a cache
wrapper = new PojoCacheJmxWrapper();
// JBAS-4097 -- don't use a TransactionManagerLookup that will
// bind DummyTransactionManager into JNDI, as that will screw
// up other tests
wrapper.setTransactionManagerLookupClass(MockTransactionManagerLookup.class.getName());
wrapper.setCacheMode("REPL_SYNC");
mbeanServer.registerMBean(wrapper, new ObjectName(CACHE_OBJECT_NAME));
wrapper.create();
wrapper.start();
// Build up an SSO infrastructure based on LOCAL_ADDRESS
JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
MockSSOValve localValve = new MockSSOValve(mbeanServer);
localValve.setCacheConfig(CACHE_OBJECT_NAME);
localValve.setClusterManager(localSSOManager);
localSSOManager.setSSOLocalManager(localValve);
localSSOManager.start();
// Create an SSO that will have two sessions from local valve
localSSOManager.register("1", "FORM", "Brian", "password");
Manager localSessMgr1 = getSessionManager("A");
Session sess1 = new MockSession(localSessMgr1, "1");
localSSOManager.addSession("1", getFullyQualifiedSessionId(sess1));
Manager localSessMgr2 = getSessionManager("B");
Session sess2 = new MockSession(localSessMgr2, "2");
localSSOManager.addSession("1", getFullyQualifiedSessionId(sess2));
// Confirm that data is cached properly
assertEquals("SSO 1 has correct number of sessions", 2, localSSOManager.getSessionCount("1"));
}
finally
{
try
{
if (wrapper != null)
{
wrapper.stop();
wrapper.destroy();
}
}
catch (Exception ignored)
{
}