[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/loader ...
Elias Ross
genman at noderunner.net
Wed Feb 7 17:06:49 EST 2007
User: genman
Date: 07/02/07 17:06:49
Modified: tests/functional/org/jboss/cache/loader
SamplePojo.java BdbjeTest.java
AsyncFileCacheLoaderTest.java
RpcDelegatingCacheLoaderTests.java
CacheLoaderWithReplicationTest.java
CacheLoaderTestsBase.java
ChainingCacheLoaderFullTest.java
DataSourceIntegrationTest.java
TxCacheLoaderTest.java
Added: tests/functional/org/jboss/cache/loader
CacheLoaderWithReplicationTest.java.tmp
Log:
JBCACHE-969 - Move transaction classes to org.jboss.cache.transaction
Revision Changes Path
1.3 +15 -7 JBossCache/tests/functional/org/jboss/cache/loader/SamplePojo.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SamplePojo.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/SamplePojo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- SamplePojo.java 24 Jul 2005 00:06:21 -0000 1.2
+++ SamplePojo.java 7 Feb 2007 22:06:49 -0000 1.3
@@ -5,8 +5,10 @@
import java.util.List;
/**
+ * Sample object for testing.
+ *
* @author Bela Ban
- * @version $Id: SamplePojo.java,v 1.2 2005/07/24 00:06:21 msurtani Exp $
+ * @version $Id: SamplePojo.java,v 1.3 2007/02/07 22:06:49 genman Exp $
*/
public class SamplePojo implements Serializable {
int age;
@@ -48,13 +50,19 @@
public boolean equals(Object o)
{
- if (o instanceof SamplePojo)
+ if (!(o instanceof SamplePojo))
{
+ return false;
+ }
+
SamplePojo other = (SamplePojo) o;
boolean equals = (name.equals(other.getName())) && (age == other.getAge()) && (hobbies.equals(other.getHobbies()));
return equals;
}
- else
- return false;
+
+ public int hashCode()
+ {
+ return name.hashCode() ^ age ^ hobbies.hashCode();
}
+
}
1.20 +2 -2 JBossCache/tests/functional/org/jboss/cache/loader/BdbjeTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BdbjeTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/BdbjeTest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- BdbjeTest.java 29 Jan 2007 16:55:47 -0000 1.19
+++ BdbjeTest.java 7 Feb 2007 22:06:49 -0000 1.20
@@ -37,7 +37,7 @@
* directory. Any scratch directory will do, but beware that all files in
* the directory will be deleted by setUp().</p>
*
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.20 $
*/
public class BdbjeTest extends TestCase
{
@@ -145,7 +145,7 @@
if (transactional)
{
cache.getConfiguration().setTransactionManagerLookupClass(
- "org.jboss.cache.DummyTransactionManagerLookup");
+ "org.jboss.cache.transaction.DummyTransactionManagerLookup");
}
cache.start();
1.22 +2 -2 JBossCache/tests/functional/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AsyncFileCacheLoaderTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- AsyncFileCacheLoaderTest.java 30 Jan 2007 00:11:39 -0000 1.21
+++ AsyncFileCacheLoaderTest.java 7 Feb 2007 22:06:49 -0000 1.22
@@ -108,12 +108,12 @@
Fqn fqn = Fqn.fromString("/bound");
loader.remove(fqn);
// You can't really see it block though :-/
- for (int i = 0; i < 100; i++)
+ for (int i = 0; i < 50; i++)
{
cache.put(fqn, "key" + i, "value1");
}
Thread.sleep(1000);
- assertEquals(100, loader.get(fqn).size());
+ assertEquals(50, loader.get(fqn).size());
loader.remove(fqn);
}
1.11 +2 -2 JBossCache/tests/functional/org/jboss/cache/loader/RpcDelegatingCacheLoaderTests.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RpcDelegatingCacheLoaderTests.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/RpcDelegatingCacheLoaderTests.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- RpcDelegatingCacheLoaderTests.java 11 Jan 2007 13:49:06 -0000 1.10
+++ RpcDelegatingCacheLoaderTests.java 7 Feb 2007 22:06:49 -0000 1.11
@@ -12,7 +12,7 @@
/**
* @author Bela Ban
- * @version $Id: RpcDelegatingCacheLoaderTests.java,v 1.10 2007/01/11 13:49:06 msurtani Exp $
+ * @version $Id: RpcDelegatingCacheLoaderTests.java,v 1.11 2007/02/07 22:06:49 genman Exp $
*/
public class RpcDelegatingCacheLoaderTests
{
@@ -63,7 +63,7 @@
cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
cache.getConfiguration().setFetchInMemoryState(true);
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig());
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.start();
if (client == false)
1.28 +2 -2 JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoaderWithReplicationTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- CacheLoaderWithReplicationTest.java 11 Jan 2007 13:49:06 -0000 1.27
+++ CacheLoaderWithReplicationTest.java 7 Feb 2007 22:06:49 -0000 1.28
@@ -55,11 +55,11 @@
{
cache1 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpLocation1, false, true, false));
- cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache2 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpLocation2, false, true, false));
- cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
}
public void tearDown() throws Exception
1.47 +2 -2 JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoaderTestsBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- CacheLoaderTestsBase.java 29 Jan 2007 16:55:47 -0000 1.46
+++ CacheLoaderTestsBase.java 7 Feb 2007 22:06:49 -0000 1.47
@@ -32,7 +32,7 @@
* Commons tests for all CacheLoaders
*
* @author Bela Ban
- * @version $Id: CacheLoaderTestsBase.java,v 1.46 2007/01/29 16:55:47 msurtani Exp $
+ * @version $Id: CacheLoaderTestsBase.java,v 1.47 2007/02/07 22:06:49 genman Exp $
*/
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
@@ -69,7 +69,7 @@
Configuration c = new Configuration();
cache.setConfiguration(c);
c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
configureCache();
cache.start();
loader = cache.getCacheLoaderManager().getCacheLoader();
1.13 +1 -1 JBossCache/tests/functional/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ChainingCacheLoaderFullTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- ChainingCacheLoaderFullTest.java 1 Feb 2007 16:33:10 -0000 1.12
+++ ChainingCacheLoaderFullTest.java 7 Feb 2007 22:06:49 -0000 1.13
@@ -58,7 +58,7 @@
TestingUtil.recursiveFileRemove(loc2);
cache.getConfiguration().setCacheMode("local");
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.start();
chainingCacheLoader = (ChainingCacheLoader) cache.getCacheLoaderManager().getCacheLoader();
1.13 +1 -1 JBossCache/tests/functional/org/jboss/cache/loader/DataSourceIntegrationTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DataSourceIntegrationTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/DataSourceIntegrationTest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- DataSourceIntegrationTest.java 11 Jan 2007 13:49:06 -0000 1.12
+++ DataSourceIntegrationTest.java 7 Feb 2007 22:06:49 -0000 1.13
@@ -62,7 +62,7 @@
}
cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache.getConfiguration().setCacheMode("local");
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(JNDI_NAME));
cache.create();
1.10 +3 -3 JBossCache/tests/functional/org/jboss/cache/loader/TxCacheLoaderTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TxCacheLoaderTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/TxCacheLoaderTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- TxCacheLoaderTest.java 11 Jan 2007 13:49:06 -0000 1.9
+++ TxCacheLoaderTest.java 7 Feb 2007 22:06:49 -0000 1.10
@@ -17,7 +17,7 @@
/**
* @author Bela Ban
- * @version $Id: TxCacheLoaderTest.java,v 1.9 2007/01/11 13:49:06 msurtani Exp $
+ * @version $Id: TxCacheLoaderTest.java,v 1.10 2007/02/07 22:06:49 genman Exp $
*/
public class TxCacheLoaderTest extends AbstractCacheLoaderTestBase
{
@@ -33,7 +33,7 @@
cache1 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache1.getConfiguration().setCacheMode("repl_sync");
- cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "location=" + location, false, false, false));
// cache1.setReplQueueInterval(3000);
@@ -44,7 +44,7 @@
cache2 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache2.getConfiguration().setCacheMode("repl_sync");
- cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "location=" + location, false, false, false));
cache2.getConfiguration().setLockAcquisitionTimeout(2000);
// cache2.setReplQueueInterval(3000);
1.1 date: 2007/02/07 22:06:49; author: genman; state: Exp;JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java.tmp
Index: CacheLoaderWithReplicationTest.java.tmp
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.loader;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheImpl;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.misc.TestingUtil;
import javax.transaction.TransactionManager;
import java.io.File;
/**
* Tests using cache loaders with replicating data
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
public class CacheLoaderWithReplicationTest extends AbstractCacheLoaderTestBase
{
private CacheImpl cache1, cache2;
private String tmpLocation1 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-CacheLoaderWithReplicationTest1";
private String tmpLocation2 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-CacheLoaderWithReplicationTest2";
private File dir1 = new File(tmpLocation1);
private File dir2 = new File(tmpLocation2);
private Fqn fqn = Fqn.fromString("/a");
private String key = "key";
private static final Log log = LogFactory.getLog(CacheLoaderWithReplicationTest.class);
public CacheLoaderWithReplicationTest()
{
recursivedelete(dir1);
recursivedelete(dir2);
if (!dir1.exists()) dir1.mkdirs();
if (!dir2.exists()) dir2.mkdirs();
log.debug(" System props dump: " + System.getProperties());
log.debug("Using location for CL 1 : " + tmpLocation1);
log.debug("Using location for CL 2 : " + tmpLocation2);
}
public void setUp() throws Exception
{
<<<<<<< CacheLoaderWithReplicationTest.java
super.setUp();
cache1 = new CacheImpl();
=======
cache1 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
>>>>>>> 1.27
cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpLocation1, false, true, false));
cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
cache2 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpLocation2, false, true, false));
cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
}
public void tearDown() throws Exception
{
if (cache1 != null)
{
try
{
cache1.remove(fqn);
cache1.getCacheLoaderManager().getCacheLoader().remove(fqn);
cache1.stop();
}
finally
{
cache1 = null;
}
}
if (cache2 != null)
{
try
{
cache2.remove(fqn);
cache2.getCacheLoaderManager().getCacheLoader().remove(fqn);
cache2.stop();
}
finally
{
cache2 = null;
}
}
recursivedelete(dir1);
recursivedelete(dir2);
}
private void recursivedelete(File f)
{
if (f.isDirectory())
{
File[] files = f.listFiles();
for (int i = 0; i < files.length; i++)
{
recursivedelete(files[i]);
}
}
//System.out.println("File " + f.toURI() + " deleted = " + f.delete());
f.delete();
}
public void testPessSyncRepl() throws Exception
{
cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
cache1.start();
cache2.start();
Assert.assertNull(cache1.get(fqn, key));
Assert.assertNull(cache2.get(fqn, key));
CacheLoader loader1 = cache1.getCacheLoaderManager().getCacheLoader();
CacheLoader loader2 = cache2.getCacheLoaderManager().getCacheLoader();
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
cache1.put(fqn, key, "value");
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertNull(cache2.get(fqn, key));
Assert.assertNull(loader1.get(fqn));
Assert.assertNull(loader2.get(fqn));
mgr.commit();
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.begin();
cache1.put(fqn, key, "value2");
Assert.assertEquals("value2", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.rollback();
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
// force clean up
tearDown();
}
public void testPessAsyncRepl() throws Exception
{
cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
cache1.start();
cache2.start();
CacheLoader loader1 = cache1.getCacheLoaderManager().getCacheLoader();
CacheLoader loader2 = cache2.getCacheLoaderManager().getCacheLoader();
// make sure everything is empty...
Assert.assertNull(loader1.get(fqn));
Assert.assertNull(loader2.get(fqn));
Assert.assertNull(cache1.get(fqn));
Assert.assertNull(cache2.get(fqn));
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
cache1.put(fqn, key, "value");
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertNull(cache2.get(fqn, key));
Assert.assertNull(loader1.get(fqn));
Assert.assertNull(loader2.get(fqn));
mgr.commit();
TestingUtil.sleepThread(500);
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.begin();
cache1.put(fqn, key, "value2");
Assert.assertEquals("value2", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.rollback();
TestingUtil.sleepThread(500);
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
// force clean up
tearDown();
}
public void testOptSyncRepl() throws Exception
{
try
{
cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
cache1.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
cache2.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
cache1.start();
cache2.start();
CacheLoader loader1 = cache1.getCacheLoaderManager().getCacheLoader();
CacheLoader loader2 = cache2.getCacheLoaderManager().getCacheLoader();
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
cache1.put(fqn, key, "value");
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertNull(cache2.get(fqn, key));
Assert.assertNull(loader1.get(fqn));
Assert.assertNull(loader2.get(fqn));
log.info("BEFORE COMMIT" + cache2.toString(true));
mgr.commit();
log.info("AFTER COMMIT" + cache2.toString(true));
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.begin();
cache1.put(fqn, key, "value2");
Assert.assertEquals("value2", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.rollback();
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
}
catch (Exception e)
{
Assert.assertTrue("Caught exception " + e.getMessage(), false);
e.printStackTrace();
}
// force clean up
tearDown();
}
public void testOptAsyncRepl() throws Exception
{
cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
cache1.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
cache2.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
cache1.start();
cache2.start();
CacheLoader loader1 = cache1.getCacheLoaderManager().getCacheLoader();
CacheLoader loader2 = cache2.getCacheLoaderManager().getCacheLoader();
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
cache1.put(fqn, key, "value");
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertNull(cache2.get(fqn, key));
Assert.assertNull(loader1.get(fqn));
Assert.assertNull(loader2.get(fqn));
mgr.commit();
TestingUtil.sleepThread(500);
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.begin();
cache1.put(fqn, key, "value2");
Assert.assertEquals("value2", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
mgr.rollback();
TestingUtil.sleepThread(500);
Assert.assertEquals("value", cache1.get(fqn, key));
Assert.assertEquals("value", cache2.get(fqn, key));
Assert.assertEquals("value", loader1.get(fqn).get(key));
Assert.assertEquals("value", loader2.get(fqn).get(key));
// force clean up
tearDown();
}
public static Test suite()
{
return new TestSuite(CacheLoaderWithReplicationTest.class);
}
public static void main(String[] args)
{
junit.textui.TestRunner.run(suite());
}
}
More information about the jboss-cvs-commits
mailing list