[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/statetransfer ...
Vladmir Blagojevic
vladimir.blagojevic at jboss.com
Mon Sep 11 15:28:11 EDT 2006
User: vblagojevic
Date: 06/09/11 15:28:11
Modified: tests/functional/org/jboss/cache/statetransfer
StateTransferTestBase.java VersionedTestBase.java
Log:
added cacheloader compatibility tests
Revision Changes Path
1.21 +38 -33 JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StateTransferTestBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- StateTransferTestBase.java 7 Sep 2006 17:42:29 -0000 1.20
+++ StateTransferTestBase.java 11 Sep 2006 19:28:11 -0000 1.21
@@ -22,8 +22,6 @@
package org.jboss.cache.statetransfer;
-import junit.framework.TestCase;
-
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
@@ -32,6 +30,7 @@
import org.jboss.cache.factories.CacheFactory;
import org.jboss.cache.factories.DefaultCacheFactory;
import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
import org.jboss.cache.xml.XmlHelper;
import org.w3c.dom.Element;
@@ -39,6 +38,7 @@
import java.io.File;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
/**
@@ -47,7 +47,7 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-public abstract class StateTransferTestBase extends TestCase
+public abstract class StateTransferTestBase extends AbstractCacheLoaderTestBase
{
public static final Fqn A_B = Fqn.fromString("/a/b");
public static final Fqn A_C = Fqn.fromString("/a/c");
@@ -147,9 +147,34 @@
configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader", cacheID, useExtended, async);
}
- protected void configureCacheLoader(Configuration c, String cacheloaderClass, String cacheID, boolean useExtended, boolean async)
- throws Exception
+ protected void configureCacheLoader(Configuration c, String cacheloaderClass, String cacheID, boolean useExtended,
+ boolean async) throws Exception
+ {
+ if (cacheloaderClass != null)
+ {
+ if (cacheloaderClass.equals("org.jboss.cache.loader.JDBCCacheLoader"))
+ {
+ Properties prop = new Properties();
+ try
{
+ prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error loading jdbc properties ");
+ }
+ String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" + "cache.jdbc.url="
+ + prop.getProperty("cache.jdbc.url") + "\n" + "cache.jdbc.user="
+ + prop.getProperty("cache.jdbc.user") + "\n" + "cache.jdbc.password="
+ + prop.getProperty("cache.jdbc.password") + "\n" + "cache.jdbc.node.type="
+ + prop.getProperty("cache.jdbc.node.type");
+
+ c.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader",
+ props, false, true, false));
+ }
+ else
+ {
+
String tmp_location = getTempLocation(cacheID);
// Do cleanup in case it failed before
@@ -159,30 +184,10 @@
file.mkdir();
tmp_location = escapeWindowsPath(tmp_location);
-
- c.setCacheLoaderConfiguration(getCacheLoaderConfig(cacheloaderClass, tmp_location,
- async));
+ String props = "location = " + tmp_location + "\n";
+ c.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", cacheloaderClass, props, async, true, false));
+ }
}
-
- protected Element getCacheLoaderConfig(String cl, String loc, boolean async) throws Exception
- {
- String xml = " <config>\n" +
- " \n" +
- " <passivation>false</passivation>\n" +
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- " <class>" + cl + "</class>\n" +
- " <properties>\n" +
- " location=" + loc + "\n" +
- " </properties>\n" +
- " <async>" + async + "</async>\n" +
- " <fetchPersistentState>true</fetchPersistentState>\n" +
- " <ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
- return XmlHelper.stringToElement(xml);
}
protected String getTempLocation(String cacheID)
1.12 +36 -3 JBossCache/tests/functional/org/jboss/cache/statetransfer/VersionedTestBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: VersionedTestBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/VersionedTestBase.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- VersionedTestBase.java 11 Sep 2006 17:51:25 -0000 1.11
+++ VersionedTestBase.java 11 Sep 2006 19:28:11 -0000 1.12
@@ -66,21 +66,54 @@
initialStateTferWithLoaderTest(false);
}
+ public void testCompatibilityBetweenFileAndJbdmCacheLoaders() throws Exception
+ {
+ initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
+ "org.jboss.cache.loader.jdbm.JdbmCacheLoader",false);
+ }
+
+ public void testCompatibilityBetweenFileAndJDBCCacheLoaders() throws Exception
+ {
+ initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
+ "org.jboss.cache.loader.JDBCCacheLoader",false);
+ }
+
+ public void testCompatibilityBetweenJbdmAndJDBCCacheLoaders() throws Exception
+ {
+ initialStateTferWithLoaderTest("org.jboss.cache.loader.jdbm.JdbmCacheLoader",
+ "org.jboss.cache.loader.JDBCCacheLoader",false);
+ }
+
+ public void testCompatibilityBetweenFileAndBdbjeCacheLoaders() throws Exception
+ {
+
+ //this one should pass after BdbjeCacheLoader becomes compatible
+ //see http://jira.jboss.com/jira/browse/JBCACHE-749
+ initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
+ "org.jboss.cache.loader.bdbje.BdbjeCacheLoader",false);
+ }
+
public void testInitialStateTferWithAsyncLoader() throws Exception
{
initialStateTferWithLoaderTest(true);
}
- private void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
+ protected void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
+ {
+ initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
+ "org.jboss.cache.loader.FileCacheLoader", asyncLoader);
+ }
+
+ protected void initialStateTferWithLoaderTest(String cacheLoaderClass1, String cacheLoaderClass2, boolean asyncLoader) throws Exception
{
- CacheSPI cache1 = createCache("cache1", false, false, true);
+ CacheSPI cache1 = createCache("cache1", false,false, cacheLoaderClass1, false, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI cache2 = createCache("cache2", false, false, true, asyncLoader, false);
+ CacheSPI cache2 = createCache("cache2", false, false,cacheLoaderClass2, asyncLoader, false);
cache2.start();
More information about the jboss-cvs-commits
mailing list