[jbosscache-commits] JBoss Cache SVN: r4547 - core/trunk/src/test/java/org/jboss/cache/loader.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Oct 5 04:30:54 EDT 2007


Author: manik.surtani at jboss.com
Date: 2007-10-05 04:30:54 -0400 (Fri, 05 Oct 2007)
New Revision: 4547

Modified:
   core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
Log:
Fixed failing tests

Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java	2007-10-05 07:46:18 UTC (rev 4546)
+++ core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java	2007-10-05 08:30:54 UTC (rev 4547)
@@ -71,7 +71,7 @@
          c6 = cf.getConnection();
          fail("Should have produced an SQLException indicating that it timed out checking out a Connection");
       }
-      catch (IllegalStateException ise)
+      catch (Exception good)
       {
       }
       finally

Modified: core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java	2007-10-05 07:46:18 UTC (rev 4546)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java	2007-10-05 08:30:54 UTC (rev 4547)
@@ -6,23 +6,21 @@
  */
 package org.jboss.cache.loader;
 
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.io.File;
-
-import javax.transaction.TransactionManager;
-
 import org.jboss.cache.CacheImpl;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
 import org.jboss.cache.xml.XmlHelper;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
+import javax.transaction.TransactionManager;
+
 /**
  * Tests ignoreModifications and tests contents of individual loaders
  *
@@ -31,9 +29,6 @@
 @Test(groups = {"functional"})
 public class ChainingCacheLoaderFullTest
 {
-   private String loc1 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-1";
-   private String loc2 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-2";
-
    private CacheImpl<Object, Object> cache;
    private ChainingCacheLoader chainingCacheLoader;
    private CacheLoader loader1, loader2;
@@ -42,30 +37,22 @@
    private String value = "value";
 
 
-   public ChainingCacheLoaderFullTest()
-   {
-      File dir1 = new File(loc1);
-      File dir2 = new File(loc2);
-
-      if (!dir1.exists()) dir1.mkdirs();
-      if (!dir2.exists()) dir2.mkdirs();
-   }
-
    protected void startCache(boolean ignoreMods1, boolean ignoreMods2) throws Exception
    {
       cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache(false);
-      cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(loc1, loc2, ignoreMods1, ignoreMods2));
+      cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(ignoreMods1, ignoreMods2));
 
-      TestingUtil.recursiveFileRemove(loc1);
-      TestingUtil.recursiveFileRemove(loc2);
-
-      cache.getConfiguration().setCacheMode("local");
-      cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+      cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+      cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       cache.start();
 
       chainingCacheLoader = (ChainingCacheLoader) cache.getCacheLoaderManager().getCacheLoader();
       loader1 = chainingCacheLoader.getCacheLoaders().get(0);
       loader2 = chainingCacheLoader.getCacheLoaders().get(1);
+
+      // we need to make sure we have the raw loaders - not the "ReadOnly.." wrapped versions.
+      while (loader1 instanceof AbstractDelegatingCacheLoader) loader1 = ((AbstractDelegatingCacheLoader) loader1).getCacheLoader();
+      while (loader2 instanceof AbstractDelegatingCacheLoader) loader2 = ((AbstractDelegatingCacheLoader) loader2).getCacheLoader();
    }
 
    protected void cleanup() throws Exception
@@ -75,24 +62,22 @@
       cache = null;
    }
 
-   protected CacheLoaderConfig getCacheLoaderConfig(String loc1, String loc2, boolean ignoreMods1, boolean ignoreMods2) throws Exception
+   protected CacheLoaderConfig getCacheLoaderConfig(boolean ignoreMods1, boolean ignoreMods2) throws Exception
    {
       String xml = "<config>\n" +
                    "<passivation>false</passivation>\n" +
                    "<preload></preload>\n" +
                    "<cacheloader>\n" +
-                   "<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
+                   "<class>"+ DummyInMemoryCacheLoader.class.getName() +"</class>\n" +
                    "<properties>" +
-                   " location=" + loc1 + "\n" +
                    "</properties>\n" +
                    "<async>false</async>\n" +
                    "<fetchPersistentState>true</fetchPersistentState>\n" +
                    "<ignoreModifications>" + ignoreMods1 + "</ignoreModifications>\n" +
                    "</cacheloader>\n" +
                    "<cacheloader>\n" +
-                   "<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
+                   "<class>"+ DummyInMemoryCacheLoader.class.getName() +"</class>\n" +
                    "<properties>" +
-                   " location=" + loc2 + "\n" +
                    "</properties>\n" +
                    "<async>false</async>\n" +
                    "<fetchPersistentState>false</fetchPersistentState>\n" +




More information about the jbosscache-commits mailing list