Author: manik.surtani(a)jboss.com
Date: 2007-10-04 21:58:07 -0400 (Thu, 04 Oct 2007)
New Revision: 4544
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
Log:
Fixed a few tests
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2007-10-04
16:52:57 UTC (rev 4543)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2007-10-05
01:58:07 UTC (rev 4544)
@@ -2095,6 +2095,11 @@
// now stop the cache
cache.stop();
cache.destroy();
+
+ assert "v".equals(loader.get(fqn).get("k"));
+ assert cache.getCacheLoader() == null : "Should nullify cache loader in the
cache";
+ assert cache.getCacheLoaderManager() == null : "Should nullify cache loader
manager in the cache";
+
cache.getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs().get(0).setIgnoreModifications(true);
cache.start();
loader = cache.getCacheLoader();
@@ -2103,8 +2108,8 @@
assert loader instanceof ReadOnlyDelegatingCacheLoader;
// old state should be persisted.
- assert "v".equals(cache.get(fqn, "k"));
assert "v".equals(loader.get(fqn).get("k"));
+ assert "v".equals(cache.get(fqn, "k"));
// the loader should now be read-only
cache.put(fqn, "k", "v2");
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java 2007-10-04
16:52:57 UTC (rev 4543)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java 2007-10-05
01:58:07 UTC (rev 4544)
@@ -40,9 +40,10 @@
return "NULL placeholder";
}
};
-
+ protected IndividualCacheLoaderConfig config;
public void setConfig(IndividualCacheLoaderConfig config)
{
+ this.config = config;
if (config != null && config.getProperties() != null)
{
debug =
Boolean.parseBoolean(config.getProperties().getProperty("debug",
"false"));
@@ -51,7 +52,7 @@
public IndividualCacheLoaderConfig getConfig()
{
- return null;
+ return config;
}
public Set<?> getChildrenNames(Fqn fqn) throws Exception
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2007-10-04
16:52:57 UTC (rev 4543)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2007-10-05
01:58:07 UTC (rev 4544)
@@ -1,13 +1,20 @@
package org.jboss.cache.loader;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.testng.annotations.Test;
+
/**
* Odd that we need a test for a test class, but if we intend to use the {@link
org.jboss.cache.loader.DummyInMemoryCacheLoader} as a cache
* loader stub then we need to make sure it behaves as a valid cache loader.
*/
+@Test(groups = {"functional"})
public class DummyInMemoryCacheLoaderTest extends CacheLoaderTestsBase
{
protected void configureCache() throws Exception
{
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.DummyInMemoryCacheLoader", "", false, true,
false));
+ // use the shared variation of the DIMCL so that state is persisted in a static
variable in memory rather than an
+ // instance one.
+ CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "", false, true, false);
+ cache.getConfiguration().setCacheLoaderConfig(clc);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2007-10-04
16:52:57 UTC (rev 4543)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2007-10-05
01:58:07 UTC (rev 4544)
@@ -11,10 +11,12 @@
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
import org.testng.annotations.Test;
+import org.testng.annotations.AfterMethod;
import java.util.Properties;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
/**
* This test runs cache loader tests using Database as the cache loader store.
@@ -41,10 +43,13 @@
"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") + "\n" +
- "cache.jdbc.sql-concat=" +
prop.getProperty("cache.jdbc.sql-concat") + "\n" +
- "cache.jdbc.table.name=" +
prop.getProperty("cache.jdbc.table.name");
+ "cache.jdbc.node.type=" +
prop.getProperty("cache.jdbc.node.type") + "\n" +
+ "cache.jdbc.sql-concat=" +
prop.getProperty("cache.jdbc.sql-concat") + "\n" +
+ "cache.jdbc.table.name=" +
prop.getProperty("cache.jdbc.table.name") + "\n" +
+ "cache.jdbc.table.drop=false";
+ // make sure dropTable is false!!
+
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true,
false));
}