[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/pojo/jmx ...
Brian Stansberry
brian.stansberry at jboss.com
Tue May 22 21:37:03 EDT 2007
User: bstansberry
Date: 07/05/22 21:37:03
Modified: tests/functional/org/jboss/cache/pojo/jmx
PojoCacheJmxWrapperTest.java
Log:
[JBCACHE-1058] Test duplicate invocations; lifecycle state
Revision Changes Path
1.3 +83 -0 JBossCache/tests/functional/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoCacheJmxWrapperTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- PojoCacheJmxWrapperTest.java 12 May 2007 03:54:15 -0000 1.2
+++ PojoCacheJmxWrapperTest.java 23 May 2007 01:37:03 -0000 1.3
@@ -9,8 +9,12 @@
import javax.management.ObjectName;
+import org.jboss.cache.AbstractCacheListener;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.LifecycleState;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.test.Person;
/**
@@ -124,4 +128,83 @@
assertEquals("Correct location", "/person/joe", wrapper.getInternalLocation(joe));
}
+ public void testDuplicateInvocation() throws Exception
+ {
+ PojoCacheJmxWrapperMBean cache = registerWrapper();
+ cache.create();
+ cache.start();
+ cache.create();
+ cache.start();
+
+ cache.getPojoCache().attach("/a/b/c", null);
+
+ cache.stop();
+ cache.destroy();
+ cache.stop();
+ cache.destroy();
+ }
+
+ public void testFailedStart() throws Exception
+ {
+ PojoCacheJmxWrapper wrapper = new PojoCacheJmxWrapper(createCache(createConfiguration()));
+ registerWrapper(wrapper);
+ assertEquals("Correct state", LifecycleState.INSTANTIATED, wrapper.getLifecycleState());
+ DisruptLifecycleListener listener = new DisruptLifecycleListener();
+ wrapper.getPojoCache().getCache().addCacheListener(listener);
+ wrapper.create();
+ assertEquals("Correct state", LifecycleState.CREATED, wrapper.getLifecycleState());
+ try
+ {
+ wrapper.start();
+ fail("Listener did not prevent start");
+ }
+ catch (PojoCacheException good) {}
+
+ assertEquals("Correct state", LifecycleState.FAILED, wrapper.getLifecycleState());
+
+ wrapper.getPojoCache().getCache().removeCacheListener(listener);
+
+ wrapper.start();
+
+ assertEquals("Correct state", LifecycleState.STARTED, wrapper.getLifecycleState());
+
+ wrapper.getPojoCache().attach("/a/b/c", null);
+
+ wrapper.getPojoCache().getCache().addCacheListener(listener);
+
+ try
+ {
+ wrapper.stop();
+ fail("Listener did not prevent stop");
+ }
+ catch (IllegalStateException good) {}
+
+ assertEquals("Correct state", LifecycleState.FAILED, wrapper.getLifecycleState());
+
+ wrapper.getPojoCache().getCache().removeCacheListener(listener);
+
+ wrapper.stop();
+ assertEquals("Correct state", LifecycleState.STOPPED, wrapper.getLifecycleState());
+ wrapper.destroy();
+ assertEquals("Correct state", LifecycleState.DESTROYED, wrapper.getLifecycleState());
+ }
+
+
+ class DisruptLifecycleListener extends AbstractCacheListener
+ {
+
+ @Override
+ public void cacheStarted(CacheSPI cache)
+ {
+ throw new IllegalStateException("I don't want to start");
+ }
+
+ @Override
+ public void cacheStopped(CacheSPI cache)
+ {
+ throw new IllegalStateException("I don't want to stop");
+ }
+
+ }
+
}
More information about the jboss-cvs-commits
mailing list