[jbosscache-commits] JBoss Cache SVN: r6184 - in core/trunk/src/test/java/org/jboss/cache: loader and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jul 7 10:38:23 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-07-07 10:38:23 -0400 (Mon, 07 Jul 2008)
New Revision: 6184

Modified:
   core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Improved tests

Modified: core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java	2008-07-07 10:53:27 UTC (rev 6183)
+++ core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java	2008-07-07 14:38:23 UTC (rev 6184)
@@ -1,10 +1,9 @@
 package org.jboss.cache.api;
 
-import org.jboss.cache.Cache;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Configuration.NodeLockingScheme;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -26,7 +25,7 @@
 @Test(groups = {"functional", "pessimistic"})
 public class DeletedChildResurrectionTest
 {
-   private Cache<Object, Object> cache;
+   private CacheSPI<Object, Object> cache;
    private static final Fqn<String> A_B = Fqn.fromString("/a/b");
    private static final Fqn<String> A = Fqn.fromString("/a");
    private static final Fqn<String> A_C = Fqn.fromString("/a/c");
@@ -35,15 +34,20 @@
    private static final String K2 = "k2";
    private static final String V2 = "v2";
    protected NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
+   protected NodeSPI root;
+   protected TransactionManager txManager;
 
    @BeforeMethod(alwaysRun = true)
    public void setUp()
    {
-      cache = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true), false);
+      cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true), false);
       cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+      cache.getConfiguration().setCacheLoaderConfig(null);
       cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
       configure(cache.getConfiguration());
       cache.start();
+      root = cache.getRoot();
+      txManager = cache.getTransactionManager();
    }
 
    @AfterMethod(alwaysRun = true)
@@ -59,11 +63,6 @@
 
    public void testDeletedChildResurrection1() throws Exception
    {
-      CacheSPI spi = (CacheSPI) cache;
-      Node<Object, Object> root = cache.getRoot();
-
-      TransactionManager txManager = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
-
       root.addChild(A_B).put(KEY, VALUE);
       cache.put(A, "key", "value");
       txManager.begin();
@@ -73,7 +72,7 @@
       assert !root.hasChild(A_B);
       assert null == cache.get(A, "key");
       // do a peek to ensure the node really has been removed and not just marked for removal
-      assert spi.peek(A_B, true, true) == null;
+      assert cache.peek(A_B, true, true) == null;
       assert root.hasChild(A);
    }
 
@@ -84,10 +83,6 @@
     */
    public void testDeletedChildResurrection2() throws Exception
    {
-      Node<Object, Object> root = cache.getRoot();
-
-      TransactionManager txManager = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
-
       root.addChild(A_B).put(KEY, VALUE);
 
       txManager.begin();

Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java	2008-07-07 10:53:27 UTC (rev 6183)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java	2008-07-07 14:38:23 UTC (rev 6184)
@@ -13,6 +13,7 @@
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.statetransfer.StateTransferManager;
 import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.util.TestingUtil;
 import org.jboss.util.stream.MarshalledValueInputStream;
 import org.jboss.util.stream.MarshalledValueOutputStream;
 import static org.testng.AssertJUnit.*;
@@ -87,28 +88,9 @@
    @AfterMethod(alwaysRun = true)
    public void tearDown() throws Exception
    {
-      log.warn("********* Starting tearDown()");
       cleanup();
-      try
-      {
-         cache.removeNode(Fqn.ROOT);
-      }
-      catch (Exception e)
-      {
-         // do nothing
-      }
-
-      try
-      {
-         loader.remove(Fqn.ROOT);
-      }
-      catch (Exception e)
-      {
-         // do nothing
-      }
-
-      cache.stop();
-      cache.destroy();
+      loader.remove(Fqn.ROOT);
+      TestingUtil.killCaches(cache);
    }
 
    protected void cleanup()




More information about the jbosscache-commits mailing list