[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/api ...
Manik Surtani
msurtani at jboss.com
Thu Jan 4 09:36:00 EST 2007
User: msurtani
Date: 07/01/04 09:36:00
Modified: tests/functional/org/jboss/cache/api SyncReplTxTest.java
CacheSPITest.java
Log:
fixed stuff
Revision Changes Path
1.6 +30 -7 JBossCache/tests/functional/org/jboss/cache/api/SyncReplTxTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SyncReplTxTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/api/SyncReplTxTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- SyncReplTxTest.java 4 Jan 2007 05:35:37 -0000 1.5
+++ SyncReplTxTest.java 4 Jan 2007 14:36:00 -0000 1.6
@@ -9,6 +9,7 @@
import junit.framework.TestCase;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
@@ -29,14 +30,14 @@
*/
public class SyncReplTxTest extends TestCase
{
- private Cache[] caches;
+ private CacheSPI[] caches;
protected void setUp()
{
System.out.println("*** In setUp()");
- caches = new Cache[2];
- caches[0] = DefaultCacheFactory.getInstance().createCache("META-INF/replSync-service.xml");
- caches[1] = DefaultCacheFactory.getInstance().createCache("META-INF/replSync-service.xml");
+ caches = new CacheSPI[2];
+ caches[0] = (CacheSPI) DefaultCacheFactory.getInstance().createCache("META-INF/replSync-service.xml");
+ caches[1] = (CacheSPI) DefaultCacheFactory.getInstance().createCache("META-INF/replSync-service.xml");
TestingUtil.blockUntilViewsReceived(caches, 5000);
System.out.println("*** Finished setUp()");
@@ -47,10 +48,32 @@
System.out.println("*** In tearDown()");
if (caches != null)
{
- for (Cache c : caches)
+ for (CacheSPI c : caches)
+ {
+ if (c != null)
+ {
+ Transaction t;
+
+ try
+ {
+ if ((t = c.getTransactionManager().getTransaction()) != null)
+ {
+ try
{
+ t.rollback();
+ }
+ catch (SystemException e)
+ {
+ // do nothing
+ }
+ }
+ }
+ catch (SystemException e)
+ {
+ // do nothing
+ }
c.stop();
- c = null;
+ }
}
caches = null;
}
1.5 +59 -2 JBossCache/tests/functional/org/jboss/cache/api/CacheSPITest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheSPITest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/api/CacheSPITest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- CacheSPITest.java 3 Jan 2007 23:45:56 -0000 1.4
+++ CacheSPITest.java 4 Jan 2007 14:36:00 -0000 1.5
@@ -2,6 +2,8 @@
import junit.framework.TestCase;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.DefaultCacheFactory;
import org.jboss.cache.factories.XmlConfigurationParser;
@@ -82,8 +84,8 @@
Configuration conf2 = parser.parseFile("META-INF/replSync-service.xml");
- CacheSPI cache1 = (CacheSPI) DefaultCacheFactory.getInstance().createCache(conf1, false);
- CacheSPI cache2 = (CacheSPI) DefaultCacheFactory.getInstance().createCache(conf2, false);
+ cache1 = (CacheSPI) DefaultCacheFactory.getInstance().createCache(conf1, false);
+ cache2 = (CacheSPI) DefaultCacheFactory.getInstance().createCache(conf2, false);
cache1.start();
assertTrue("Cache1 is coordinator", cache1.getRPCManager().isCoordinator());
@@ -96,4 +98,59 @@
assertTrue("Cache2 is coordinator", cache2.getRPCManager().isCoordinator());
}
+
+ public void testDeepOperations() throws Exception
+ {
+ // only use 1 cache
+ cache1.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ cache1.start();
+
+ Fqn A = Fqn.fromString("/a");
+ Fqn B = Fqn.fromString("/b");
+ Fqn A_B = Fqn.fromString("/a/b");
+
+ NodeSPI nodeA, nodeB;
+
+ cache1.put(A, "k", "v");
+ cache1.put(A_B, "k", "v");
+
+ nodeA = cache1.getRoot().getChildDirect(A); // should work
+ try
+ {
+ nodeB = cache1.getRoot().getChildDirect(A_B); // should fail
+ fail("Should have failed");
+ }
+ catch (UnsupportedOperationException e)
+ {
+ // expected
+ }
+
+ nodeB = nodeA.getChildDirect(B); // should work
+ try
+ {
+ cache1.getRoot().removeChildDirect(A_B); // should fail
+ fail("Should have failed");
+ }
+ catch (UnsupportedOperationException e)
+ {
+ // expected
+ }
+
+ nodeA.removeChildDirect(B); // should work
+ cache1.getRoot().removeChildDirect(A); // should work
+
+ try
+ {
+ cache1.getRoot().addChildDirect(A_B); // should fail
+ fail("Should have failed");
+ }
+ catch (UnsupportedOperationException e)
+ {
+ // expected
+ }
+ nodeA = cache1.getRoot().addChildDirect(A); // should work
+ nodeA.addChildDirect(B); // should work
+
+
+ }
}
More information about the jboss-cvs-commits
mailing list