Author: mircea.markus
Date: 2008-12-09 10:04:25 -0500 (Tue, 09 Dec 2008)
New Revision: 7269
Modified:
core/trunk/pom.xml
core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/trunk/src/main/resources/cache-jdbc.properties
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java
core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
core/trunk/src/test/resources/cache-jdbc.properties
Log:
switched to hsqldb instead of derby
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/pom.xml 2008-12-09 15:04:25 UTC (rev 7269)
@@ -30,6 +30,13 @@
<version>2.6.7.GA</version>
</dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- For the JTA 1.1 API; consuming projects can safely
exclude this and replace with any valid source of this API -->
<dependency>
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -147,8 +147,8 @@
@Stop
void stop()
{
- syncProcessor.shutdownNow();
- asyncProcessor.shutdownNow();
+ if (syncProcessor != null) syncProcessor.shutdownNow();
+ if (asyncProcessor != null) asyncProcessor.shutdownNow();
}
@Destroy
Modified: core/trunk/src/main/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/main/resources/cache-jdbc.properties 2008-12-09 15:01:40 UTC (rev
7268)
+++ core/trunk/src/main/resources/cache-jdbc.properties 2008-12-09 15:04:25 UTC (rev
7269)
@@ -11,7 +11,7 @@
cache.jdbc.fqn.column=fqn
cache.jdbc.fqn.type=varchar(255)
cache.jdbc.node.column=node
-cache.jdbc.node.type=blob
+cache.jdbc.node.type=BINARY
cache.jdbc.parent.column=parent
# Specify your DBMS's string concatenation function syntax in the following manner:
concat(1 , 2) -> '12'.
# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql,
PostgreSQL. Derby - on which
@@ -63,7 +63,7 @@
#cache.jdbc.password=admin
## Derby
-cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
-cache.jdbc.url=jdbc:derby:jbossdb;create=true
-cache.jdbc.user=user1
-cache.jdbc.password=user1
\ No newline at end of file
+cache.jdbc.driver = org.hsqldb.jdbcDriver
+cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
+cache.jdbc.user=sa
+cache.jdbc.password=
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-12-09 15:01:40
UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-12-09 15:04:25
UTC (rev 7269)
@@ -178,15 +178,14 @@
private void tryMCastAddress()
{
String useIpV4 = System.getProperty("java.net.preferIPv4Stack");
- log.error("++++++++++++++++++++++++++++++ useIpV4 property=" + useIpV4);
+ log.info("++++++++++++++++++++++++++++++ useIpV4 property=" + useIpV4);
SocketAddress socketAddress = new InetSocketAddress("224.10.10.10",
45588);
try
{
MulticastSocket ms = new MulticastSocket(socketAddress);
} catch (IOException e)
{
- System.err.println("+++++++++++++++++++++++++++ Error : " +
e.getMessage());
- log.error("+++++++++++++++++++++++++++ Error : " + e.getMessage(),
e);
+ log.info("+++++++++++++++++++++++++++ Error : " + e.getMessage(), e);
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -18,7 +18,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
super.configureCache();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
@@ -27,7 +26,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class),
cr.getComponent(InvocationContextContainer.class));
Modified:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -21,7 +21,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
@@ -35,7 +34,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class),
cr.getComponent(InvocationContextContainer.class));
Modified:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -18,7 +18,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
super.configureCache();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
@@ -27,7 +26,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class),
cr.getComponent(InvocationContextContainer.class));
Modified:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -20,7 +20,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "bin=" +
Thread.currentThread().getName() + getClass().getName(), false, true, false);
@@ -31,7 +30,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class),
cr.getComponent(InvocationContextContainer.class));
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -11,9 +11,7 @@
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -42,6 +40,23 @@
private CacheSPI cache, cache2;
+ private Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis()
- durration)/1000);
+ }
+
/**
* Note : newImpl is not started here but in each individual test. That's because
on start it performs
* some backward compatibility logic.
@@ -51,7 +66,6 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- Properties props = TestDbPropertiesFactory.getTestDbProperties();
newImpl = getNewCacheLoader((Properties) props.clone());
oldImpl = getOldLoader((Properties) props.clone());
cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache();
@@ -72,8 +86,6 @@
TestingUtil.killCaches(cache, cache2);
cache = null;
cache2 = null;
-
TestDbPropertiesFactory.shutdownInMemoryDatabase(oldImpl.getConfig().getProperties());
-
TestDbPropertiesFactory.shutdownInMemoryDatabase(newImpl.getConfig().getProperties());
}
public void testCommonOperations() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -19,10 +19,8 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = TestingUtil.TEST_FILES;
- String threadId = Thread.currentThread().getName();
- String tmpCLLoc = tmpDir + "/JBossCache-BdbjeCacheLoaderTest-" +
threadId;
+ String tmpCLLoc = tmpDir + "/JBossCache-BdbjeCacheLoaderTest";
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" +
tmpCLLoc, false, true, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
@@ -31,7 +29,6 @@
public void testTransaction() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
// to help recreate the issue in
//
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048003#...
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -10,9 +10,7 @@
import org.jboss.cache.util.TestDbPropertiesFactory;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.fail;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
import java.sql.Connection;
import java.util.Properties;
@@ -28,19 +26,34 @@
private C3p0ConnectionFactory cf;
private AdjListJDBCCacheLoaderConfig config;
+ private Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis()
- durration)/1000);
+ }
+
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
config = new AdjListJDBCCacheLoaderConfig();
- config.setProperties(prop);
+ config.setProperties(props);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
cf.stop();
- TestDbPropertiesFactory.shutdownInMemoryDatabase(config.getProperties());
}
public void testSetConfig() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -11,6 +11,8 @@
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.TestDbPropertiesFactory;
import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
/**
* Unit test that runs the the tests defined JDBCCacheLoaderTest using a standalone
@@ -18,16 +20,20 @@
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
-@Test(groups = "functional", testName =
"loader.JDBCCacheLoaderTest")
+@Test(groups = "functional", testName =
"loader.C3p0JDBCCacheLoaderTest")
public class C3p0JDBCCacheLoaderTest extends JDBCCacheLoaderTest
{
private static final String CF_CLASS =
"org.jboss.cache.loader.C3p0ConnectionFactory";
+ @BeforeTest
+ public void createDatabase()
+ {
+ super.createDatabase();
+ props.put("cache.jdbc.connection.factory", CF_CLASS);
+ }
+
protected void configureCache() throws Exception
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
- prop.put("cache.jdbc.connection.factory", CF_CLASS);
- CacheSPI<Object, Object> cache = cacheTL.get();
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", prop, false, true, false));
+
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -2,13 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
@@ -26,13 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
@@ -45,11 +33,8 @@
@Test(groups = {"functional"})
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
- private static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
+ static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
- protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new
ThreadLocal<CacheSPI<Object, Object>>();
- ThreadLocal<CacheLoader> loaderTL = new ThreadLocal<CacheLoader>();
-
static final Fqn FQN = Fqn.fromString("/key");
private static final Fqn SUBTREE_FQN = Fqn.fromRelativeElements(FQN,
"subtree");
@@ -58,30 +43,20 @@
private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, FQN);
private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeFqn(BUDDY_BASE,
SUBTREE_FQN);
+ protected CacheSPI<Object, Object> cache;
+ protected CacheLoader loader;
- @BeforeMethod(alwaysRun = true)
+ @BeforeMethod
public void setUp() throws Exception
{
- try
- {
- CacheSPI<Object, Object> cache =
- (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false);
- cacheTL.set(cache);
-
- Configuration c = cache.getConfiguration();
- c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- configureCache();
- cache.start();
- CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
- loaderTL.set(loader);
- postConfigure();
- }
- catch (Exception e)
- {
-// e.printStackTrace();
- throw e;
- }
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false);
+ Configuration c = cache.getConfiguration();
+ c.setCacheMode(Configuration.CacheMode.LOCAL);
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ configureCache();
+ cache.start();
+ loader = cache.getCacheLoaderManager().getCacheLoader();
+ postConfigure();
}
protected void postConfigure()
@@ -95,12 +70,8 @@
public void tearDown() throws Exception
{
cleanup();
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
//if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
- cacheTL.set(null);
- loaderTL.set(null);
}
protected void cleanup()
@@ -121,7 +92,7 @@
*/
protected boolean exists(String fqn, String key)
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
NodeSPI n = cache.peek(Fqn.fromString(fqn), false, false);
if (key == null) return n != null;
return n != null && n.getKeysDirect().contains(key);
@@ -129,7 +100,7 @@
public void testPrint() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
cache.put(NODE, KEY, 10);
@@ -141,7 +112,7 @@
public void testPut() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -162,8 +133,8 @@
public void testPut2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
final String NODE = "/a/b/c";
assertNull(loader.get(Fqn.fromString(NODE)));
final String KEY = "key";
@@ -192,8 +163,7 @@
{
final Fqn NODE = Fqn.fromString("/a/b/c");
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
cache.removeNode(NODE);
addDelay();
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -215,16 +185,17 @@
cache.get(NODE, "X");
assertEquals(m, cache.getNode(NODE).getData());
cache.evict(NODE, false);
+ assertEquals(m, cache.getNode(NODE).getData());
cache.get(NODE, "X");
cache.put(NODE, m2);
- assertEquals("combined", 4, cache.getNode(NODE).getData().size());
+ Map<Object, Object> data = cache.getNode(NODE).getData();
+ System.out.println("data = " + data);
+ assertEquals("combined", 4, data.size());
}
public void testPutNullDataMap() throws Exception
{
Fqn f = Fqn.fromString("/a");
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
assert !cache.exists(f);
assert !loader.exists(f);
cache.put(f, null);
@@ -236,8 +207,8 @@
public void testPutNullDataMapNodeHasData() throws Exception
{
Fqn f = Fqn.fromString("/a");
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
cache.put(f, "key", "value");
assert cache.exists(f);
assert loader.exists(f);
@@ -250,7 +221,7 @@
public void testShallowMove() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn a = Fqn.fromString("/a");
Fqn b = Fqn.fromString("/b");
Fqn a_b = Fqn.fromString("/a/b");
@@ -280,8 +251,8 @@
public void testDeepMove() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn a = Fqn.fromString("/a");
Fqn b = Fqn.fromString("/b");
Fqn a_b = Fqn.fromString("/a/b");
@@ -320,9 +291,8 @@
*/
public void testPutRemoveCombos() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
final String NODE = "/a/b/c";
cache.removeNode(NODE);
Fqn fqn = Fqn.fromString(NODE);
@@ -343,8 +313,8 @@
public void testGet() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/a/b/c";
Object retval;
cache.removeNode(NODE);
@@ -364,8 +334,8 @@
public void testGetNode() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/a/b/c";
Node<Object, Object> retval;
cache.removeNode(NODE);
@@ -384,8 +354,8 @@
public void testSerialization() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
SamplePojo pojo = new SamplePojo(39, "Bela");
pojo.getHobbies().add("Running");
pojo.getHobbies().add("Beerathlon");
@@ -407,7 +377,7 @@
*/
public void testPopulate()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -445,7 +415,7 @@
public void testPreloading() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.removeNode(Fqn.ROOT);
cache.put("1/2/3/4/5/d", "key", "val");
cache.evict(Fqn.fromString("1/2/3/4/5/d"));
@@ -461,7 +431,7 @@
@SuppressWarnings("unchecked")
public void testCacheLoading2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set keys = null;
cache.put("/a/b/c", "key", "val");
keys = cache.getNode("/a/b/c").getKeys();
@@ -472,7 +442,7 @@
public void testExists()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/eins/zwei/drei", "key1", "val1");
assertTrue(cache.exists("/eins/zwei/drei"));
assert (exists("/eins/zwei/drei", "key1"));
@@ -483,7 +453,7 @@
public void testGetChildren()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/1/2/3/4/5/d/one", null);
@@ -505,7 +475,7 @@
public void testGetChildrenWithEviction() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/a/b/c/1", null);
cache.put("/a/b/c/2", null);
cache.put("/a/b/c/3", null);
@@ -527,7 +497,7 @@
public void testGetChildren2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/1", null);
@@ -546,7 +516,7 @@
public void testGetChildren3()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/1", null);
@@ -565,7 +535,7 @@
public void testGetChildren4()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
if (!cache.exists("/a/b/c"))
@@ -584,7 +554,7 @@
public void testGetChildren5()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -607,7 +577,7 @@
public void testGetChildren6()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -633,7 +603,7 @@
public void testGetChildren7()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -661,7 +631,7 @@
public void testGetChildren8()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -681,7 +651,7 @@
public void testGetChildren9()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -722,7 +692,7 @@
public void testGetChildren10()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -755,7 +725,7 @@
public void testGetChildren11()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set children;
try
{
@@ -798,7 +768,7 @@
public void testGetChildren12()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set children;
cache.put("/a/b", "key", "val");
cache.put("/a/b/1", "key", "val");
@@ -830,8 +800,8 @@
public void testLoaderGetChildrenNames() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn f = Fqn.fromString("/a");
cache.put(f, "k", "v");
assertEquals("v", loader.get(f).get("k"));
@@ -840,7 +810,7 @@
public void testGetKeys() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn f = Fqn.fromString("/a");
cache.put(f, "one", "one");
cache.put(f, "two", "two");
@@ -853,8 +823,8 @@
public void testGetData() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn f = Fqn.fromString("/a");
assert !cache.exists(f);
assert !loader.exists(f);
@@ -871,7 +841,7 @@
public void testRemoveData()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -888,7 +858,7 @@
public void testRemoveData2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -907,7 +877,7 @@
public void testRemoveData3()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -923,8 +893,8 @@
public void testRemoveData4() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -945,8 +915,8 @@
public void testReplaceAll() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -972,7 +942,7 @@
public void testRemoveKey()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
assertEquals(1, cache.getNode(key).getKeys().size());
@@ -988,7 +958,7 @@
public void testRemoveKey2() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -1005,7 +975,7 @@
public void testRemoveKey3() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -1027,7 +997,7 @@
public void testRemove()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -1043,7 +1013,7 @@
public void testRemoveRoot()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
assertEquals(0, cache.getRoot().getKeys().size());
cache.put("/1/2/3/4/5", null);
cache.put("uno/due/tre", null);
@@ -1056,8 +1026,8 @@
public void testLoaderRemoveRoot() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn f = Fqn.fromString("/a");
loader.put(f, "k", "v");
assertTrue(loader.get(f).containsKey("k"));
@@ -1071,7 +1041,7 @@
public void testEvictionWithCacheLoader()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/first/second", "key1", "val1");// stored
in cache loader
cache.put("/first/second/third", "key2", "val2");//
stored in cache loader
cache.evict(Fqn.fromString("/first/second"));// doesn't remove node,
just data !
@@ -1089,7 +1059,7 @@
public void testEvictionWithCacheLoader2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/first/second/third", "key1", "val1");//
stored in cache loader
cache.evict(Fqn.fromString("/first/second/third"));// removes node,
because there are no children
addDelay();
@@ -1106,7 +1076,7 @@
public void testEvictionWithGetChildrenNames() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -1136,8 +1106,7 @@
TransactionManager mgr = getTransactionManager();
mgr.begin();
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
cache.put("/one/two/three", "key1", "val1");
cache.put("/one/two/three/four", "key2", "val2");
mgr.commit();
@@ -1154,8 +1123,7 @@
{
TransactionManager mgr = getTransactionManager();
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
cache.removeNode("/one");
addDelay();
mgr.begin();
@@ -1206,8 +1174,6 @@
private void doTestBasicOperations() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
/* One FQN only. */
doPutTests(Fqn.fromString("/key"));
doRemoveTests(Fqn.fromString("/key"));
@@ -1238,7 +1204,7 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
+
assertTrue(!loader.exists(fqn));
/* put(Fqn,Object,Object) and get(Fqn,Object) */
@@ -1285,7 +1251,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
/* remove(Fqn,Object) */
Object oldVal;
oldVal = loader.remove(fqn, "one");
@@ -1320,8 +1285,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* Create top level node implicitly. */
assertTrue(!loader.exists(Fqn.fromString("/key0")));
loader.put(Fqn.fromString("/key0/level1/level2"), null);
@@ -1485,7 +1448,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
@@ -1556,7 +1518,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
Set set = loader.getChildrenNames(fqn);
if (names != null)
@@ -1566,8 +1527,7 @@
{
assertTrue(set.contains(names[i]));
}
- }
- else
+ } else
{
assertNull(set);
}
@@ -1603,8 +1563,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* PUT_KEY_VALUE, PUT_DATA */
List<Modification> list = createUpdates();
loader.put(list);
@@ -1652,7 +1610,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
@@ -1666,8 +1623,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
// Object txnKey = new Object();
TransactionManager mgr = getTransactionManager();
mgr.begin();
@@ -1686,7 +1641,7 @@
*/
public void testTransactionRollback() throws Exception
{
- CacheLoader loader = loaderTL.get();
+
loader.remove(Fqn.fromString("/"));
int num;
try
@@ -1717,7 +1672,7 @@
*/
public void testIntegratedTransactionRollback() throws Exception
{
- CacheLoader loader = loaderTL.get();
+
loader.remove(Fqn.fromString("/"));
int num = 0;
try
@@ -1785,8 +1740,8 @@
*/
private void checkModifications(List<Modification> list) throws Exception
{
- CacheLoader loader = loaderTL.get();
+
for (Modification mod : list)
{
Fqn fqn = mod.getFqn();
@@ -1827,7 +1782,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
loader.put(FQN, null, "x");
addDelay();
@@ -1887,7 +1841,7 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
+
loader.put(FQN, "one", "two");
addDelay();
assertEquals("two", loader.get(FQN).get("one"));
@@ -1900,8 +1854,6 @@
throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
// Empty state
loader.remove(Fqn.fromString("/"));
@@ -1997,8 +1949,7 @@
if (nested == null)
{
return super.hashCode();
- }
- else
+ } else
{
return 13 + nested.hashCode();
}
@@ -2007,8 +1958,8 @@
public void testRemoveInTransactionCommit() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
loader.remove(fqn);
String key = "key";
@@ -2034,8 +1985,8 @@
public void testRemoveInTransactionRollback() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
loader.remove(fqn);
String key = "key";
@@ -2063,7 +2014,7 @@
*/
public void testRemoveAndGetInTransaction() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn fqn = Fqn.fromString("/a/b");
String key = "key";
String value = "value";
@@ -2086,8 +2037,8 @@
public void testPutAllAfterEvict() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
Map<String, String> original = new HashMap<String, String>();
Map<String, String> toAdd = new HashMap<String, String>();
@@ -2113,8 +2064,8 @@
public void testPutAllAfterEvictWithChild() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
Map<String, String> original = new HashMap<String, String>();
Map<String, String> toAdd = new HashMap<String, String>();
@@ -2146,8 +2097,6 @@
public void testPartialLoadAndStore()
throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
/* Empty state. */
loader.remove(Fqn.fromString("/"));
@@ -2203,8 +2152,7 @@
public void testBuddyBackupStore() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
/* Empty state. */
loader.remove(Fqn.ROOT);
@@ -2252,8 +2200,6 @@
public void testIgnoreModifications() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
Fqn fqn = Fqn.fromString("/a");
cache.put(fqn, "k", "v");
assert "v".equals(cache.get(fqn, "k"));
@@ -2302,7 +2248,6 @@
protected void threadSafetyTest(final boolean singleFqn) throws Exception
{
- final CacheLoader loader = loaderTL.get();
final CountDownLatch latch = new CountDownLatch(1);
final Fqn fqn = Fqn.fromString("/a/b/c");
final List<Fqn> fqns = new ArrayList<Fqn>(30);
@@ -2315,8 +2260,7 @@
fqns.add(f);
loader.put(f, "k", "v");
}
- }
- else
+ } else
{
loader.put(fqn, "k", "v");
}
@@ -2461,18 +2405,16 @@
protected TransactionManager getTransactionManager()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
return cache.getConfiguration().getRuntimeConfig().getTransactionManager();
}
public void testSetData() throws Exception
{
log.info("testSetData");
- CacheSPI<Object, Object> cache = cacheTL.get();
Fqn key = Fqn.fromElements("key");
Map<Object, Object> map = new HashMap<Object, Object>();
Map<Object, Object> loaderMap;
- CacheLoader loader = loaderTL.get();
map.put("a", "a");
map.put("c", "c");
log.info("PUT");
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -36,7 +36,6 @@
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(loc1, loc2));
TestingUtil.recursiveFileRemove(loc1);
TestingUtil.recursiveFileRemove(loc2);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -268,7 +268,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("Evict in loop " + i);
+// System.out.println("Evict in loop " + i);
Fqn f = singleFqn ? fqn : fqns.get(r.nextInt(fqns.size()));
cache1.evict(f);
TestingUtil.sleepRandom(50);
@@ -296,7 +296,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("Write in loop " + i);
+// System.out.println("Write in loop " + i);
Fqn f = singleFqn ? fqn : fqns.get(r.nextInt(fqns.size()));
cache2.put(f, "k", "v");
TestingUtil.sleepRandom(50);
@@ -321,7 +321,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("R1 in loop " + i);
+// System.out.println("R1 in loop " + i);
loader1.get(singleFqn ? fqn : fqns.get(r.nextInt(fqns.size())));
TestingUtil.sleepRandom(50);
}
@@ -343,7 +343,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("R2 in loop " + i);
+// System.out.println("R2 in loop " + i);
loader1.getChildrenNames(singleFqn ? fqn.getParent() :
fqns.get(r.nextInt(fqns.size())).getParent());
TestingUtil.sleepRandom(50);
}
@@ -365,7 +365,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("R3 in loop " + i);
+// System.out.println("R3 in loop " + i);
loader1.getChildrenNames(singleFqn ? fqn :
fqns.get(r.nextInt(fqns.size())));
TestingUtil.sleepRandom(50);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -36,6 +36,7 @@
private final String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
private final String JNDI_NAME = "java:/MockDS";
private CacheSPI cache;
+ private Properties props;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -62,37 +63,31 @@
*/
public void testDataSourceIntegration() throws Exception
{
- Properties props = null;
+ props = null;
+ Context context = new InitialContext();
try
{
- Context context = new InitialContext();
- try
- {
Object obj = context.lookup(JNDI_NAME);
- assertNull(JNDI_NAME + " not bound", obj);
- }
- catch (NameNotFoundException n)
- {
- // expected
- }
- props = TestDbPropertiesFactory.getTestDbProperties();
- cache = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(false);
- cache.getConfiguration().setCacheMode("local");
-
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(props));
- cache.create();
-
-
- context.bind(JNDI_NAME, new MockDataSource(props));
- assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
- cache.start();
-
- assertNotNull("Cache has a cache loader",
cache.getCacheLoaderManager().getCacheLoader());
+ assertNull(JNDI_NAME + " not bound", obj);
}
- finally
+ catch (NameNotFoundException n)
{
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ // expected
}
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ cache = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(false);
+ cache.getConfiguration().setCacheMode("local");
+
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(props));
+ cache.create();
+
+
+ MockDataSource ds = new MockDataSource(props);
+ context.bind(JNDI_NAME, ds);
+ assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
+ cache.start();
+
+ assertNotNull("Cache has a cache loader",
cache.getCacheLoaderManager().getCacheLoader());
}
@AfterMethod(alwaysRun = true)
@@ -103,6 +98,7 @@
if (cache != null)
{
TestingUtil.killCaches(cache);
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
cache = null;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -16,7 +16,6 @@
{
// use the shared variation of the DIMCL so that state is persisted in a static
variable in memory rather than an
// instance one.
- CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "debug=true \n bin=" +
getClass().getName(), false, true, false);
cache.getConfiguration().setCacheLoaderConfig(clc);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -11,25 +11,37 @@
@Test(groups = {"functional"}, testName =
"loader.DummyInMemoryCacheLoaderTest")
public class DummyInMemoryCacheLoaderTest extends CacheLoaderTestsBase
{
+
+ DummySharedInMemoryCacheLoader dimCl;
+
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
// use the shared variation of the DIMCL so that state is persisted in a static
variable in memory rather than an
// instance one.
String bin = "DummyInMemoryCacheLoader-" +
Thread.currentThread().getName();
CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "bin=" + bin, false, true,
false);
cache.getConfiguration().setCacheLoaderConfig(clc);
}
-
+
+ protected void postConfigure()
+ {
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+ if (loader instanceof AbstractDelegatingCacheLoader)
+ {
+ dimCl = (DummySharedInMemoryCacheLoader)
((ReadOnlyDelegatingCacheLoader)loader).getCacheLoader();
+ }
+ else
+ {
+ dimCl = (DummySharedInMemoryCacheLoader) loader;
+ }
+ }
+
@Override
protected void cleanup()
{
- DummySharedInMemoryCacheLoader loader = (DummySharedInMemoryCacheLoader)
loaderTL.get();
- if (loader != null) {
- loader.wipeBin();
- loaderTL.set(null);
+ if (dimCl != null) {
+ dimCl.wipeBin();
}
}
-
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -11,7 +11,6 @@
{
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String threadId = Thread.currentThread().getName();
String tmpCLLoc = TestingUtil.TEST_FILES +
"/JBossCache-FileCacheLoaderTest-" + threadId;
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.FileCacheLoader", "location=" + tmpCLLoc,
false, true, false));
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -21,7 +21,7 @@
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
-@Test(groups = {"unit"}, sequential = true, testName =
"loader.JDBCCacheLoaderConfigTest")
+@Test(groups = {"unit"}, testName =
"loader.JDBCCacheLoaderConfigTest")
public class JDBCCacheLoaderConfigTest
{
private AdjListJDBCCacheLoaderConfig cacheLoaderConfig;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -6,21 +6,20 @@
*/
package org.jboss.cache.loader;
-import org.apache.derby.jdbc.EmbeddedXADataSource;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
+import org.hsqldb.jdbc.jdbcDataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import java.util.Properties;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
/**
* This test runs cache loader tests using Database as the cache loader store.
@@ -41,7 +40,7 @@
private final String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
private final String JNDI_NAME = "java:/DerbyDS";
private Properties prop;
- private EmbeddedXADataSource ds;
+ private jdbcDataSource ds;
protected void configureCache() throws Exception
{
@@ -62,20 +61,16 @@
prop = TestDbPropertiesFactory.getTestDbProperties();
- ds = new EmbeddedXADataSource();
- ds.setDatabaseName(TestDbPropertiesFactory.getDatabaseName(prop));
- ds.setCreateDatabase("create");
- ds.setUser(prop.getProperty("cache.jdbc.user"));
- ds.setPassword(prop.getProperty("cache.jdbc.password"));
+ ds = new jdbcDataSource();
+ ds.setDatabase(prop.getProperty("cache.jdbc.url"));
+ ds.setUser("sa");
-
String props = "cache.jdbc.datasource =" + JNDI_NAME + "\n" +
"cache.jdbc.node.type=" +
prop.getProperty("cache.jdbc.node.type") + "\n" +
"cache.jdbc.sql-concat= 1 || 2" + "\n" +
- "cache.jdbc.table.name=jbosscache" + TestingUtil.getThreadId() +
"\n" +
- "cache.jdbc.table.primarykey=jbosscache_pk" +
TestingUtil.getThreadId();
+ "cache.jdbc.table.name=jbosscache" + "\n" +
+ "cache.jdbc.table.primarykey=jbosscache_pk";
- CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig config = getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false);
cache.getConfiguration().setCacheLoaderConfig(config);
cache.create();
@@ -87,13 +82,12 @@
protected void cleanup()
{
- ds.setShutdownDatabase("shutdown");
+// ds.setShutdownDatabase("shutdown");
TestDbPropertiesFactory.shutdownInMemoryDatabase(prop);
}
public void testLargeObject()
{
- CacheLoader loader = loaderTL.get();
try
{
String key = "LargeObj";
@@ -153,4 +147,9 @@
}
*/
}
+
+ public void testRemoveData()
+ {
+ super.testRemoveData();
+ }
}
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -25,12 +25,15 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.transaction.GenericTransactionManagerLookup;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
import java.util.Properties;
@@ -46,22 +49,39 @@
CacheSPI first;
CacheSPI second;
+ private Properties props1;
+ private Properties props2;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props1 = TestDbPropertiesFactory.getTestDbProperties();
+ props2 = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props1);
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props2);
+ System.out.println("Test execution took: " + (System.currentTimeMillis()
- durration)/1000);
+ }
+
+
+
@AfterMethod
public void tearDown()
{
- if (first != null) first.stop();
- if (second != null) second.stop();
- Properties props =
first.getCacheLoaderManager().getCacheLoaderConfig().getFirstCacheLoaderConfig().getProperties();
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
- props =
second.getCacheLoaderManager().getCacheLoaderConfig().getFirstCacheLoaderConfig().getProperties();
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ if (first != null) TestingUtil.killCaches(first);
+ if (second != null) TestingUtil.killCaches(second);
}
- private Configuration getConfiguration() throws Exception
+ private Configuration getConfiguration(Properties props) throws Exception
{
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(GenericTransactionManagerLookup.class.getName());
- Properties props = TestDbPropertiesFactory.getTestDbProperties();
CacheLoaderConfig clc = getSingleCacheLoaderConfig("/",
JDBCCacheLoader.class.getName(), props, false, true, false);
clc.setPassivation(false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
@@ -73,11 +93,11 @@
public void testSimpleStateTransfer() throws Exception
{
- first = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ first = (CacheSPI) new
UnitTestCacheFactory().createCache(getConfiguration(props1));
first.put("/a/b/c", "key", "value");
first.put("/a/b/d", "key", "value");
first.put("/a/b/e", "key", "value");
- second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ second = (CacheSPI) new
UnitTestCacheFactory().createCache(getConfiguration(props2));
assert second.get("/a/b/c","key").equals("value");
assert second.get("/a/b/d","key").equals("value");
assert second.get("/a/b/e","key").equals("value");
@@ -91,7 +111,7 @@
{
long startTime = System.currentTimeMillis();
- first = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ first = (CacheSPI) new
UnitTestCacheFactory().createCache(getConfiguration(props1));
long cacheStartTime = System.currentTimeMillis() - startTime;
System.out.println("cacheStartTime = " + cacheStartTime);
for (int i = 0; i < 5012; i++)
@@ -100,7 +120,7 @@
if (i%1000 == 0) System.out.println(i + " operations executed so
far");
}
startTime = System.currentTimeMillis();
- second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ second = (CacheSPI) new
UnitTestCacheFactory().createCache(getConfiguration(props2));
long stateTranferTime = System.currentTimeMillis() - startTime - cacheStartTime;
for (int i = 0; i < 5012; i+=100)
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -10,9 +10,13 @@
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
import java.util.Properties;
import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.util.TestDbPropertiesFactory;
@@ -35,11 +39,27 @@
@Test(groups = {"functional"}, testName =
"loader.JDBCCacheLoaderTest")
public class JDBCCacheLoaderTest extends CacheLoaderTestsBase
{
+
+ protected Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis()
- durration)/1000);
+ }
+
protected void configureCache() throws Exception
{
- String props = props2String(TestDbPropertiesFactory.getTestDbProperties());
-
- CacheSPI<Object, Object> cache = cacheTL.get();
+ String props = props2String(this.props);
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
JDBCCacheLoader.class.getName(), props, false, true, false));
}
@@ -60,9 +80,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
TestingUtil.killCaches(cache);
- Properties props =
cacheTL.get().getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs().get(0).getProperties();
TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
}
@@ -74,7 +92,6 @@
public void testLargeObject()
{
- CacheLoader loader = loaderTL.get();
try
{
String key = "LargeObj";
@@ -107,8 +124,9 @@
public void testRootIsCreated() throws Exception
{
- CacheLoader loader = loaderTL.get();
loader.put(Fqn.fromString("/a/b/c"), "a", "b");
assertTrue(loader.exists(Fqn.ROOT));
}
+
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -16,7 +16,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoader2Test-" +
threadId;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -15,7 +15,6 @@
{
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = TestingUtil.TEST_FILES;
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoaderTest-" +
threadId;
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -14,8 +14,6 @@
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
delegating_cache = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(false);
delegating_cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
delegating_cache.create();
@@ -32,7 +30,7 @@
protected void postConfigure()
{
- CacheLoader ldr = loaderTL.get();
+ CacheLoader ldr = loader;
LocalDelegatingCacheLoader ldcl = null;
do
{
Modified: core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -35,8 +35,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
String accessKey = System.getProperty("accessKey");
String properties;
if (accessKey == null)
@@ -85,7 +83,6 @@
protected void postConfigure()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.removeNode(Fqn.root());
}
Modified: core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -546,7 +546,7 @@
{
for (int i = 0; i < opCount; i++)
{
- if (i % 10 == 0) System.out.println("readLockChanger loop# " +
i);
+// if (i % 10 == 0) System.out.println("readLockChanger loop# " +
i);
lockMap.addReader(new Object());
}
}
@@ -562,7 +562,7 @@
{
if (i % 10 == 0)
{
- System.out.println("toStringProcessor loop# " + i + ",
" + (System.currentTimeMillis() - initialTime));
+// System.out.println("toStringProcessor loop# " + i + ",
" + (System.currentTimeMillis() - initialTime));
initialTime = System.currentTimeMillis();
}
try
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -2,13 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.*;
import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.SamplePojo;
@@ -26,11 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Base tests for passivation using any of the cache loaders
@@ -45,26 +35,22 @@
Log log = LogFactory.getLog(getClass());
//Cache Loader fields
- protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new
ThreadLocal<CacheSPI<Object, Object>>();
- ThreadLocal<CacheLoader> loaderTL = new ThreadLocal<CacheLoader>();
static final Fqn FQN = Fqn.fromString("/key");
+ protected CacheLoader loader;
+ protected CacheSPI<Object, Object> cache;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new
UnitTestCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false);
cache.getConfiguration().setCacheMode("local");
- cacheTL.set(cache);
-
configureCache();
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.create();
cache.start();
- CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
-
- loaderTL.set(loader);
+ loader = cache.getCacheLoaderManager().getCacheLoader();
}
abstract protected void configureCache() throws Exception;
@@ -73,9 +59,6 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
log.info("**** TEARING DOWN ****");
if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
@@ -95,7 +78,6 @@
*/
protected boolean exists(String fqn, String key)
{
- CacheSPI<Object, Object> cache = cacheTL.get();
NodeSPI n = cache.peek(Fqn.fromString(fqn), false, false);
if (key == null) return n != null;
return n != null && n.getKeysDirect().contains(key);
@@ -108,9 +90,6 @@
public void testPutPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval;
@@ -130,9 +109,6 @@
public void testPut2Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
final Fqn NODE = Fqn.fromString("/a/b/c");
final String KEY = "key";
Object retval;
@@ -156,9 +132,6 @@
public void testSerializationPassivation() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Fqn fqn = Fqn.fromString("/mypojo");
SamplePojo pojo = new SamplePojo(39, "Hany");
pojo.getHobbies().add("Running");
@@ -196,8 +169,6 @@
*/
public void testPopulate()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
try
{
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -235,9 +206,6 @@
public void testPreloadingPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.removeNode(Fqn.ROOT);// remove nothing
cache.put("1/2/3/4/5/d", "key", "val");// put in
memory
cache.evict(Fqn.fromString("1/2/3/4/5/d"));// passivate node
@@ -262,8 +230,6 @@
public void testCacheLoading2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
Set<Object> keys = null;
cache.put("/a/b/c", "key", "val");
keys = cache.getNode(Fqn.fromString("/a/b/c")).getKeys();
@@ -274,8 +240,6 @@
public void testExists() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
cache.put("/eins/zwei/drei", "key1", "val1");
assert (exists("/eins/zwei/drei"));
assert (exists("/eins/zwei/drei", "key1"));
@@ -286,8 +250,6 @@
public void testGetChildren() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
cache.put("/d/one", null);
cache.put("/d/two", null);
cache.put("/d/three", null);
@@ -303,9 +265,6 @@
public void testGetChildrenWithEvictionPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/b/c/1", null);
cache.put("/a/b/c/2", null);
cache.put("/a/b/c/3", null);
@@ -339,7 +298,6 @@
public void testGetChildren2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -358,7 +316,6 @@
public void testGetChildren3()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -377,8 +334,6 @@
public void testGetChildren4()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
if (!cache.exists("/a/b/c"))
{
cache.put("/a/b/c", null);
@@ -390,7 +345,7 @@
public void testGetChildren5()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -413,9 +368,6 @@
public void testGetChildren6Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);// put node in memory
cache.put("/a/2", null);// put node in memory
cache.put("/a/3", null);// put node in memory
@@ -443,9 +395,6 @@
public void testGetChildren7Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -475,9 +424,6 @@
public void testGetChildren8Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -501,9 +447,6 @@
public void testGetChildren9Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -550,9 +493,6 @@
public void testGetChildren10Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -583,8 +523,8 @@
public void testRemoveData() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -601,9 +541,6 @@
public void testRemoveData2Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Set<Object> keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -623,9 +560,6 @@
public void testRemoveData3Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Set<Object> keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -643,8 +577,6 @@
public void testRemoveKey() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -657,8 +589,6 @@
public void testRemoveKey2() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval = null;
@@ -675,9 +605,6 @@
public void testRemoveKey3Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval = null;
@@ -703,8 +630,6 @@
public void testRemove() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -720,8 +645,6 @@
public void testRemoveRoot() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
assertEquals(0, cache.getRoot().getKeys().size());
cache.put("/1/2/3/4/5", null);
cache.put("uno/due/tre", null);
@@ -735,9 +658,6 @@
public void testEvictionWithCacheLoaderPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/first/second", "key1", "val1");
cache.put("/first/second/third", "key2", "val2");
cache.evict(Fqn.fromString("/first/second"));// pasivate node to cache
loader
@@ -758,9 +678,6 @@
public void testEvictionWithCacheLoaderPassivation2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/first/second/third", "key1", "val1");//
stored in cache loader
cache.evict(Fqn.fromString("/first/second/third"));// passivate node,
note: it has no children
addDelay();
@@ -778,9 +695,6 @@
public void testEvictionWithGetChildrenNamesPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -807,9 +721,6 @@
public void testPutDataMapAfterPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Fqn f = Fqn.fromString("/a");
assert !cache.exists(f);
assert !loader.exists(f);
@@ -835,9 +746,6 @@
public void testTxPutCommit() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
mgr.begin();
@@ -864,9 +772,6 @@
public void testTxReadCommit() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
mgr.begin();
@@ -899,9 +804,6 @@
public void testTxPutRollback() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
cache.removeNode("/one");
@@ -922,9 +824,6 @@
public void testPassivationAndActivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Object val, val2;
Fqn NODE = Fqn.fromString("/test");
loader.remove(Fqn.fromString("/"));
@@ -973,8 +872,6 @@
*/
private void doTestBasicOperations() throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* One FQN only. */
doPutTests(Fqn.fromString("/key"));
doRemoveTests(Fqn.fromString("/key"));
@@ -1004,8 +901,6 @@
private void doPutTests(Fqn fqn)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
assertTrue(!loader.exists(fqn));
/* put(Fqn,Object,Object) and get(Fqn,Object) */
@@ -1052,8 +947,6 @@
private void doRemoveTests(Fqn fqn)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* remove(Fqn,Object) */
Object oldVal;
oldVal = loader.remove(fqn, "one");
@@ -1086,8 +979,6 @@
public void testMultiLevelTree()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* Create top level node implicitly. */
Fqn k0 = Fqn.fromString("/key0");
@@ -1253,8 +1144,6 @@
public void testGetChildrenNames()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
@@ -1295,26 +1184,6 @@
checkChildren(Fqn.fromString("/key0/a"), new String[]{"1",
"2"});
checkChildren(Fqn.fromString("/key0"),
new String[]{"a", "ab", "abc", "x",
"xx", "xxx"});
- //
- // loader.put(Fqn.fromString("/key0/\u0000"), null);
- // loader.put(Fqn.fromString("/key0/\u0001"), null);
- // checkChildren(Fqn.fromString("/key0"),
- // new String[] { "a", "ab",
"abc", "x", "xx", "xxx",
- // "\u0000", "\u0001"});
- //
- // loader.put(Fqn.fromString("/\u0001"), null);
- // checkChildren(new Fqn(), new String[] { "key0", "key1",
"\u0001" });
- //
- // loader.put(Fqn.fromString("/\u0001/\u0001"), null);
- // checkChildren(Fqn.fromString("/\u0001"), new String[] {
"\u0001" });
- //
- // loader.put(Fqn.fromString("/\u0001/\uFFFF"), null);
- // checkChildren(Fqn.fromString("/\u0001"),
- // new String[] { "\u0001", "\uFFFF" });
- //
- // loader.put(Fqn.fromString("/\u0001/\uFFFF/\u0001"), null);
- // checkChildren(Fqn.fromString("/\u0001/\uFFFF"),
- // new String[] { "\u0001" });
}
/**
@@ -1323,8 +1192,6 @@
private void checkChildren(Fqn fqn, String[] names)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
Set set = loader.getChildrenNames(fqn);
if (names != null)
{
@@ -1368,8 +1235,6 @@
private void doTestModifications()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* PUT_KEY_VALUE, PUT_DATA */
List<Modification> list = createUpdates();
loader.put(list);
@@ -1416,8 +1281,6 @@
public void testOnePhaseTransaction()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
checkModifications(mods);
@@ -1429,15 +1292,9 @@
public void testTwoPhaseTransactionPassivation()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
Object txnKey = new Object();
List<Modification> mods = createUpdates();
loader.prepare(txnKey, mods, false);
- // try {
- // checkModifications(mods);
- // // fail("Expected lock timeout");
- // } catch (DeadlockException expected) {}
loader.commit(txnKey);
addDelay();
checkModifications(mods);
@@ -1449,8 +1306,6 @@
public void testTransactionRollbackPassivation()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
loader.remove(Fqn.fromString("/"));
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
@@ -1477,7 +1332,6 @@
*/
private List<Modification> createUpdates()
{
-
List<Modification> list = new ArrayList<Modification>();
Map<String, String> map = new HashMap<String, String>();
@@ -1512,8 +1366,6 @@
private void checkModifications(List<Modification> list)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
for (Modification mod : list)
{
Fqn fqn = mod.getFqn();
@@ -1553,8 +1405,6 @@
public void testNullKeysAndValues()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
loader.put(FQN, null, "x");
addDelay();
assertEquals("x", loader.get(FQN).get(null));
@@ -1609,8 +1459,6 @@
public void testDatabaseNamePassivation()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
loader.put(FQN, "one", "two");
addDelay();
assertEquals("two", loader.get(FQN).get("one"));
@@ -1622,17 +1470,8 @@
public void testLoadAndStore()
throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
/* Empty state. */
loader.remove(Fqn.fromString("/"));
- // assertEquals(0, loader.loadEntireState().length);
- // loader.storeEntireState(new byte[0]);
- // assertEquals(0, loader.loadEntireState().length);
- // loader.storeEntireState(null);
- // assertEquals(0, loader.loadEntireState().length);
- // assertEquals(null, loader.get(FQN));
/* Use a complex object to ensure that the class catalog is used. */
Complex c1 = new Complex();
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -56,8 +56,6 @@
String tmpDir = TestingUtil.TEST_FILES;
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir +
"/JBossCache-PassivationToBdbjeCacheLoaderTest-" + threadId;
-
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true,
null, "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" +
tmpCLLoc, false, false, false, false, false));
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -10,7 +10,6 @@
{
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig clc = new CacheLoaderConfig();
cache.getConfiguration().setCacheLoaderConfig(clc);
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new
CacheLoaderConfig.IndividualCacheLoaderConfig();
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -31,7 +31,6 @@
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpLocation +
"/JBossCache-PassivationToFileCacheLoaderTest-" + threadId;
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true,
null, "org.jboss.cache.loader.FileCacheLoader", "location=" +
tmpCLLoc, false, false, false, false, false));
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -7,15 +7,16 @@
package org.jboss.cache.passivation;
import java.util.Properties;
-import org.jboss.cache.CacheSPI;
+
import org.jboss.cache.Fqn;
-import org.jboss.cache.loader.CacheLoader;
import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.TestDbPropertiesFactory;
import org.testng.annotations.Test;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
/**
* Tests passivation using JDBC Cache Loader.
@@ -27,29 +28,35 @@
@Test(groups = "functional", testName =
"passivation.PassivationToJDBCCacheLoaderTest")
public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
{
- private String getJDBCProps()
+
+ private Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
- return "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") + "\n" +
- "cache.jdbc.sql-concat=" +
prop.getProperty("cache.jdbc.sql-concat") + "\n" +
- "cache.jdbc.table.name=passivationtojdbc" +
TestingUtil.getThreadId() + "\n" +
- "cache.jdbc.table.primarykey=passivationtojdbc_pk" +
TestingUtil.getThreadId();
-
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
}
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis()
- durration)/1000);
+ }
+
+ private Properties getJDBCProps()
+ {
+ return props;
+ }
+
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
log.info("**** TEARING DOWN ****");
if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
- Properties props = loader.getConfig().getProperties();
TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
}
@@ -58,7 +65,6 @@
{
CacheLoaderConfig loaderConfig = buildSingleCacheLoaderConfig(true, null,
"org.jboss.cache.loader.JDBCCacheLoader",
getJDBCProps(), false, false, false, false, false);
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(loaderConfig);
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2008-12-09
15:01:40 UTC (rev 7268)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -37,7 +37,6 @@
CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
cacheLoaderConfig.addIndividualCacheLoaderConfig(cfg);
cacheLoaderConfig.setPassivation(true);
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(cacheLoaderConfig);
}
Modified: core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-12-09
15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-12-09
15:04:25 UTC (rev 7269)
@@ -8,6 +8,9 @@
import java.io.IOException;
import java.io.File;
import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.SQLException;
/**
* @author Mircea.Markus(a)jboss.com
@@ -41,19 +44,37 @@
public static void shutdownInMemoryDatabase(Properties props)
{
+ Connection conn = null;
+ Statement st = null;
try
{
String shutDownConnection = getShutdownUrl(props);
+ String url = props.getProperty("cache.jdbc.url");
+ assert url != null;
System.out.println("shutDownConnection = " + shutDownConnection);
- DriverManager.getConnection(shutDownConnection);
- assert false: "Exception should be raised to confirm the DB is
closed";
- //here is why: Important: The XJ015 error (successful shutdown of the Derby
engine) and the 08006 error
- //(successful shutdown of a single database) are the *only exceptions thrown by
Derby that might indicate that an operation succeeded*.
+ conn = DriverManager.getConnection(shutDownConnection);
+ st = conn.createStatement();
+ st.execute("SHUTDOWN");
}
catch (Throwable e)
{
- //expected
+ throw new IllegalStateException(e);
}
+ finally
+ {
+ try
+ {
+ conn.close();
+ st.close();
+ } catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void clearDatabaseFiles(Properties props)
+ {
//now delete the disk folder
String dbName = getDatabaseName(props);
String toDel = TestingUtil.TEST_FILES + File.separator + dbName;
@@ -63,10 +84,11 @@
public static String getDatabaseName(Properties prop)
{
- //jdbc:derby:jbossdb;create=true
- StringTokenizer tokenizer = new
StringTokenizer(prop.getProperty("cache.jdbc.url"), ":;");
+ //jdbc:hsqldb:mem:jbosscache
+ StringTokenizer tokenizer = new
StringTokenizer(prop.getProperty("cache.jdbc.url"), ":");
tokenizer.nextToken();
tokenizer.nextToken();
+ tokenizer.nextToken();
return tokenizer.nextToken();
}
@@ -83,18 +105,33 @@
private static Properties returnBasedOnDifferentInstance()
{
+ //jdbc:hsqldb:mem:jbosscache
Properties toReturn = (Properties) realProps.clone();
String jdbcUrl = toReturn.getProperty("cache.jdbc.url");
- Pattern pattern = Pattern.compile("jbossdb");
+ Pattern pattern = Pattern.compile("jbosscache");
Matcher matcher = pattern.matcher(jdbcUrl);
boolean found = matcher.find();
assert found;
- String newJdbcUrl = matcher.replaceFirst("jbossdb" +
userIndex.incrementAndGet());
+ String newJdbcUrl = matcher.replaceFirst(extractTestName() +
userIndex.incrementAndGet());
System.out.println("newJdbcUrl = " + newJdbcUrl);
toReturn.put("cache.jdbc.url", newJdbcUrl);
return toReturn;
}
+ private static String extractTestName()
+ {
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ if (stack.length == 0) return null;
+ for (int i = stack.length - 1; i > 0; i--)
+ {
+ StackTraceElement e = stack[i];
+ String className = e.getClassName();
+ if (className.indexOf("org.jboss.cache") != -1) return
className.replace('.','_') + "_" + e.getMethodName();
+ }
+ return null;
+ }
+
+
private static Properties returnBasedOnDifferentTables()
{
Properties toReturn = (Properties) realProps.clone();
Modified: core/trunk/src/test/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/test/resources/cache-jdbc.properties 2008-12-09 15:01:40 UTC (rev
7268)
+++ core/trunk/src/test/resources/cache-jdbc.properties 2008-12-09 15:04:25 UTC (rev
7269)
@@ -11,7 +11,7 @@
cache.jdbc.fqn.column=fqn
cache.jdbc.fqn.type=varchar(255)
cache.jdbc.node.column=node
-cache.jdbc.node.type=blob
+cache.jdbc.node.type=BINARY
cache.jdbc.parent.column=parent
# Specify your DBMS's string concatenation function syntax in the following manner:
concat(1 , 2) -> '12'.
# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql,
PostgreSQL. Derby - on which
@@ -63,7 +63,8 @@
#cache.jdbc.password=admin
## Derby
-cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
-cache.jdbc.url=jdbc:derby:jbossdb;create=true
-cache.jdbc.user=user1
-cache.jdbc.password=user1
+cache.jdbc.driver = org.hsqldb.jdbcDriver
+cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
+cache.jdbc.user=sa
+cache.jdbc.password=
+