[jboss-cvs] JBossCache/tests/functional/org/jboss/cache ...
Manik Surtani
manik at jboss.org
Tue Jul 17 10:44:23 EDT 2007
User: msurtani
Date: 07/07/17 10:44:23
Modified: tests/functional/org/jboss/cache LifeCycleTest.java
Log:
JBCACHE-1100
Revision Changes Path
1.14 +86 -1 JBossCache/tests/functional/org/jboss/cache/LifeCycleTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LifeCycleTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/LifeCycleTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- LifeCycleTest.java 17 Jul 2007 14:17:27 -0000 1.13
+++ LifeCycleTest.java 17 Jul 2007 14:44:22 -0000 1.14
@@ -20,7 +20,7 @@
* Tests restart (stop-destroy-create-start) of CacheImpl
*
* @author Bela Ban
- * @version $Id: LifeCycleTest.java,v 1.13 2007/07/17 14:17:27 msurtani Exp $
+ * @version $Id: LifeCycleTest.java,v 1.14 2007/07/17 14:44:22 msurtani Exp $
*/
public class LifeCycleTest extends TestCase
{
@@ -188,6 +188,91 @@
assertEquals("Correct state", CacheStatus.DESTROYED, cache.getCacheStatus());
}
+ public void testInvalidStateInvocations() throws Exception
+ {
+ Cache c = createCache(Configuration.CacheMode.LOCAL);
+ try
+ {
+ try
+ {
+ c.get(Fqn.ROOT, "k");
+ fail("Cache isn't ready!");
+ }
+ catch (IllegalStateException good)
+ {
+ }
+
+ c.create();
+ try
+ {
+ c.get(Fqn.ROOT, "k");
+ fail("Cache isn't ready!");
+ }
+ catch (IllegalStateException good)
+ {
+ }
+
+ c.start();
+ c.get(Fqn.ROOT, "k"); // should work
+
+ c.stop();
+
+ try
+ {
+ c.get(Fqn.ROOT, "k");
+ fail("Cache isn't ready!");
+ }
+ catch (IllegalStateException good)
+ {
+ }
+
+ c.destroy();
+ try
+ {
+ c.get(Fqn.ROOT, "k");
+ fail("Cache isn't ready!");
+ }
+ catch (IllegalStateException good)
+ {
+ }
+ }
+ finally
+ {
+ c.stop();
+ }
+ }
+
+ public void testRemoteInvalidStateInvocations() throws Exception
+ {
+ CacheImpl c1 = createCache(Configuration.CacheMode.REPL_SYNC);
+ CacheImpl c2 = createCache(Configuration.CacheMode.REPL_SYNC);
+ try
+ {
+ // need to start them both first to ensure they see each other
+ c1.start();
+ c2.start();
+
+ // now DIRECTLY change the status of c2.
+ // emulate the race condition where the remote cache is stopping but hasn't disconnected from the channel.
+ c2.cacheStatus = CacheStatus.STOPPING;
+
+ try
+ {
+ c1.put(Fqn.ROOT, "k", "v");
+ fail("Cache isn't ready!");
+ }
+ catch (IllegalStateException good)
+ {
+ }
+ }
+ finally
+ {
+ c1.stop();
+ c2.stop();
+ }
+ }
+
+
CacheImpl createCache(Configuration.CacheMode cache_mode) throws Exception
{
CacheImpl retval = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
More information about the jboss-cvs-commits
mailing list