[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/pojo/jmx ...
Manik Surtani
manik at jboss.org
Tue Jul 3 08:00:56 EDT 2007
User: msurtani
Date: 07/07/03 08:00:56
Modified: tests/functional/org/jboss/cache/pojo/jmx
PojoCacheJmxWrapperTest.java
Log:
listener based fixes
Revision Changes Path
1.8 +18 -7 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.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- PojoCacheJmxWrapperTest.java 28 Jun 2007 16:53:40 -0000 1.7
+++ PojoCacheJmxWrapperTest.java 3 Jul 2007 12:00:56 -0000 1.8
@@ -7,6 +7,7 @@
package org.jboss.cache.pojo.jmx;
+import org.jboss.cache.CacheException;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -129,6 +130,7 @@
// }
//
+
public void testDuplicateInvocation() throws Exception
{
PojoCacheJmxWrapperMBean cache = registerWrapper();
@@ -154,6 +156,7 @@
wrapper.getPojoCache().getCache().addCacheListener(listener);
wrapper.create();
assertEquals("Correct state", CacheStatus.CREATED, wrapper.getCacheStatus());
+ listener.setDisrupt(true);
try
{
wrapper.start();
@@ -165,7 +168,7 @@
assertEquals("Correct state", CacheStatus.FAILED, wrapper.getCacheStatus());
- wrapper.getPojoCache().getCache().removeCacheListener(listener);
+ listener.setDisrupt(false);
wrapper.start();
@@ -173,20 +176,23 @@
wrapper.getPojoCache().attach("/a/b/c", null);
+ listener.setDisrupt(true);
+ // need to re-add the listener since the failed start would have nullified the notifier.
wrapper.getPojoCache().getCache().addCacheListener(listener);
+
try
{
wrapper.stop();
fail("Listener did not prevent stop");
}
- catch (IllegalStateException good)
+ catch (CacheException good)
{
}
assertEquals("Correct state", CacheStatus.FAILED, wrapper.getCacheStatus());
- wrapper.getPojoCache().getCache().removeCacheListener(listener);
+ listener.setDisrupt(false);
wrapper.stop();
assertEquals("Correct state", CacheStatus.STOPPED, wrapper.getCacheStatus());
@@ -196,20 +202,25 @@
@CacheListener
- class DisruptLifecycleListener
+ public class DisruptLifecycleListener
{
+ private boolean disrupt;
+
@CacheStarted
public void cacheStarted(Event e)
{
- throw new IllegalStateException("I don't want to start");
+ if (disrupt) throw new IllegalStateException("I don't want to start");
}
@CacheStopped
public void cacheStopped(Event e)
{
- throw new IllegalStateException("I don't want to stop");
+ if (disrupt) throw new IllegalStateException("I don't want to stop");
}
+ public void setDisrupt(boolean disrupt)
+ {
+ this.disrupt = disrupt;
+ }
}
-
}
More information about the jboss-cvs-commits
mailing list