Author: mircea.markus
Date: 2008-12-16 08:44:26 -0500 (Tue, 16 Dec 2008)
New Revision: 7332
Added:
core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleWithReplTest.java
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyCountingCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummySharedInMemoryCacheLoader.java
Removed:
core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyCountingCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java
Modified:
core/trunk/src/main/java/org/jboss/cache/RegionImpl.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
core/trunk/src/test/java/org/jboss/cache/AbstractMultipleCachesTest.java
core/trunk/src/test/java/org/jboss/cache/AbstractSingleCacheTest.java
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.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/api/nodevalidity/InvalidatedOptNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java
core/trunk/src/test/java/org/jboss/cache/invalidation/CacheLoaderInvalidationTest.java
core/trunk/src/test/java/org/jboss/cache/invalidation/PessWithCacheLoaderInvalidationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.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/CacheLoaderManagerTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.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/JDBCCacheLoaderConnectionTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.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/PreloadTest.java
core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
Log:
fix tests
Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-12-15 14:33:25 UTC (rev
7331)
+++ core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-12-16 13:44:26 UTC (rev
7332)
@@ -204,6 +204,7 @@
public void resetEvictionQueues()
{
evictionEventQueue.clear();
+ evictionAlgorithm.getEvictionQueue().clear();
}
public void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -280,7 +280,10 @@
{
return returnValue;
}
-
+ if (command.isErase())
+ {
+ loader.removeData(command.getFqn());
+ }
storeStateForPutDataMap(command.getFqn(), ctx);
if (getStatisticsEnabled()) cacheStores++;
Modified: core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2008-12-15 14:33:25
UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2008-12-16 13:44:26
UTC (rev 7332)
@@ -5,14 +5,19 @@
*/
public class AbstractCacheTest<K, V>
{
+ /**
+ * Importnat: do not reset RegionManager (rm.reset()) here, as this woulfd cause
eviction region to be clered.
+ * If that is needed, do it in @BeforeMethods
+ */
public void clearContent(CacheSPI<K, V> cache)
{
clearRunningTx(cache);
if (!cache.getCacheStatus().allowInvocations()) return;
- cache.getRoot().clearDataDirect();
- cache.getRoot().removeChildrenDirect();
- RegionManager regionManager = cache.getRegionManager();
- if (regionManager != null) regionManager.reset();
+ if (cache.getRoot() != null)
+ {
+ cache.getRoot().clearDataDirect();
+ cache.getRoot().removeChildrenDirect();
+ }
//impoortant!!! keep invocation ctxt cleanup as the last line in the cleanup
process, prev calls modify
// OptionOverrides
cache.getInvocationContext().reset();
Modified: core/trunk/src/test/java/org/jboss/cache/AbstractMultipleCachesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/AbstractMultipleCachesTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/AbstractMultipleCachesTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -30,6 +30,7 @@
@AfterMethod
protected void clearContent() throws Throwable
{
+ if (caches.isEmpty()) throw new IllegalStateException("No caches registered!
Use registerCaches(Cache... caches) do that!");
for (CacheSPI<K, V> cache : caches)
{
super.clearContent(cache);
Modified: core/trunk/src/test/java/org/jboss/cache/AbstractSingleCacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/AbstractSingleCacheTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/AbstractSingleCacheTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -15,7 +15,7 @@
protected CacheSPI<K, V> cache;
@BeforeClass
- protected void create()
+ protected void create() throws Exception
{
cache = createCache();
}
@@ -32,5 +32,5 @@
super.clearContent(cache);
}
- protected abstract CacheSPI<K, V> createCache();
+ protected abstract CacheSPI<K, V> createCache() throws Exception;
}
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-12-15 14:33:25
UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-12-16 13:44:26
UTC (rev 7332)
@@ -38,6 +38,8 @@
private final Log log = LogFactory.getLog(UnitTestCacheFactory.class);
+ public static AtomicInteger replCacheCount = new AtomicInteger(0);
+ public static AtomicInteger localCacheCount = new AtomicInteger(0);
/**
* Holds unique mcast_addr for each thread used for JGroups channel construction.
@@ -106,6 +108,12 @@
public Cache<K, V> createCache(String configFileName, boolean start, Class
ownerClass) throws ConfigurationException
{
+ Configuration c = getConfigurationFromFile(configFileName);
+ return createCache(c, start, ownerClass);
+ }
+
+ public Configuration getConfigurationFromFile(String configFileName)
+ {
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c;
try
@@ -117,7 +125,7 @@
XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
c = oldParser.parseFile(configFileName);
}
- return createCache(c, start, ownerClass);
+ return c;
}
public Cache<K, V> createCache(Configuration configuration, Class ownerClass)
throws ConfigurationException
@@ -146,6 +154,7 @@
{
case LOCAL:
// local cache, no channel used
+ localCacheCount.incrementAndGet();
break;
case REPL_SYNC:
case REPL_ASYNC:
@@ -153,6 +162,7 @@
case INVALIDATION_SYNC:
// replicated cache, update channel setup
mangleConfiguration(configuration);
+ replCacheCount.incrementAndGet();
break;
default:
log.info("Unknown cache mode!");
@@ -207,11 +217,6 @@
public void removeCache(Cache c)
{
- // - Do not print out this exception - since tests are ALSO run from IDEs on the
main thread. - MANIK
-// if (!Thread.currentThread().getName().contains("pool"))
-// {
-// System.out.println("RemoveCache called from wrong thread.");
-// }
List<Cache> caches = threadCaches.get();
synchronized (allCaches)
@@ -267,14 +272,7 @@
}
- // - Do not print out this exception - since tests are ALSO run from IDEs on the
main thread. - MANIK
-//
-// if (Thread.currentThread().getName().equals("main")) {
-// Exception e = new Exception("Invoked from main thread.");
-// e.printStackTrace();
-// };
-
- // replace mcast_addr
+ // replace mcast_addr
Pattern pattern = Pattern.compile("mcast_addr=[^;]*");
Matcher m = pattern.matcher(clusterConfig);
if (m.find())
Modified: core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java 2008-12-15 14:33:25 UTC
(rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java 2008-12-16 13:44:26 UTC
(rev 7332)
@@ -54,6 +54,7 @@
public void tearDown()
{
events.clear();
+ cache.getRegionManager().reset();
}
protected NodeLockingScheme getNodeLockingScheme()
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-12-15 14:33:25
UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-12-16 13:44:26
UTC (rev 7332)
@@ -8,7 +8,7 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.element.LoadersElementParser;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -47,8 +47,8 @@
cache2.getConfiguration().setSyncCommitPhase(true);
cache2.getConfiguration().setSyncRollbackPhase(true);
cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(cache2.getConfiguration());
cache2.start();
- configure(cache2.getConfiguration());
registerCaches(cache1, cache2);
}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -16,9 +16,9 @@
public class CacheLoaderTest extends DummyInMemoryCacheLoaderTest
{
@Override
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
- super.configureCache();
+ super.configureCache(cache);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,13 +1,12 @@
package org.jboss.cache.api.mvcc.read_committed;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.api.mvcc.LockAssert;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.passivation.PassivationTestsBase;
@@ -26,7 +25,8 @@
String binName = "bin-" + Thread.currentThread().getName();
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "debug=true\nbin=" + binName,
false, true, false);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
DummySharedInMemoryCacheLoader.class.getName(),
+ "debug=true\nbin=" + binName, false, true, false, false, false);
clc.setPassivation(true);
cache.getConfiguration().setCacheLoaderConfig(clc);
}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -16,9 +16,9 @@
public class CacheLoaderTest extends DummyInMemoryCacheLoaderTest
{
@Override
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
- super.configureCache();
+ super.configureCache(cache);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,12 +1,12 @@
package org.jboss.cache.api.mvcc.repeatable_read;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.api.mvcc.LockAssert;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.passivation.PassivationTestsBase;
@@ -22,7 +22,8 @@
{
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);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
DummySharedInMemoryCacheLoader.class.getName(),
+ "bin=" + Thread.currentThread().getName() + getClass().getName(),
false, true, false, false, false);
clc.setPassivation(true);
cache.getConfiguration().setCacheLoaderConfig(clc);
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,10 +1,8 @@
package org.jboss.cache.api.nodevalidity;
-import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.testng.annotations.Test;
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,17 +1,13 @@
package org.jboss.cache.api.nodevalidity;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
-import org.testng.annotations.AfterMethod;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.testng.annotations.Test;
-import org.testng.annotations.AfterTest;
import org.testng.annotations.AfterClass;
import java.util.Properties;
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -15,7 +15,7 @@
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
Modified:
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -92,6 +92,7 @@
assert !appender.isFoundUnknownWarning();
Cache cache = ucf.createCache(CONFIG_ROOT + "/" + aConfFile, true,
getClass());
cache.stop();
+ cache.destroy();
assert !appender.isFoundUnknownWarning();
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -8,7 +8,6 @@
package org.jboss.cache.eviction;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -24,7 +23,7 @@
import org.testng.annotations.Test;
import java.io.IOException;
-import java.util.Properties;
+
import org.jboss.cache.UnitTestCacheFactory;
/**
@@ -70,7 +69,7 @@
cacheLoaderConfig.setPreload("/");
cacheLoaderConfig.setShared(false);
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new
CacheLoaderConfig.IndividualCacheLoaderConfig();
- iclc.setClassName("org.jboss.cache.loader.DummyInMemoryCacheLoader");
+
iclc.setClassName("org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader");
iclc.setAsync(false);
iclc.setFetchPersistentState(true);
iclc.setIgnoreModifications(false);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -38,7 +38,7 @@
CacheSPI<Object, Object> cache;
long wakeupIntervalMillis = 0;
final String ROOT_STR = "/test";
- Throwable t1_ex, t2_ex;
+ volatile Throwable t1_ex, t2_ex;
volatile boolean isTrue;
int maxNodes = 50;
@@ -295,16 +295,11 @@
}
}
-
public void testConcurrentPutAndEvict() throws Exception
{
- cache.stop();
- cache.destroy();
- cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- cache.start();
cache.put(ROOT_STR + "/concurrentPutAndEvict", "value", 1);
List<MyPutter> putters = new ArrayList<MyPutter>();
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 5; i++)
{
MyPutter p = new MyPutter("Putter" + i);
putters.add(p);
@@ -319,7 +314,7 @@
{
fail("Exception generated in put() " + t1_ex);
}
- TestingUtil.sleepThread(1000);
+ TestingUtil.sleepThread(250);
if (counter > 5)
{// run for 5 seconds
isTrue = false;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -26,7 +26,7 @@
@Test(groups = {"functional"}, sequential = true, testName =
"eviction.FIFOQueueTest")
public class FIFOQueueTest
{
- private static final int CAPACITY = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+ private static final int CAPACITY = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT/4;
private FIFOQueue queue;
@@ -110,14 +110,12 @@
public void testLargeAddAndRemoval() throws Exception
{
- long begin = System.currentTimeMillis();
for (int i = 0; i < CAPACITY; i++)
{
queue.addNodeEntry(new NodeEntry("/test/" + Integer.toString(i)));
}
assertEquals(CAPACITY, queue.getNumberOfNodes());
- begin = System.currentTimeMillis();
for (int i = CAPACITY - 1; i >= 0; i--)
{
// pop it backwards for worse case scenario if O(n) = n
@@ -126,14 +124,12 @@
assertEquals(0, queue.getNumberOfNodes());
- begin = System.currentTimeMillis();
for (int i = 0; i < CAPACITY; i++)
{
queue.addNodeEntry(new NodeEntry("/test/" + Integer.toString(i)));
}
assertEquals(CAPACITY, queue.getNumberOfNodes());
NodeEntry ne;
- begin = System.currentTimeMillis();
while ((ne = queue.getFirstNodeEntry()) != null)
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -306,8 +306,7 @@
}
}
}
-
-
+ //todo mmarkus create a test profile to use greater values for thread count below
public void testConcurrentPutAndEvict() throws Exception
{
cache.stop();
@@ -316,7 +315,7 @@
cache.start();
cache.put(ROOT_STR + "/concurrentPutAndEvict", "value", 1);
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 5; i++)
{
new MyPutter("Putter" + i).start();
}
@@ -329,7 +328,7 @@
{
fail("Exception generated in put() " + t1_ex);
}
- TestingUtil.sleepThread(1000);
+ TestingUtil.sleepThread(250);
if (counter > 5)
{// run for 5 seconds
isTrue = false;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -16,6 +16,7 @@
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.EvictionController;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -81,7 +82,8 @@
cache.put("/org/jboss/test/data/d", "/org/jboss/test/data/d",
"/org/jboss/test/data/d");
cache.put("/org/jboss/test/data/e", "/org/jboss/test/data/e",
"/org/jboss/test/data/e");
- TestingUtil.sleepThread(wakeupIntervalMillis + 800);
+ EvictionController ec = new EvictionController(cache);
+ ec.startEviction();
cache.put("/org/jboss/test/data/f", "/org/jboss/test/data/f",
"/org/jboss/test/data/f");
cache.put("/org/jboss/test/data/g", "/org/jboss/test/data/g",
"/org/jboss/test/data/g");
@@ -89,7 +91,7 @@
assertNotNull(cache.get("/org/jboss/test/data/a",
"/org/jboss/test/data/a"));
assertNotNull(cache.get("/org/jboss/test/data/b",
"/org/jboss/test/data/b"));
- TestingUtil.sleepThread(wakeupIntervalMillis + 800);
+ ec.startEviction();
assertNull(cache.get("/org/jboss/test/data/a",
"/org/jboss/test/data/a"));
assertNull(cache.get("/org/jboss/test/data/b",
"/org/jboss/test/data/b"));
@@ -103,14 +105,16 @@
cache.put("/org/jboss/test/data/d", "/org/jboss/test/data/d",
"/org/jboss/test/data/d");
cache.put("/org/jboss/test/data/e", "/org/jboss/test/data/e",
"/org/jboss/test/data/e");
- TestingUtil.sleepThread(wakeupIntervalMillis + 500);
+ EvictionController ec = new EvictionController(cache);
+ ec.startEviction();
+
cache.removeNode("/org/jboss/test/data/d");
cache.removeNode("/org/jboss/test/data/e");
cache.put("/org/jboss/test/data/f", "/org/jboss/test/data/f",
"/org/jboss/test/data/f");
cache.put("/org/jboss/test/data/g", "/org/jboss/test/data/g",
"/org/jboss/test/data/g");
- TestingUtil.sleepThread(wakeupIntervalMillis + 500);
+ ec.startEviction();
assertNull(cache.get("/org/jboss/test/data/d",
"/org/jboss/test/data/d"));
assertNull(cache.get("/org/jboss/test/data/e",
"/org/jboss/test/data/e"));
@@ -159,7 +163,7 @@
cache.start();
cache.put(ROOT_STR + "/concurrentPutAndEvict", "value", 1);
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 5; i++)
{
new MyPutter("Putter" + i).start();
}
@@ -172,7 +176,7 @@
{
fail("Exception generated in put() " + t1_ex);
}
- TestingUtil.sleepThread(1000);
+ TestingUtil.sleepThread(250);
if (counter > 5)
{// run for 5 seconds
isTrue = false;
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -13,7 +13,7 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.interceptors.*;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
Modified: core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -7,7 +7,7 @@
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.marshall.AbstractMarshaller;
import org.jboss.cache.marshall.VersionAwareMarshaller;
import org.jboss.cache.transaction.DummyTransactionManager;
Modified: core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -255,80 +255,8 @@
}
}
- public void testRemoteInvalidStateInvocations() throws Exception
- {
- createAndRegisterCache(Configuration.CacheMode.REPL_SYNC, true);
- createAndRegisterCache(Configuration.CacheMode.REPL_SYNC, true);
- try
- {
- // now DIRECTLY change the status of c2.
- // emulate the race condition where the remote cache is stopping but hasn't
disconnected from the channel.
- ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(c[1]);
- cr1.state = CacheStatus.STOPPING;
- // Thanks to JBCACHE-1179, this should only log a warning and not throw an
exception
- c[0].put(Fqn.ROOT, "k", "v");
- }
- finally
- {
- // reset c[1] to running so the tearDown method can clean it up
- ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(c[1]);
- cr1.state = CacheStatus.STARTED;
- }
- }
- public void testRemoteInvalidStateInvocations2() throws Exception
- {
- createAndRegisterCache(Configuration.CacheMode.REPL_SYNC, true);
- createAndRegisterCache(Configuration.CacheMode.REPL_SYNC, true);
- TestingUtil.blockUntilViewsReceived(c, 10000);
- try
- {
- // now DIRECTLY change the status of c2.
- // emulate the race condition where the remote cache is stopping but hasn't
disconnected from the channel.
-
- // there is a lousy race condition here - we need to make sure cache[1]'s
start() method doesn't set status to STARTED
- // after we attempt to change this.
- TestingUtil.blockUntilCacheStatusAchieved(c[1], CacheStatus.STARTED, 1000);
- ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(c[1]);
- cr1.state = CacheStatus.STARTING;
- try
- {
- // This call should wait for up to StateRetrievalTimeout secs or until c[1]
has entered the STARTED state, and then barf.
- c[0].put(Fqn.ROOT, "k", "v");
- fail("Should barf!");
- }
- catch (Exception good)
- {
-
- }
-
- // now kick off another thread to sleep for a few secs and then set c[1] to
STARTED
- final int sleepTime = 500;
- new Thread()
- {
- public void run()
- {
- TestingUtil.sleepThread(sleepTime);
- ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(c[1]);
- cr1.state = CacheStatus.STARTED;
- }
- }.start();
-
- // should succeed but should take at least 1000ms.
- long startTime = System.currentTimeMillis();
- c[0].put(Fqn.ROOT, "k", "v");
- assert System.currentTimeMillis() > (startTime + sleepTime) : "Should
wait till c[1] has STARTED state";
-
- }
- finally
- {
- // reset c[1] to running so the tearDown method can clean it up
- ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(c[1]);
- cr1.state = CacheStatus.STARTED;
- }
- }
-
public void testInvalidStateTxCommit() throws Exception
{
createAndRegisterCache(Configuration.CacheMode.LOCAL, true);
@@ -350,63 +278,6 @@
}
}
- public void testStopInstanceWhileOtherInstanceSends() throws Exception
- {
- final Fqn fqn = Fqn.fromString("/a");
- final List<Boolean> running = new LinkedList<Boolean>();
- final List<Exception> exceptions = new LinkedList<Exception>();
- running.add(true);
-
- createAndRegisterCache(Configuration.CacheMode.REPL_SYNC, true);
- createAndRegisterCache(Configuration.CacheMode.REPL_SYNC, true);
-
- c[0].put(fqn, "k", "v");
-
- assert "v".equals(c[0].get(fqn, "k"));
- assert "v".equals(c[1].get(fqn, "k"));
-
- // now kick start a thread on c[1] that will constantly update the fqn
-
- Thread updater = new Thread()
- {
- public void run()
- {
- int i = 0;
- while (running.get(0))
- {
- try
- {
- i++;
- if (running.get(0)) c[1].put(fqn, "k", "v" + i);
- }
- catch (ReplicationException re)
- {
- // this sometimes happens when JGroups suspects the remote node. This
is ok, as long as we don't get an ISE.
- }
- catch (SuspectException se)
- {
- // this sometimes happens when JGroups suspects the remote node. This
is ok, as long as we don't get an ISE.
- }
- catch (Exception e)
- {
- exceptions.add(e);
- }
- TestingUtil.sleepThread(20);
-
- }
- }
- };
-
- updater.start();
-
- c[0].stop();
- running.add(false);
- running.remove(true);
- updater.join();
-
- for (Exception e : exceptions) throw e;
- }
-
public void testInvalidStateTxRollback() throws Exception
{
createAndRegisterCache(Configuration.CacheMode.LOCAL, true);
Added: core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleWithReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleWithReplTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleWithReplTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -0,0 +1,159 @@
+package org.jboss.cache.factories;
+
+import org.jboss.cache.*;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.util.TestingUtil;
+import static org.testng.AssertJUnit.fail;
+import org.testng.annotations.Test;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+@Test(groups = {"functional"}, testName =
"factories.LifeCycleWithReplTest")
+public class LifeCycleWithReplTest extends AbstractMultipleCachesTest
+{
+
+ private CacheSPI<Object, Object> first;
+ private CacheSPI<Object, Object> second;
+
+ protected void createCaches() throws Throwable
+ {
+ first = createCache(Configuration.CacheMode.REPL_SYNC);
+ second = createCache(Configuration.CacheMode.REPL_SYNC);
+ TestingUtil.blockUntilViewReceived(first, 2, 10000);
+ registerCaches(first, second);
+ }
+
+ public void testRemoteInvalidStateInvocations() throws Exception
+ {
+ try
+ {
+ // now DIRECTLY change the status of c2.
+ // emulate the race condition where the remote cache is stopping but hasn't
disconnected from the channel.
+ ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(second);
+ cr1.state = CacheStatus.STOPPING;
+
+ // Thanks to JBCACHE-1179, this should only log a warning and not throw an
exception
+ first.put(Fqn.ROOT, "k", "v");
+ }
+ finally
+ {
+ ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(second);
+ cr1.state = CacheStatus.STARTED;
+ }
+ }
+
+ public void testStopInstanceWhileOtherInstanceSends() throws Exception
+ {
+ final Fqn fqn = Fqn.fromString("/a");
+ final List<Boolean> running = new LinkedList<Boolean>();
+ final List<Exception> exceptions = new LinkedList<Exception>();
+ running.add(true);
+
+ first.put(fqn, "k", "v");
+
+ assert "v".equals(first.get(fqn, "k"));
+ assert "v".equals(second.get(fqn, "k"));
+
+ // now kick start a thread on second that will constantly update the fqn
+
+ Thread updater = new Thread()
+ {
+ public void run()
+ {
+ int i = 0;
+ while (running.get(0))
+ {
+ try
+ {
+ i++;
+ if (running.get(0)) second.put(fqn, "k", "v" + i);
+ }
+ catch (ReplicationException re)
+ {
+ // this sometimes happens when JGroups suspects the remote node. This
is ok, as long as we don't get an ISE.
+ }
+ catch (SuspectException se)
+ {
+ // this sometimes happens when JGroups suspects the remote node. This
is ok, as long as we don't get an ISE.
+ }
+ catch (Exception e)
+ {
+ exceptions.add(e);
+ }
+ TestingUtil.sleepThread(20);
+
+ }
+ }
+ };
+
+ updater.start();
+
+ first.stop();
+ running.add(false);
+ running.remove(true);
+ updater.join();
+
+ for (Exception e : exceptions) throw e;
+ }
+
+ public void testRemoteInvalidStateInvocations2() throws Exception
+ {
+ try
+ {
+ // now DIRECTLY change the status of second.
+ // emulate the race condition where the remote cache is stopping but hasn't
disconnected from the channel.
+ // there is a lousy race condition here - we need to make sure seconds's
start() method doesn't set status to STARTED
+ // after we attempt to change this.
+ ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(second);
+ cr1.state = CacheStatus.STARTING;
+ try
+ {
+ // This call should wait for up to StateRetrievalTimeout secs or until second
has entered the STARTED state, and then barf.
+ first.put(Fqn.ROOT, "k", "v");
+ fail("Should barf!");
+ }
+ catch (Exception good)
+ {
+ }
+
+ // now kick off another thread to sleep for a few secs and then set second to
STARTED
+ final int sleepTime = 500;
+ new Thread()
+ {
+ public void run()
+ {
+ TestingUtil.sleepThread(sleepTime);
+ ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(second);
+ cr1.state = CacheStatus.STARTED;
+ }
+ }.start();
+
+ // should succeed but should take at least 1000ms.
+ long startTime = System.currentTimeMillis();
+ first.put(Fqn.ROOT, "k", "v");
+ assert System.currentTimeMillis() > (startTime + sleepTime) : "Should
wait till second has STARTED state";
+ }
+ finally
+ {
+ // reset second to running so the tearDown method can clean it up
+ ComponentRegistry cr1 = TestingUtil.extractComponentRegistry(second);
+ cr1.state = CacheStatus.STARTED;
+ }
+ }
+
+
+
+ private CacheSPI<Object, Object> createCache(Configuration.CacheMode cacheMode)
+ {
+ Configuration c = new Configuration();
+ c.setCacheMode(cacheMode);
+
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ CacheSPI<Object, Object> retval = (CacheSPI<Object, Object>) new
UnitTestCacheFactory<Object, Object>().createCache(c, false, getClass());
+ retval.start();
+ return retval;
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/CacheLoaderInvalidationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/invalidation/CacheLoaderInvalidationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/invalidation/CacheLoaderInvalidationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -158,7 +158,7 @@
static CacheLoaderConfig getCacheLoaderConfig(Class requestor) throws Exception
{
return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"",
- "org.jboss.cache.loader.DummySharedInMemoryCacheLoader",
"bin=" + requestor , false, false, false, false, false);
+
"org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader",
"bin=" + requestor , false, false, false, false, false);
}
static void assertHasBeenInvalidated(Node n, String message)
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/PessWithCacheLoaderInvalidationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/invalidation/PessWithCacheLoaderInvalidationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/invalidation/PessWithCacheLoaderInvalidationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -4,8 +4,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.AbstractMultipleCachesTest;
-import org.jboss.cache.loader.DummyInMemoryCacheLoaderPessimisticTest;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.config.Configuration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
Deleted: core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.loader;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.testng.annotations.Test;
-
-import java.util.Properties;
-
-/**
- * Very basic test case that provides methods to create a cache loader config.
- *
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
- */
-
-@Test(groups = "functional")
-public abstract class AbstractCacheLoaderTestBase
-{
- protected final Log log = LogFactory.getLog(getClass());
-
- @Deprecated
- protected CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String
cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean
shared) throws Exception
- {
- return getSingleCacheLoaderConfig(preload, cacheloaderClass, properties, async,
fetchPersistentState, shared, false);
- }
-
- @Deprecated
- protected CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String
cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean
shared, boolean purgeOnStartup) throws Exception
- {
- return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
preload, cacheloaderClass,
- properties, async, fetchPersistentState, shared, purgeOnStartup, false);
- }
-
- protected CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String
cacheloaderClass, Properties properties, boolean async, boolean fetchPersistentState,
boolean shared) throws Exception
- {
- return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
preload, cacheloaderClass, properties, async, fetchPersistentState, shared, false,
false);
- }
-}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -20,6 +20,7 @@
import java.util.Properties;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.AbstractMultipleCachesTest;
/**
* Tests the compatibility between <tt>JDBCCacheLoader</tt> and
<tt>JDBCCacheLoaderOld</tt>. More exactly,
@@ -31,7 +32,7 @@
*/
@Test(groups = {"functional"}, testName =
"loader.AdjListJDBCCacheLoaderCompatibilityTest")
@SuppressWarnings("deprecation")
-public class AdjListJDBCCacheLoaderCompatibilityTest
+public class AdjListJDBCCacheLoaderCompatibilityTest extends AbstractMultipleCachesTest
{
@SuppressWarnings("deprecation")
@@ -39,57 +40,41 @@
private JDBCCacheLoader newImpl;
private CacheSPI cache, cache2;
-
- private Properties props;
- private long durration;
-
- @BeforeTest
- public void createDatabase()
+ protected void createCaches() throws Throwable
{
- durration = System.currentTimeMillis();
- props = TestDbPropertiesFactory.getTestDbProperties();
- }
-
- @AfterTest
- public void shutDownDatabase()
- {
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
- }
-
- /**
- * Note : newImpl is not started here but in each individual test. That's because
on start it performs
- * some backward compatibility logic.
- *
- * @see JDBCCacheLoader#start()
- */
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
newImpl = getNewCacheLoader((Properties) props.clone());
oldImpl = getOldLoader((Properties) props.clone());
cache = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(getClass());
cache2 = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(getClass());
newImpl.setCache(cache);//this is needed for marshaller
oldImpl.setCache(cache2);
+ registerCaches(cache, cache2);
oldImpl.start();
- oldImpl.remove(Fqn.ROOT);
+ newImpl.start();
}
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
+ @BeforeMethod
+ public void beforeMethod() throws Exception
{
oldImpl.remove(Fqn.ROOT);
- oldImpl.stop();
- newImpl.stop();
+ }
- TestingUtil.killCaches(cache, cache2);
- cache = null;
- cache2 = null;
+ private Properties props;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ props = TestDbPropertiesFactory.getTestDbProperties();
}
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ }
+
public void testCommonOperations() throws Exception
{
- newImpl.start();
oldImpl.put(Fqn.fromString("/a/b/c"), "key1",
"value1");
oldImpl.put(Fqn.fromString("/a/b/d"), "key2",
"value2");
oldImpl.put(Fqn.fromString("/a/b/e"), "key3",
"value3");
@@ -113,7 +98,7 @@
assertTrue(newImpl.exists(Fqn.fromString("/a/b/c")));
assertTrue(newImpl.exists(Fqn.fromString("/a/b/d")));
assertTrue(newImpl.exists(Fqn.fromString("/a/b/e")));
- newImpl.start();
+
newImpl.remove(Fqn.fromString("/a/b"));
assertFalse(newImpl.exists(Fqn.fromString("/a/b/c")));
assertFalse(newImpl.exists(Fqn.fromString("/a/b/d")));
@@ -197,7 +182,7 @@
oldImpl.put(Fqn.fromString("/a/b/e"), "key3",
"value3");
oldImpl.put(Fqn.fromString("/a/f/e"), "key4",
"value4");
oldImpl.put(Fqn.ROOT, "root_key", "root_value");
- newImpl.start();
+
ArrayList<NodeData> oldList = new ArrayList<NodeData>();
oldImpl.getNodeDataList(Fqn.ROOT, oldList);
ArrayList<NodeData> newList = new ArrayList<NodeData>();
@@ -222,7 +207,7 @@
{
return TestDbPropertiesFactory.getTestDbProperties();
}
-
+
private JDBCCacheLoader getNewCacheLoader(Properties prop) throws Exception
{
String tablePkPrefix = prop.getProperty("cache.jdbc.table.primarykey",
"jbosscache_pk");
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -18,10 +18,11 @@
import java.util.Collections;
import java.util.HashMap;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
@Test(groups = "functional", sequential = true, testName =
"loader.AsyncFileCacheLoaderTest")
-public class AsyncFileCacheLoaderTest extends AbstractCacheLoaderTestBase
+public class AsyncFileCacheLoaderTest
{
private CacheSPI<Object, Object> cache;
@@ -34,8 +35,8 @@
{
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false, getClass());
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- // cache.setCacheLoaderConfiguration(buildSingleCacheLoaderConfig("",
"org.jboss.cache.loader.jdbm.JdbmCacheLoader",
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.FileCacheLoader", props, true, false, true));
+ cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory
+ .buildSingleCacheLoaderConfig(false, "",
"org.jboss.cache.loader.FileCacheLoader", props, true, false, true, false,
false));
cache.create();
cache.start();
}
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-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -2,9 +2,11 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
/**
* Runs the same tests as {@link FileCacheLoaderTest}, but with Berkeley DB instead of a
file-based CacheLoader
@@ -17,16 +19,23 @@
{
@Override
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
String tmpDir = TestingUtil.TEST_FILES;
String tmpCLLoc = tmpDir + "/JBossCache-BdbjeCacheLoaderTest";
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" +
tmpCLLoc, false, true, false));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader",
+ "location=" + tmpCLLoc, false, true, false, false, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
+ @BeforeMethod
+ public void clearDatabase() throws Exception
+ {
+ loader.remove(Fqn.ROOT);
+ }
+
public void testTransaction() throws Exception
{
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-12-15 14:33:25 UTC
(rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-12-16 13:44:26 UTC
(rev 7332)
@@ -41,7 +41,6 @@
@Test(groups = {"functional"}, testName = "loader.BdbjeTest")
public class BdbjeTest
{
-
private static final int STREAM_HEADER_LENGTH = 4;
private static final String envHome = ".";
private static final Fqn FQN = Fqn.fromString("/key");
@@ -660,8 +659,7 @@
/**
* Tests a two-phase transaction.
*/
- public void testTwoPhaseTransaction()
- throws Exception
+ public void testTwoPhaseTransaction() throws Exception
{
startLoader(true, null);
@@ -669,14 +667,7 @@
Object txnKey = new Object();
List<Modification> mods = createUpdates();
loader.prepare(txnKey, mods, false);
- try
- {
- checkModifications(mods);
- fail("Expected lock timeout");
- }
- catch (DeadlockException expected)
- {
- }
+ long start = System.currentTimeMillis();
loader.commit(txnKey);
checkModifications(mods);
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -27,12 +27,10 @@
private AdjListJDBCCacheLoaderConfig config;
private Properties props;
- private long durration;
@BeforeTest
public void createDatabase()
{
- durration = System.currentTimeMillis();
props = TestDbPropertiesFactory.getTestDbProperties();
}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -6,13 +6,10 @@
*/
package org.jboss.cache.loader;
-import java.util.Properties;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
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
@@ -32,8 +29,8 @@
props.put("cache.jdbc.connection.factory", CF_CLASS);
}
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true,
false, false, false));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -25,7 +25,7 @@
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
@Test(groups = "functional", sequential = true, testName =
"loader.CacheLoaderManagerTest")
-public class CacheLoaderManagerTest extends AbstractCacheLoaderTestBase
+public class CacheLoaderManagerTest
{
private LoadersElementParser loadersElementParser = new LoadersElementParser();
@@ -113,7 +113,8 @@
public void testSingleCacheLoaderFromXml() throws Exception
{
// without async
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.FileCacheLoader", "location=" + getTempDir(),
false, false, false);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
"org.jboss.cache.loader.FileCacheLoader",
+ "location=" + getTempDir(), false, false, false, false, false);
CacheLoaderManager mgr = new CacheLoaderManager();
mgr.setConfig(clc, null, null);
@@ -122,7 +123,8 @@
assertEquals(FileCacheLoader.class, cl.getClass());
// with async
- clc = getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.FileCacheLoader", "location=" + getTempDir(),
true, false, false);
+ clc = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.FileCacheLoader",
+ "location=" + getTempDir(), true, false, false, false, false);
mgr.setConfig(clc, null, null);
cl = mgr.getCacheLoader();
@@ -292,7 +294,7 @@
conf =
"<loaders passivation=\"false\">\n" +
" <preload/>\n" +
- " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader\">"
+
" <singletonStore enabled=\"true\"/>\n"
+
" </loader>" +
"</loaders>";
@@ -315,7 +317,7 @@
conf =
"<loaders passivation=\"false\">\n" +
" <preload/>\n" +
- " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader\">"
+
" <singletonStore enabled=\"true\"
class=\"org.jboss.cache.loader.CacheLoaderManagerTest$MockSingletonStoreCacheLoader\"
/>\n" +
" </loader>" +
"</loaders>";
@@ -336,7 +338,7 @@
conf =
" <loaders passivation=\"true\">\n" +
" <preload/>\n" +
- " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader\">\n"
+
" <singletonStore
enabled=\"true\">\n" +
" <properties>\n" +
" pushStateWhenCoordinator=false\n" +
@@ -361,7 +363,7 @@
conf =
" <loaders passivation=\"true\">\n" +
" <preload/>\n" +
- " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader\">\n"
+
" <singletonStore
enabled=\"true\">\n" +
" <properties>\n" +
" pushStateWhenCoordinator = true\n" +
@@ -387,7 +389,7 @@
conf =
" <loaders passivation=\"false\"
shared=\"true\">\n" +
" <preload/>\n" +
- " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader\">\n"
+
" <singletonStore
enabled=\"true\">\n" +
" <properties>\n" +
" pushStateWhenCoordinator = true\n" +
@@ -412,8 +414,8 @@
conf =
" <loaders passivation=\"true\">\n" +
" <preload/>\n" +
- " <loader
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
- " <singletonStore enabled=\"true\"
class=\"org.jboss.cache.loader.DummyInMemoryCacheLoader\">\n" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader\">\n"
+
+ " <singletonStore enabled=\"true\"
class=\"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader\">\n"
+
" </singletonStore>\n" +
" </loader>\n" +
" </loaders>";
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -8,6 +8,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummyCountingCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
@@ -21,7 +23,7 @@
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
*/
@Test(groups = "functional", sequential = true, testName =
"loader.CacheLoaderMethodCallCounterTest")
-public class CacheLoaderMethodCallCounterTest extends AbstractCacheLoaderTestBase
+public class CacheLoaderMethodCallCounterTest
{
private CacheSPI cache;
private DummyCountingCacheLoader dummyLoader;
@@ -32,7 +34,8 @@
if (cache != null) tearDown();
cache = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(false, getClass());
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyCountingCacheLoader.class.getName(), "", false, false, false));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyCountingCacheLoader.class.getName(),
+ "", false, false, false, false, false));
cache.start();
dummyLoader = (DummyCountingCacheLoader)
cache.getCacheLoaderManager().getCacheLoader();
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -10,6 +10,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.parsing.XmlConfigHelper;
@@ -23,7 +25,7 @@
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
*/
@Test(groups = {"functional"}, sequential = true, testName =
"loader.CacheLoaderPurgingTest")
-public class CacheLoaderPurgingTest extends AbstractCacheLoaderTestBase
+public class CacheLoaderPurgingTest
{
private CacheSPI<Object, Object> cache;
private String key = "key", value = "value";
@@ -46,7 +48,8 @@
Configuration c = cache.getConfiguration();
String s = "bin=" + getClass().getName();
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), s, false, false, false));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummySharedInMemoryCacheLoader.class.getName(),
+ s, false, false, false, false, false));
cache.start();
cache.put(fqn, key, value);
@@ -70,7 +73,8 @@
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false, getClass());
Configuration c = cache.getConfiguration();
String s = "bin=" + getClass().getName();
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), s, false, false, false, true));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummySharedInMemoryCacheLoader.class.getName(),
+ s, false, false, false, true, false));
cache.start();
cache.put(fqn, key, value);
@@ -97,11 +101,11 @@
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false, getClass());
String xml =
" <loaders passivation=\"false\">\n" +
- " <loader
class=\"org.jboss.cache.loader.DummySharedInMemoryCacheLoader\"
fetchPersistentState=\"true\"\n" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader\"
fetchPersistentState=\"true\"\n" +
"
purgeOnStartup=\"true\">\n" +
" <properties>bin=" + getClass() +
"bin1</properties>\n" +
" </loader>" +
- " <loader
class=\"org.jboss.cache.loader.DummySharedInMemoryCacheLoader\"
fetchPersistentState=\"false\"\n" +
+ " <loader
class=\"org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader\"
fetchPersistentState=\"false\"\n" +
"
purgeOnStartup=\"false\">\n" +
" <properties>bin=" + getClass()+
"bin2</properties>\n" +
" </loader>" +
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-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -3,8 +3,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.util.TestingUtil;
@@ -12,8 +14,8 @@
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -31,7 +33,7 @@
* @version $Id$
*/
@Test(groups = {"functional"})
-abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
+abstract public class CacheLoaderTestsBase extends AbstractSingleCacheTest
{
static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
@@ -43,38 +45,49 @@
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
- public void setUp() throws Exception
+
+ protected CacheSPI createCache() throws Exception
{
- cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(false, getClass());
- Configuration c = cache.getConfiguration();
- c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- configureCache();
+ cache = createUnstartedCache();
cache.start();
loader = cache.getCacheLoaderManager().getCacheLoader();
postConfigure();
+ return cache;
}
- protected void postConfigure()
+ private CacheSPI<Object, Object> createUnstartedCache() throws Exception
{
- // no op. Subclass if you need any further cfg after the cache starts.
+ CacheSPI<Object, Object> result = (CacheSPI<Object, Object>) new
UnitTestCacheFactory<Object, Object>().createCache(false, getClass());
+ Configuration c = result.getConfiguration();
+ c.setCacheMode(Configuration.CacheMode.LOCAL);
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ configureCache(result);
+ return result;
}
- abstract protected void configureCache() throws Exception;
+ @BeforeMethod
+ public void clearLoader() throws Exception
+ {
+ loader.remove(Fqn.ROOT);
+ }
+ /**
+ * Subclass if you need any further cfg after the cache starts.
+ */
+ protected void postConfigure() { }
+
+ abstract protected void configureCache(CacheSPI cache) throws Exception;
+
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
cleanup();
//if (loader != null) loader.remove(Fqn.ROOT);
- TestingUtil.killCaches(cache);
}
- protected void cleanup()
+ protected void cleanup() throws Exception
{
// to be overridden
}
@@ -757,7 +770,6 @@
public void testGetChildren12()
{
-
Set children;
cache.put("/a/b", "key", "val");
cache.put("/a/b/1", "key", "val");
@@ -866,7 +878,6 @@
public void testRemoveData3()
{
-
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -2050,8 +2061,6 @@
public void testPutAllAfterEvictWithChild() throws Exception
{
-
-
Fqn fqn = Fqn.fromString("/a/b");
Map<String, String> original = new HashMap<String, String>();
Map<String, String> toAdd = new HashMap<String, String>();
@@ -2194,32 +2203,34 @@
// Some loaders cannot deal with being called when outside of a running cache.
assert "v".equals(loader.get(fqn).get("k"));
- // now stop the cache
- cache.stop();
- cache.destroy();
+// // now stop the cache
+// cache.stop();
+// cache.destroy();
- assert cache.getCacheLoaderManager() == null : "Should nullify cache loader
manager in the cache";
+// assert cache.getCacheLoaderManager() == null : "Should nullify cache loader
manager in the cache";
-
cache.getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs().get(0).setIgnoreModifications(true);
- cache.start();
- loader = cache.getCacheLoaderManager().getCacheLoader();
+ CacheSPI<Object, Object> secondCache = createUnstartedCache();
+
secondCache.getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs().get(0).setIgnoreModifications(true);
+ secondCache.start();
+ CacheLoader secondLoader = secondCache.getCacheLoaderManager().getCacheLoader();
postConfigure();
// CCL uses it's own mechanisms to ensure read-only behaviour
- if (!(loader instanceof ChainingCacheLoader))
+ if (!(secondLoader instanceof ChainingCacheLoader))
{
// test that the cache loader is wrapped by a read-only delegate
- assert loader instanceof ReadOnlyDelegatingCacheLoader;
+ assert secondLoader instanceof ReadOnlyDelegatingCacheLoader;
}
// old state should be persisted.
- assert "v".equals(loader.get(fqn).get("k"));
- assert "v".equals(cache.get(fqn, "k"));
+ assert "v".equals(secondLoader.get(fqn).get("k"));
+ assert "v".equals(secondCache.get(fqn, "k"));
// the loader should now be read-only
- cache.put(fqn, "k", "v2");
- assert "v2".equals(cache.get(fqn, "k"));
+ secondCache.put(fqn, "k", "v2");
+ assert "v2".equals(secondCache.get(fqn, "k"));
assert "v".equals(loader.get(fqn).get("k"));
+ TestingUtil.killCaches(secondCache);
}
public void testCacheLoaderThreadSafety() throws Exception
@@ -2232,6 +2243,7 @@
threadSafetyTest(false);
}
+ //todo mmarkus add a parameter here to user grater values for different mvn profiles
protected void threadSafetyTest(final boolean singleFqn) throws Exception
{
final CountDownLatch latch = new CountDownLatch(1);
@@ -2250,7 +2262,7 @@
{
loader.put(fqn, "k", "v");
}
- final int loops = 1000;
+ final int loops = 100;
final Set<Exception> exceptions = new
CopyOnWriteArraySet<Exception>();
Thread remover1 = new Thread("Remover-1")
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -10,6 +10,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -30,7 +32,7 @@
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
*/
@Test(groups = "functional", sequential = true, testName =
"loader.CacheLoaderWithReplicationTest")
-public class CacheLoaderWithReplicationTest extends AbstractCacheLoaderTestBase
+public class CacheLoaderWithReplicationTest
{
private Cache<Object, Object> cache1, cache2;
private Fqn fqn = Fqn.fromString("/a");
@@ -43,11 +45,13 @@
public void setUp() throws Exception
{
cache1 = new UnitTestCacheFactory<Object, Object>().createCache(false,
getClass());
-
cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyInMemoryCacheLoader.class.getName(), "debug=true", false, true, false));
+
cache1.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyInMemoryCacheLoader.class.getName(),
+ "debug=true", false, true, false, false, false));
cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache2 = new UnitTestCacheFactory<Object, Object>().createCache(false,
getClass());
-
cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyInMemoryCacheLoader.class.getName(), "debug=true", false, true, false));
+
cache2.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyInMemoryCacheLoader.class.getName(),
+ "debug=true", false, true, false, false, false));
cache2.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
loader1 = loader2 = null;
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -7,6 +7,7 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
@@ -34,7 +35,7 @@
if (!dir2.exists()) dir2.mkdirs();
}
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(loc1, loc2));
TestingUtil.recursiveFileRemove(loc1);
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -9,6 +9,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -8,10 +8,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Region;
-import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.*;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.lock.TimeoutException;
@@ -35,7 +33,7 @@
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
*/
@Test(groups = {"functional"}, sequential = true, testName =
"loader.ClusteredCacheLoaderTest")
-public class ClusteredCacheLoaderTest extends AbstractCacheLoaderTestBase
+public class ClusteredCacheLoaderTest extends AbstractMultipleCachesTest
{
private static Log log = LogFactory.getLog(ClusteredCacheLoaderTest.class);
private CacheSPI<Object, Object> cache1, cache2;
@@ -46,11 +44,8 @@
protected boolean useRegionBasedMarshalling = false;
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
+ protected void createCaches() throws Throwable
{
- if (cache1 != null || cache2 != null) tearDown();
-
Configuration c1 = new Configuration();
Configuration c2 = new Configuration();
c1.setStateRetrievalTimeout(2000);
@@ -58,8 +53,10 @@
c1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
c2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- c1.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false,
false, false));
- c2.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false,
false, false));
+
c1.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.ClusteredCacheLoader",
+ "timeout=5000", false, false, false, false, false));
+
c2.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.ClusteredCacheLoader",
+ "timeout=5000", false, false, false, false, false));
c1.setUseRegionBasedMarshalling(useRegionBasedMarshalling);
c2.setUseRegionBasedMarshalling(useRegionBasedMarshalling);
@@ -85,26 +82,9 @@
loader1 = cache1.getCacheLoaderManager().getCacheLoader();
loader2 = cache2.getCacheLoaderManager().getCacheLoader();
+ registerCaches(cache1, cache2);
}
- @AfterMethod(alwaysRun = true)
- public void tearDown()
- {
- if (cache1 != null)
- {
- TestingUtil.killCaches(cache1);
- cache1 = null;
- loader1 = null;
- }
-
- if (cache2 != null)
- {
- TestingUtil.killCaches(cache2);
- cache2 = null;
- loader2 = null;
- }
- }
-
public void testGetKeyValue() throws Exception
{
cache1.put(fqn, key, "value");
@@ -224,6 +204,7 @@
assertTrue("should exist", loader2.exists(fqn));
}
+ //todo - mmarkus - extract these as testng.xml configs withe different values for
different environements (for this test e.g. number of loops)
public void testCacheLoaderThreadSafety() throws Throwable
{
threadSafetyTest(true);
@@ -255,7 +236,7 @@
cache2.put(fqn, "k", "v");
cache1.evict(fqn);
}
- final int loops = 300; // was 1000
+ final int loops = 25; // was 300
final Set<Exception> exceptions = new
CopyOnWriteArraySet<Exception>();
Thread evictor = new Thread("Evictor")
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -3,6 +3,8 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.util.TestingUtil;
@@ -23,7 +25,7 @@
*/
@Test(groups = "functional", enabled = false, testName =
"loader.ConcurrentPutRemoveEvictTest")
// TODO: 2.2.0: Figure out why this occasionally hangs!!
-public class ConcurrentPutRemoveEvictTest extends AbstractCacheLoaderTestBase
+public class ConcurrentPutRemoveEvictTest
{
Cache<String, String> cache;
Fqn fqn = Fqn.fromString("/a");
@@ -34,7 +36,8 @@
@BeforeTest
public void setUp() throws Exception
{
- CacheLoaderConfig cacheLoaderConfig = getSingleCacheLoaderConfig("",
DummyInMemoryCacheLoader.class.getName(), "", false, false, false);
+ CacheLoaderConfig cacheLoaderConfig =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
DummyInMemoryCacheLoader.class.getName(),
+ "", false, false, false, false, false);
Configuration cfg = new Configuration();
cfg.setCacheLoaderConfig(cacheLoaderConfig);
cache = new UnitTestCacheFactory<String, String>().createCache(cfg,
getClass());
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -26,11 +26,12 @@
import java.util.Properties;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.TestDbPropertiesFactory;
@Test(groups = "functional", sequential = true, testName =
"loader.DataSourceIntegrationTest")
-public class DataSourceIntegrationTest extends AbstractCacheLoaderTestBase
+public class DataSourceIntegrationTest
{
//private String old_factory = null;
private final String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
@@ -52,7 +53,7 @@
props.put("cache.jdbc.datasource", JNDI_NAME);
props.put("cache.jdbc.table.create", true);
props.put("cache.jdbc.table.drop", true);
- return getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, false, false);
+ return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.JDBCCacheLoader", props, false, false,
false, false, false);
}
/**
Deleted: core/trunk/src/test/java/org/jboss/cache/loader/DummyCountingCacheLoader.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DummyCountingCacheLoader.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyCountingCacheLoader.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,224 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.loader;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Dummy cache loader that captures the number of times each method is called. Stores
statistics statically, mimicking
- * a shared cache loader.
- *
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
- */
-public class DummyCountingCacheLoader extends AbstractCacheLoader
-{
- private static int getChildrenNamesCount = 0, getCount = 0, putCount = 0, existsCount
= 0, removeCount = 0;
-
- public int getGetChildrenNamesCount()
- {
- return getChildrenNamesCount;
- }
-
- public int getGetCount()
- {
- return getCount;
- }
-
- public int getPutCount()
- {
- return putCount;
- }
-
- public int getExistsCount()
- {
- return existsCount;
- }
-
- public int getRemoveCount()
- {
- return removeCount;
- }
-
-
- /**
- * Sets the configuration. Will be called before {@link #create()} and {@link
#start()}
- */
- public void setConfig(IndividualCacheLoaderConfig config)
- {
- }
-
- public IndividualCacheLoaderConfig getConfig()
- {
- return null;
- }
-
- /**
- * Returns a list of children names, all names are <em>relative</em>.
Returns null if the parent node is not found.
- * The returned set must not be modified, e.g. use Collections.unmodifiableSet(s) to
return the result
- *
- * @param fqn The FQN of the parent
- * @return Set<String>. A list of children. Returns null if no children nodes
are present, or the parent is
- * not present
- */
- public Set<String> getChildrenNames(Fqn fqn) throws Exception
- {
- getChildrenNamesCount++;
- return null;
- }
-
- /**
- * Returns the value for a given key. Returns null if the node doesn't exist, or
the value is not bound
- *
- * @param name
- * @return
- * @throws Exception
- */
- public Object get(Fqn name, Object key) throws Exception
- {
- getCount++;
- return null;
- }
-
- /**
- * Returns all keys and values from the persistent store, given a fully qualified
name
- *
- * @param name
- * @return Map<Object,Object> of keys and values for the given node. Returns
null if the node was not found, or
- * if the node has no attributes
- * @throws Exception
- */
- public Map<Object, Object> get(Fqn name) throws Exception
- {
- getCount++;
- return null;
- }
-
- /**
- * Checks whether the CacheLoader has a node with Fqn
- *
- * @param name
- * @return True if node exists, false otherwise
- */
- public boolean exists(Fqn name) throws Exception
- {
- existsCount++;
- return false;
- }
-
- /**
- * Inserts key and value into the attributes hashmap of the given node. If the node
does not exist, all
- * parent nodes from the root down are created automatically. Returns the old value
- */
- public Object put(Fqn name, Object key, Object value) throws Exception
- {
- putCount++;
- return null;
- }
-
- /**
- * Inserts all elements of attributes into the attributes hashmap of the given node,
overwriting existing
- * attributes, but not clearing the existing hashmap before insertion (making it a
union of existing and
- * new attributes)
- * If the node does not exist, all parent nodes from the root down are created
automatically
- *
- * @param name The fully qualified name of the node
- * @param attributes A Map of attributes. Can be null
- */
- public void put(Fqn name, Map attributes) throws Exception
- {
- putCount++;
- }
-
- /**
- * Inserts all modifications to the backend store. Overwrite whatever is already in
- * the datastore.
- *
- * @param modifications A List<Modification> of modifications
- * @throws Exception
- */
- public void put(List<Modification> modifications) throws Exception
- {
- putCount++;
- }
-
- /**
- * Removes the given key and value from the attributes of the given node. No-op if
node doesn't exist
- */
- public Object remove(Fqn name, Object key) throws Exception
- {
- removeCount++;
- return null;
- }
-
- /**
- * Removes the given node. If the node is the root of a subtree, this will recursively
remove all subnodes,
- * depth-first
- */
- public void remove(Fqn name) throws Exception
- {
- removeCount++;
- }
-
- /**
- * Removes all attributes from a given node, but doesn't delete the node itself
- *
- * @param name
- * @throws Exception
- */
- public void removeData(Fqn name) throws Exception
- {
- removeCount++;
- }
-
- @Override
- public void loadEntireState(ObjectOutputStream os) throws Exception
- {
- //intentional no-op
- }
-
- @Override
- public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
- {
- // intentional no-op
- }
-
- @Override
- public void storeEntireState(ObjectInputStream is) throws Exception
- {
- // intentional no-op
- }
-
- @Override
- public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
- {
- // intentional no-op
- }
-
-
- @Override
- public void destroy()
- {
- getChildrenNamesCount = 0;
- getCount = 0;
- putCount = 0;
- existsCount = 0;
- removeCount = 0;
- }
-
- public void scrubStats()
- {
- destroy();
- }
-}
\ No newline at end of file
Deleted: core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,293 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.loader;
-
-import net.jcip.annotations.ThreadSafe;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Dummy cache loader that stores data in memory
- *
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
- */
-@ThreadSafe
-public class DummyInMemoryCacheLoader extends AbstractCacheLoader
-{
-
- private static Log log = LogFactory.getLog(DummyInMemoryCacheLoader.class);
- // Do NOT access this map directly. always use getNodesMap() since it may be
overridden.
- protected Map<Fqn, DummyNode> nodes = new ConcurrentHashMap<Fqn,
DummyNode>();
- protected Map<Object, List<Modification>> transactions = new
ConcurrentHashMap<Object, List<Modification>>();
- protected boolean debug; // whether to dump System.out messages as well as log
messages or not
- protected final Object NULL = new Object()
- {
- @Override
- public String toString()
- {
- return "NULL placeholder";
- }
- };
- protected IndividualCacheLoaderConfig config;
-
- public void setConfig(IndividualCacheLoaderConfig config)
- {
- this.config = config;
- if (config != null && config.getProperties() != null)
- {
- debug =
Boolean.parseBoolean(config.getProperties().getProperty("debug",
"false"));
- }
- }
-
- public IndividualCacheLoaderConfig getConfig()
- {
- return config;
- }
-
- public Set<?> getChildrenNames(Fqn fqn) throws Exception
- {
- if (log.isDebugEnabled()) log.debug("Calling getChildrenNames on Fqn " +
fqn + ". Data map = " + getNodesMap());
- debugMessage("Calling getChildrenNames on Fqn " + fqn + ". Data map
= " + getNodesMap());
- if (!getNodesMap().containsKey(fqn))
- {
- log.debug("node not in loader");
- debugMessage("node not in loader");
- return null;
- }
-
- Set children = findChildren(fqn);
- log.debug("Fqn " + fqn + " has children " + children);
- debugMessage("Fqn " + fqn + " has children " + children);
- // to keep in line with the CacheLoader interface contract for this method.
- return children.size() == 0 ? null : children;
- }
-
- private Set<Object> findChildren(Fqn p)
- {
- Set<Object> c = new HashSet<Object>();
- for (Fqn f : getNodesMap().keySet())
- {
- if (!f.isRoot() && f.getParent().equals(p))
- {
- c.add(f.getLastElement());
- }
- }
- return c;
- }
-
- public Map<Object, Object> get(Fqn name) throws Exception
- {
- DummyNode dn = getNodesMap().get(name);
- Map<Object, Object> d = dn != null ? dn.data : null;
-
- if (log.isDebugEnabled()) log.debug("Getting data for fqn " + name +
" = " + d);
- debugMessage("Getting data for fqn " + name + " = " + d);
- return stripNULLs(d);
- }
-
- private Map<Object, Object> stripNULLs(Map<Object, Object> data)
- {
- if (data == null) return null;
- // otherwise make sure we replace NULL placeholders with nulls.
- Map<Object, Object> d = new HashMap<Object, Object>(data);
- if (d.containsKey(NULL))
- {
- Object v = d.remove(NULL);
- d.put(null, v);
- }
- Set<Object> keys = new HashSet<Object>();
- for (Map.Entry<Object, Object> e : d.entrySet())
- {
- if (e.getValue() == NULL)
- {
- keys.add(e.getKey());
- }
- }
- for (Object k : keys)
- {
- d.put(k, null);
- }
- return d;
- }
-
- private Map<Object, Object> injectNULLs(Map<Object, Object> data)
- {
- if (data == null) return null;
- // otherwise make sure we replace NULL placeholders with nulls.
- Map<Object, Object> d = new HashMap<Object, Object>(data);
- if (d.containsKey(null))
- {
- Object v = d.remove(null);
- d.put(NULL, v);
- }
- Set<Object> keys = new HashSet<Object>();
- for (Map.Entry<?, ?> e : d.entrySet())
- {
- if (e.getValue() == null)
- {
- keys.add(e.getKey());
- }
- }
- for (Object k : keys)
- {
- d.put(k, NULL);
- }
- return d;
- }
-
-
- public boolean exists(Fqn name) throws Exception
- {
- debugMessage("Performing exists() on " + name);
- return getNodesMap().containsKey(name == null ? NULL : name);
- }
-
- public Object put(Fqn name, Object key, Object value) throws Exception
- {
- DummyNode n = getNodesMap().get(name);
- if (n == null)
- {
- n = new DummyNode(name);
- }
- Object k = key == null ? NULL : key;
- Object v = value == null ? NULL : value;
- Object old = n.data.put(k, v);
-
- getNodesMap().put(name, n);
- // we need to make sure parents get put in as well.
- recursivelyPutParentsIfNeeded(name);
- if (log.isDebugEnabled()) log.debug("Did a put on " + name + ", data
is " + n.data);
- debugMessage("Did a put on " + name + ", data is " + n.data);
- return old == NULL ? null : old;
- }
-
- public void put(Fqn name, Map<Object, Object> attributes) throws Exception
- {
- DummyNode n = getNodesMap().get(name);
- if (n == null)
- {
- n = new DummyNode(name);
- }
- n.data.clear(); // emulate cache loaders overwriting any internal data map with new
data map passed in.
- if (attributes != null) n.data.putAll(injectNULLs(attributes));
- getNodesMap().put(name, n);
- // we need to make sure parents get put in as well.
- recursivelyPutParentsIfNeeded(name);
- if (log.isDebugEnabled()) log.debug("Did a put on " + name + ", data
is " + n.data);
- debugMessage("Did a put on " + name + ", data is " + n.data);
- }
-
- private void recursivelyPutParentsIfNeeded(Fqn node)
- {
- Fqn parent = node.getParent();
- if (getNodesMap().containsKey(parent)) return; // nothing to do.
-
- // else put the parent in.
- getNodesMap().put(parent, new DummyNode(parent));
- recursivelyPutParentsIfNeeded(parent);
- }
-
- public Object remove(Fqn fqn, Object key) throws Exception
- {
- log.debug("Removing data from " + fqn);
- debugMessage("Removing data from " + fqn);
- DummyNode n = getNodesMap().get(fqn);
- if (n == null) n = new DummyNode(fqn);
- Object old = n.data.remove(key == null ? NULL : key);
- getNodesMap().put(fqn, n);
- return old == NULL ? null : old;
- }
-
- public void remove(Fqn fqn) throws Exception
- {
- log.debug("Removing fqn " + fqn);
- debugMessage("Removing fqn " + fqn);
- getNodesMap().remove(fqn);
- // remove children.
- recursivelyRemoveChildren(fqn);
- }
-
- private void recursivelyRemoveChildren(Fqn removedParent)
- {
- for (Fqn f : getNodesMap().keySet())
- {
- if (f.getParent().equals(removedParent))
- {
- // remove the child node too
- getNodesMap().remove(f);
- // and it's children. Depth first.
- recursivelyRemoveChildren(f);
- }
- }
- }
-
- public void removeData(Fqn fqn) throws Exception
- {
- log.debug("Removing data from " + fqn);
- debugMessage("Removing data from " + fqn);
- DummyNode n = getNodesMap().get(fqn);
- if (n == null) n = new DummyNode(fqn);
- n.data.clear();
- getNodesMap().put(fqn, n);
- }
-
- public class DummyNode
- {
- Map<Object, Object> data = new ConcurrentHashMap<Object, Object>();
- Fqn fqn;
-
- public DummyNode(Fqn fqn)
- {
- this.fqn = fqn;
- }
-
- @Override
- public String toString()
- {
- return "Node{" +
- "data=" + data +
- ", fqn=" + fqn +
- '}';
- }
- }
-
- @Override
- public String toString()
- {
- return "DummyInMemoryCacheLoader{" +
- "getNodesMap()=" + getNodesMap() +
- '}';
- }
-
- protected void debugMessage(String msg)
- {
- if (log.isTraceEnabled()) log.trace(msg);
- }
-
- /**
- * ALWAYS use this method instead of accessing the node map directly as it may be
overridden.
- */
- protected Map<Fqn, DummyNode> getNodesMap()
- {
- return nodes;
- }
-
- public void wipe()
- {
- nodes.clear();
- }
-}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,22 +1,25 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
/**
- * Odd that we need a test for a test class, but if we intend to use the {@link
DummyInMemoryCacheLoader} as a cache
+ * Odd that we need a test for a test class, but if we intend to use the {@link
org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader} as a cache
* loader stub then we need to make sure it behaves as a valid cache loader.
*/
@Test(groups = {"functional"}, testName =
"loader.DummyInMemoryCacheLoaderPessimisticTest")
public class DummyInMemoryCacheLoaderPessimisticTest extends CacheLoaderTestsBase
{
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
// use the shared variation of the DIMCL so that state is persisted in a static
variable in memory rather than an
// instance one.
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "debug=true \n bin=" +
getClass().getName(), false, true, false);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
DummySharedInMemoryCacheLoader.class.getName(),
+ "debug=true \n bin=" + getClass().getName(), false, true, false,
false, 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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,11 +1,14 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.testng.annotations.Test;
/**
- * Odd that we need a test for a test class, but if we intend to use the {@link
org.jboss.cache.loader.DummyInMemoryCacheLoader} as a cache
+ * Odd that we need a test for a test class, but if we intend to use the {@link
org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader} as a cache
* loader stub then we need to make sure it behaves as a valid cache loader.
*/
@Test(groups = {"functional"}, testName =
"loader.DummyInMemoryCacheLoaderTest")
@@ -14,12 +17,13 @@
DummySharedInMemoryCacheLoader dimCl;
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
// 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);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
DummySharedInMemoryCacheLoader.class.getName(),
+ "bin=" + bin, false, true, false, false, false);
cache.getConfiguration().setCacheLoaderConfig(clc);
}
@@ -37,10 +41,10 @@
}
@Override
- protected void cleanup()
+ protected void cleanup() throws Exception
{
if (dimCl != null) {
- dimCl.wipeBin();
+ dimCl.remove(Fqn.ROOT);
}
}
Deleted:
core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,57 +0,0 @@
-package org.jboss.cache.loader;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * An extension of the {@link org.jboss.cache.loader.DummyInMemoryCacheLoader} that uses
static maps for data, children,
- * etc. so it can be shared across instances, emulating a shared database or filesystem
cache loader.
- * <p/>
- * Since 2.1.0, this dummy cache loader will take an optional parameter, "bin",
which contains the name of the "bin" to use
- * in the static field to store the content. This allows for tests to mimic multiple
shared cache loaders in the same cache.
- *
- * @author <a href="mailto:manik AT jboss DOT org">Manik
Surtani</a>
- * @since 2.0.0
- */
-public class DummySharedInMemoryCacheLoader extends DummyInMemoryCacheLoader
-{
- protected static final Map<String, Map<Fqn, DummyNode>> BINS = new
ConcurrentHashMap<String, Map<Fqn, DummyNode>>();
- private String bin = "_default_bin_";
-
- @Override
- public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig cfg)
- {
- super.setConfig(cfg);
-
- if (config != null && config.getProperties() != null)
- {
- bin = config.getProperties().getProperty("bin");
- if (bin == null)
- {
- throw new IllegalStateException("bin MUST be present for shared state
CL. This is because tests might run concurrently!");
- }
- }
-
- if (!BINS.containsKey(bin)) BINS.put(bin, new ConcurrentHashMap<Fqn,
DummyNode>());
- nodes = null; // set this to null so any method in superclass that uses this
directly will barf with an NPE
- }
-
- @Override
- protected Map<Fqn, DummyNode> getNodesMap()
- {
- return BINS.get(bin);
- }
-
- @Override
- public void wipe()
- {
- BINS.clear();
- }
-
- public void wipeBin() {
- BINS.remove(bin);
- }
-}
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-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -2,21 +2,31 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
@Test(groups = {"functional"}, testName =
"loader.FileCacheLoaderTest")
public class FileCacheLoaderTest extends CacheLoaderTestsBase
{
- protected void configureCache() throws Exception
+ private String tmpCLLoc = TestingUtil.TEST_FILES + getClass().getName();
+
+ @BeforeTest
+ @AfterTest
+ public void removeCacheLoaderFolder()
{
- 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));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
+ protected void configureCache(CacheSPI cache) throws Exception
+ {
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.FileCacheLoader",
+ "location=" + tmpCLLoc, false, true, false, false, false));
+ }
+
public void testIsCharacterPortableLocation()
{
FileCacheLoader fcl = new FileCacheLoader();
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -11,6 +11,7 @@
import java.util.Properties;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.TestDbPropertiesFactory;
@@ -18,7 +19,7 @@
* To test the closing of JDBC connections
*/
@Test(groups = "functional", sequential = true, testName =
"loader.JDBCCacheLoaderConnectionTest")
-public class JDBCCacheLoaderConnectionTest extends AbstractCacheLoaderTestBase
+public class JDBCCacheLoaderConnectionTest
{
private Cache cache;
private Properties props;
@@ -28,7 +29,7 @@
{
props = TestDbPropertiesFactory.getTestDbProperties();
cache = new UnitTestCacheFactory<Object, Object>().createCache(false,
getClass());
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
JDBCCacheLoader.class.getName(), props, false, false, true));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", JDBCCacheLoader.class.getName(), props, false, false, true, false, false));
cache.start();
}
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -7,12 +7,14 @@
package org.jboss.cache.loader;
import org.jboss.cache.Fqn;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.util.TestDbPropertiesFactory;
import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
+import org.testng.annotations.AfterTest;
import org.hsqldb.jdbc.jdbcDataSource;
import javax.naming.Context;
@@ -38,50 +40,56 @@
//private String old_factory = null;
private final String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
private final String JNDI_NAME = "java:/DerbyDS";
- private Properties prop;
- private jdbcDataSource ds;
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
- //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
- DummyTransactionManager.getInstance();
-
- Context context = new InitialContext();
- try
+ if (ds == null)
{
- Object obj = context.lookup(JNDI_NAME);
- assertNull(JNDI_NAME + " not bound", obj);
- }
- catch (NameNotFoundException n)
- {
- // expected
- }
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
+ DummyTransactionManager.getInstance();
- prop = TestDbPropertiesFactory.getTestDbProperties();
+ Context context = new InitialContext();
+ try
+ {
+ Object obj = context.lookup(JNDI_NAME);
+ assertNull(JNDI_NAME + " not bound", obj);
+ }
+ catch (NameNotFoundException n)
+ {
+ // expected
+ }
- ds = new jdbcDataSource();
- ds.setDatabase(prop.getProperty("cache.jdbc.url"));
- ds.setUser("sa");
+ prop = TestDbPropertiesFactory.getTestDbProperties();
+ ds = new jdbcDataSource();
+ ds.setDatabase(prop.getProperty("cache.jdbc.url"));
+ ds.setUser("sa");
+
+ context.bind(JNDI_NAME, ds);
+ assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
+ }
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" + "\n" +
"cache.jdbc.table.primarykey=jbosscache_pk";
-
- CacheLoaderConfig config = getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false);
+ CacheLoaderConfig config =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
"org.jboss.cache.loader.JDBCCacheLoader",
+ props, false, true, false, false, false);
cache.getConfiguration().setCacheLoaderConfig(config);
cache.create();
+ }
+ private Properties prop;
- context.bind(JNDI_NAME, ds);
- assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
- }
+ private jdbcDataSource ds;
- protected void cleanup()
+ @AfterTest
+ protected void distroyDbAfterTest() throws Exception
{
-// ds.setShutdownDatabase("shutdown");
+ Properties icProps = new Properties();
+ icProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
+ Context ctx = new InitialContext(icProps);
+ ctx.unbind(JNDI_NAME);
TestDbPropertiesFactory.shutdownInMemoryDatabase(prop);
}
@@ -127,26 +135,6 @@
// no-op
}
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- super.tearDown();
- Properties icProps = new Properties();
- icProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
- Context ctx = new InitialContext(icProps);
- ctx.unbind(JNDI_NAME);
- /*
- if (old_factory != null)
- {
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
- }
- else
- {
- System.getProperties().remove(Context.INITIAL_CONTEXT_FACTORY);
- }
- */
- }
-
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -24,6 +24,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestDbPropertiesFactory;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -43,7 +44,7 @@
* @since 3.0
*/
@Test(groups = "functional", sequential = true, testName =
"loader.JDBCCacheLoaderStateTransferTest")
-public class JDBCCacheLoaderStateTransferTest extends AbstractCacheLoaderTestBase
+public class JDBCCacheLoaderStateTransferTest
{
CacheSPI first;
@@ -79,7 +80,7 @@
{
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(GenericTransactionManagerLookup.class.getName());
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("/",
JDBCCacheLoader.class.getName(), props, false, true, false);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "/",
JDBCCacheLoader.class.getName(), props, false, true, false, false, false);
clc.setPassivation(false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
@@ -118,6 +119,7 @@
second = (CacheSPI) new
UnitTestCacheFactory().createCache(getConfiguration(props2), getClass());
long stateTranferTime = System.currentTimeMillis() - startTime - cacheStartTime;
+ System.out.println("stateTranferTime = " + stateTranferTime);
for (int i = 0; i < 5012; i+=100)
{
second.get("a/b/"+ i, "k").equals("v");
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-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -8,19 +8,13 @@
import org.jboss.cache.Fqn;
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 org.testng.annotations.*;
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.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestDbPropertiesFactory;
-import org.jboss.cache.util.TestingUtil;
/**
* This test runs cache loader tests using Database as the cache loader store.
@@ -39,14 +33,11 @@
@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();
}
@@ -56,10 +47,17 @@
TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
}
- protected void configureCache() throws Exception
+ @BeforeMethod
+ public void clearDatabase() throws Exception
{
+ loader.remove(Fqn.ROOT);
+ }
+
+ protected void configureCache(CacheSPI cache) throws Exception
+ {
String props = props2String(this.props);
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
JDBCCacheLoader.class.getName(), props, false, true, false));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", JDBCCacheLoader.class.getName(),
+ props, false, true, false, false, false));
}
private String props2String(Properties prop)
@@ -76,13 +74,6 @@
return p.toString();
}
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- TestingUtil.killCaches(cache);
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
- }
-
private void append(String propertyName, Properties prop, StringBuilder builder)
{
if (prop.containsKey(propertyName))
@@ -126,6 +117,4 @@
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-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,6 +1,7 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
@@ -14,13 +15,13 @@
public class JdbmCacheLoader2Test extends CacheLoaderTestsBase
{
@Override
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoader2Test-" +
threadId;
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.jdbm.JdbmCacheLoader2",
- "location=" + tmpCLLoc, false, true, false));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.jdbm.JdbmCacheLoader2",
+ "location=" + tmpCLLoc, false, true, false, false, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
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-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,6 +1,7 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
@@ -13,12 +14,13 @@
@Test (groups = {"functional"}, testName =
"loader.JdbmCacheLoaderTest")
public class JdbmCacheLoaderTest extends CacheLoaderTestsBase
{
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
String tmpDir = TestingUtil.TEST_FILES;
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoaderTest-" +
threadId;
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.jdbm.JdbmCacheLoader", "location=" + tmpCLLoc,
false, true, false));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", "org.jboss.cache.loader.jdbm.JdbmCacheLoader",
+ "location=" + tmpCLLoc, false, true, false, false, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -4,23 +4,25 @@
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@Test(groups = {"functional"}, sequential = true, testName =
"loader.LocalDelegatingCacheLoaderTest")
public class LocalDelegatingCacheLoaderTest extends CacheLoaderTestsBase
{
- CacheSPI delegating_cache;
+ CacheSPI delegatingCache;
- protected void configureCache() throws Exception
+ protected void configureCache(CacheSPI cache) throws Exception
{
- delegating_cache = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(false, getClass());
- delegating_cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- delegating_cache.create();
- delegating_cache.start();
+ if (delegatingCache == null)
+ {
+ delegatingCache = (CacheSPI) new UnitTestCacheFactory<Object,
Object>().createCache(false, getClass());
+ delegatingCache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ delegatingCache.create();
+ delegatingCache.start();
+ }
LocalDelegatingCacheLoaderConfig cfg = new LocalDelegatingCacheLoaderConfig();
- cfg.setDelegate(delegating_cache);
+ cfg.setDelegate(delegatingCache);
cfg.setAsync(false);
cfg.setFetchPersistentState(false);
CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
@@ -28,43 +30,6 @@
cache.getConfiguration().setCacheLoaderConfig(cacheLoaderConfig);
}
- protected void postConfigure()
- {
- CacheLoader ldr = loader;
- LocalDelegatingCacheLoader ldcl = null;
- do
- {
- if (ldr instanceof LocalDelegatingCacheLoader)
- {
- ldcl = (LocalDelegatingCacheLoader) ldr;
- }
- else
- {
- if (ldr instanceof AbstractDelegatingCacheLoader)
- {
- // look deeper in the delegate chain
- ldr = ((AbstractDelegatingCacheLoader) ldr).getCacheLoader();
- }
- else
- {
- // can't dig any deeper!
- break;
- }
- }
- }
- while (ldcl == null);
-
- ldcl.setDelegateCache(delegating_cache);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- super.tearDown();
- delegating_cache.stop();
- delegating_cache.destroy();
- }
-
@Test(groups = {"functional"}, enabled = false)
public void testLoadAndStore() throws Exception
{
Modified: core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java 2008-12-15 14:33:25
UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java 2008-12-16 13:44:26
UTC (rev 7332)
@@ -3,6 +3,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -11,7 +12,7 @@
import org.testng.annotations.Test;
@Test(groups = "functional", sequential = true, testName =
"loader.PreloadTest")
-public class PreloadTest extends AbstractCacheLoaderTestBase
+public class PreloadTest
{
CacheSPI<Object, Object> cache;
Fqn fqn = Fqn.fromString("/a/b/c");
@@ -28,7 +29,8 @@
{
Configuration c =
UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
String props = "bin=" + getClass().getName();
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a",
DummySharedInMemoryCacheLoader.class.getName(), props, false, false, false));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"/a", DummySharedInMemoryCacheLoader.class.getName(),
+ props, false, false, false, false, false));
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c.clone(), getClass());
cache.put(fqn, key, value);
assertExists();
@@ -43,22 +45,26 @@
{
Configuration c =
UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
String props = "bin=" + getClass().getName();
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a",
DummySharedInMemoryCacheLoader.class.getName(), props, false, false, false));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"/a", DummySharedInMemoryCacheLoader.class.getName(),
+ props, false, false, false, false, false));
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c.clone(), getClass());
cache.put(fqn, key, value);
assertExists();
cache.destroy();
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c,/a,/b",
DummySharedInMemoryCacheLoader.class.getName(), props, false, false, false));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"/c,/a,/b", DummySharedInMemoryCacheLoader.class.getName(),
+ props, false, false, false, false, false));
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c.clone(), getClass());
assertExists();
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c, /a, /b",
DummySharedInMemoryCacheLoader.class.getName(), props, false, false, false));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"/c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(),
+ props, false, false, false, false, false));
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c.clone(), getClass());
assertExists();
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig(" /c, /a, /b",
DummySharedInMemoryCacheLoader.class.getName(), props, false, false, false));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
" /c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(),
+ props, false, false, false, false, false));
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c.clone(), getClass());
assertExists();
}
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-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -2,7 +2,6 @@
import static org.testng.AssertJUnit.assertNotNull;
-import java.io.IOException;
import java.util.Properties;
import net.noderunner.amazon.s3.emulator.Server;
@@ -11,72 +10,67 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.testng.annotations.Test;
+import org.testng.annotations.AfterClass;
/**
* Tests {@link org.jboss.cache.loader.s3.S3CacheLoader}.
- *
+ * <p/>
* This requires a S3 account to truly test; uses an emulator otherwise.
*
* @author Elias Ross
* @version $Id$
*/
-@Test(groups =
-{"functional"}, enabled = true, testName =
"loader.S3CacheLoaderTest")
+@Test(groups = {"functional"}, enabled = true, testName =
"loader.S3CacheLoaderTest")
public class S3CacheLoaderTest extends CacheLoaderTestsBase
{
private static final Log log = LogFactory.getLog(S3CacheLoaderTest.class);
- private ThreadLocal<Server> serverTL = new ThreadLocal<Server>();
+ Server server;
@Override
- protected void configureCache() throws Exception
- {
+ protected void configureCache(CacheSPI cache) throws Exception
+ {
+ if (server == null)
+ {
+ server = new Server();
+ server.start();
+
+ }
String accessKey = System.getProperty("accessKey");
String properties;
if (accessKey == null)
{
log.info("Testing using S3CacheLoader using emulator");
- Server server = new Server();
- serverTL.set(server);
- server.start();
- properties =
- "cache.s3.accessKeyId=dummy\n" +
- "cache.s3.secretAccessKey=dummy\n" +
- "cache.s3.server=localhost\n" +
- "cache.s3.port=" + server.getPort() + "\n" +
- "cache.s3.callingFormat=VANITY" + "\n" +
- "cache.s3.bucket=localhost" + "\n";
- }
- else
+ properties =
+ "cache.s3.accessKeyId=dummy\n" +
+ "cache.s3.secretAccessKey=dummy\n" +
+ "cache.s3.server=localhost\n" +
+ "cache.s3.port=" + server.getPort() + "\n" +
+ "cache.s3.callingFormat=VANITY" + "\n" +
+ "cache.s3.bucket=localhost" + "\n";
+ } else
{
- properties =
- "cache.s3.accessKeyId=" + accessKey + "\n" +
- "cache.s3.secretAccessKey=" +
System.getProperty("secretKey") + "\n" ;
+ properties =
+ "cache.s3.accessKeyId=" + accessKey + "\n" +
+ "cache.s3.secretAccessKey=" +
System.getProperty("secretKey") + "\n";
}
- CacheLoaderConfig config = getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.s3.S3CacheLoader", properties, false, true, false);
+ CacheLoaderConfig config =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
"org.jboss.cache.loader.s3.S3CacheLoader",
+ properties, false, true, false, false, false);
Properties p = config.getFirstCacheLoaderConfig().getProperties();
assertNotNull(p.get("cache.s3.accessKeyId"));
assertNotNull(p.get("cache.s3.secretAccessKey"));
cache.getConfiguration().setCacheLoaderConfig(config);
}
-
- @Override
- public void cleanup() {
- Server server = serverTL.get();
- if (server != null)
- {
- try
- {
- server.close();
- }
- catch (IOException e) {
- }
- }
- serverTL.set(null);
+
+ @AfterClass
+ public void closeServerConnection() throws Exception
+ {
+ server.close();
}
protected void postConfigure()
@@ -106,5 +100,9 @@
protected void threadSafetyTest(final boolean singleFqn) throws Exception
{
}
-
+
+ public void testIgnoreModifications() throws Exception
+ {
+ //do nothing
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -8,6 +8,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummyCountingCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.CacheStoreInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
@@ -25,7 +27,7 @@
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
*/
@Test(groups = "functional", sequential = true, testName =
"loader.SharedCacheLoaderTest")
-public class SharedCacheLoaderTest extends AbstractCacheLoaderTestBase
+public class SharedCacheLoaderTest
{
private CacheSPI<Object, Object> cache1, cache2;
private DummyCountingCacheLoader dummyCacheLoader;
@@ -43,8 +45,10 @@
c1.setCacheMode("REPL_SYNC");
c2.setCacheMode("REPL_SYNC");
- c1.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyCountingCacheLoader.class.getName(), "", false, false, true));
- c2.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyCountingCacheLoader.class.getName(), "", false, false, true));
+
c1.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyCountingCacheLoader.class.getName(),
+ "", false, false, true, false, false));
+
c2.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyCountingCacheLoader.class.getName(),
+ "", false, false, true, false, false));
cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c1, false, getClass());
cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c2, false, getClass());
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -29,6 +29,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
/**
@@ -37,7 +38,7 @@
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder
Zamarreno</a>
*/
@Test(groups = "functional", sequential = true, testName =
"loader.SingletonStoreCacheLoaderTest")
-public class SingletonStoreCacheLoaderTest extends AbstractCacheLoaderTestBase
+public class SingletonStoreCacheLoaderTest
{
private static final Log log =
LogFactory.getLog(SingletonStoreCacheLoaderTest.class);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -16,6 +16,9 @@
import javax.transaction.TransactionManager;
import java.util.Set;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.AbstractMultipleCachesTest;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.Configuration;
/**
@@ -23,21 +26,20 @@
* @version $Id$
*/
@Test(groups = {"functional", "transaction"}, sequential = true,
testName = "loader.TxCacheLoaderTest")
-public class TxCacheLoaderTest extends AbstractCacheLoaderTestBase
+public class TxCacheLoaderTest extends AbstractMultipleCachesTest
{
CacheSPI<Object, Object> cache1, cache2;
private Fqn fqn = Fqn.fromString("/one/two/three");
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
+
+ protected void createCaches() throws Throwable
{
-
Configuration c1 = new Configuration();
c1.setCacheMode("repl_sync");
c1.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
c1.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- c1.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
- // cache1.setReplQueueInterval(3000);
+
c1.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyInMemoryCacheLoader.class.getName(),
+ "", false, false, false, false, false));
cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c1, false, getClass());
cache1.create();
@@ -47,25 +49,23 @@
c2.setCacheMode("repl_sync");
c2.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
c2.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- c2.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
+
c2.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyInMemoryCacheLoader.class.getName(),
+ "", false, false, false, false, false));
c2.setLockAcquisitionTimeout(2000);
// cache2.setReplQueueInterval(3000);
cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(c2, false, getClass());
cache2.create();
cache2.start();
+
+ registerCaches(cache1, cache2);
}
- @AfterMethod(alwaysRun = false)
+ @AfterMethod
public void tearDown() throws Exception
{
// clean up cache loaders!!
cache1.removeNode(Fqn.ROOT);
-
- TestingUtil.killCaches(cache1);
- TestingUtil.killCaches(cache2);
- cache1 = null;
- cache2 = null;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -5,8 +5,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -66,7 +65,7 @@
*/
@Test(groups = {"functional"}, enabled = false, testName =
"loader.deadlock.ConcurrentCreationDeadlockTest")
// Disabling since this has issues with ReadWriteWithUpgradeLock. See JBCACHE-461
-public class ConcurrentCreationDeadlockTest extends AbstractCacheLoaderTestBase
+public class ConcurrentCreationDeadlockTest
{
/**
* The number of worker threads to start concurrently.
@@ -160,7 +159,8 @@
cache.getConfiguration().setCacheMode(cacheMode);
if (cacheLoaderClass != null)
{
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
cacheLoaderClass, "", false, false, false));
+
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", cacheLoaderClass,
+ "", false, false, false, false, false));
}
cache.getConfiguration().setLockAcquisitionTimeout(600000);
cache.start();
Copied:
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyCountingCacheLoader.java
(from rev 7308,
core/trunk/src/test/java/org/jboss/cache/loader/DummyCountingCacheLoader.java)
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyCountingCacheLoader.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyCountingCacheLoader.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.cache.loader.testloaders;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Dummy cache loader that captures the number of times each method is called. Stores
statistics statically, mimicking
+ * a shared cache loader.
+ *
+ * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
+ */
+public class DummyCountingCacheLoader extends AbstractCacheLoader
+{
+ private static int getChildrenNamesCount = 0, getCount = 0, putCount = 0, existsCount
= 0, removeCount = 0;
+
+ public int getGetChildrenNamesCount()
+ {
+ return getChildrenNamesCount;
+ }
+
+ public int getGetCount()
+ {
+ return getCount;
+ }
+
+ public int getPutCount()
+ {
+ return putCount;
+ }
+
+ public int getExistsCount()
+ {
+ return existsCount;
+ }
+
+ public int getRemoveCount()
+ {
+ return removeCount;
+ }
+
+
+ /**
+ * Sets the configuration. Will be called before {@link #create()} and {@link
#start()}
+ */
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ }
+
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return null;
+ }
+
+ /**
+ * Returns a list of children names, all names are <em>relative</em>.
Returns null if the parent node is not found.
+ * The returned set must not be modified, e.g. use Collections.unmodifiableSet(s) to
return the result
+ *
+ * @param fqn The FQN of the parent
+ * @return Set<String>. A list of children. Returns null if no children nodes
are present, or the parent is
+ * not present
+ */
+ public Set<String> getChildrenNames(Fqn fqn) throws Exception
+ {
+ getChildrenNamesCount++;
+ return null;
+ }
+
+ /**
+ * Returns the value for a given key. Returns null if the node doesn't exist, or
the value is not bound
+ *
+ * @param name
+ * @return
+ * @throws Exception
+ */
+ public Object get(Fqn name, Object key) throws Exception
+ {
+ getCount++;
+ return null;
+ }
+
+ /**
+ * Returns all keys and values from the persistent store, given a fully qualified
name
+ *
+ * @param name
+ * @return Map<Object,Object> of keys and values for the given node. Returns
null if the node was not found, or
+ * if the node has no attributes
+ * @throws Exception
+ */
+ public Map<Object, Object> get(Fqn name) throws Exception
+ {
+ getCount++;
+ return null;
+ }
+
+ /**
+ * Checks whether the CacheLoader has a node with Fqn
+ *
+ * @param name
+ * @return True if node exists, false otherwise
+ */
+ public boolean exists(Fqn name) throws Exception
+ {
+ existsCount++;
+ return false;
+ }
+
+ /**
+ * Inserts key and value into the attributes hashmap of the given node. If the node
does not exist, all
+ * parent nodes from the root down are created automatically. Returns the old value
+ */
+ public Object put(Fqn name, Object key, Object value) throws Exception
+ {
+ putCount++;
+ return null;
+ }
+
+ /**
+ * Inserts all elements of attributes into the attributes hashmap of the given node,
overwriting existing
+ * attributes, but not clearing the existing hashmap before insertion (making it a
union of existing and
+ * new attributes)
+ * If the node does not exist, all parent nodes from the root down are created
automatically
+ *
+ * @param name The fully qualified name of the node
+ * @param attributes A Map of attributes. Can be null
+ */
+ public void put(Fqn name, Map attributes) throws Exception
+ {
+ putCount++;
+ }
+
+ /**
+ * Inserts all modifications to the backend store. Overwrite whatever is already in
+ * the datastore.
+ *
+ * @param modifications A List<Modification> of modifications
+ * @throws Exception
+ */
+ public void put(List<Modification> modifications) throws Exception
+ {
+ putCount++;
+ }
+
+ /**
+ * Removes the given key and value from the attributes of the given node. No-op if
node doesn't exist
+ */
+ public Object remove(Fqn name, Object key) throws Exception
+ {
+ removeCount++;
+ return null;
+ }
+
+ /**
+ * Removes the given node. If the node is the root of a subtree, this will recursively
remove all subnodes,
+ * depth-first
+ */
+ public void remove(Fqn name) throws Exception
+ {
+ removeCount++;
+ }
+
+ /**
+ * Removes all attributes from a given node, but doesn't delete the node itself
+ *
+ * @param name
+ * @throws Exception
+ */
+ public void removeData(Fqn name) throws Exception
+ {
+ removeCount++;
+ }
+
+ @Override
+ public void loadEntireState(ObjectOutputStream os) throws Exception
+ {
+ //intentional no-op
+ }
+
+ @Override
+ public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
+ {
+ // intentional no-op
+ }
+
+ @Override
+ public void storeEntireState(ObjectInputStream is) throws Exception
+ {
+ // intentional no-op
+ }
+
+ @Override
+ public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
+ {
+ // intentional no-op
+ }
+
+
+ @Override
+ public void destroy()
+ {
+ getChildrenNamesCount = 0;
+ getCount = 0;
+ putCount = 0;
+ existsCount = 0;
+ removeCount = 0;
+ }
+
+ public void scrubStats()
+ {
+ destroy();
+ }
+}
\ No newline at end of file
Property changes on:
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyCountingCacheLoader.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java
(from rev 7308,
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoader.java)
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -0,0 +1,294 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.cache.loader.testloaders;
+
+import net.jcip.annotations.ThreadSafe;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Dummy cache loader that stores data in memory
+ *
+ * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
+ */
+@ThreadSafe
+public class DummyInMemoryCacheLoader extends AbstractCacheLoader
+{
+
+ private static Log log = LogFactory.getLog(DummyInMemoryCacheLoader.class);
+ // Do NOT access this map directly. always use getNodesMap() since it may be
overridden.
+ protected Map<Fqn, DummyNode> nodes = new ConcurrentHashMap<Fqn,
DummyNode>();
+ protected Map<Object, List<Modification>> transactions = new
ConcurrentHashMap<Object, List<Modification>>();
+ protected boolean debug; // whether to dump System.out messages as well as log
messages or not
+ protected final Object NULL = new Object()
+ {
+ @Override
+ public String toString()
+ {
+ return "NULL placeholder";
+ }
+ };
+ protected IndividualCacheLoaderConfig config;
+
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ this.config = config;
+ if (config != null && config.getProperties() != null)
+ {
+ debug =
Boolean.parseBoolean(config.getProperties().getProperty("debug",
"false"));
+ }
+ }
+
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return config;
+ }
+
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception
+ {
+ if (log.isDebugEnabled()) log.debug("Calling getChildrenNames on Fqn " +
fqn + ". Data map = " + getNodesMap());
+ debugMessage("Calling getChildrenNames on Fqn " + fqn + ". Data map
= " + getNodesMap());
+ if (!getNodesMap().containsKey(fqn))
+ {
+ log.debug("node not in loader");
+ debugMessage("node not in loader");
+ return null;
+ }
+
+ Set children = findChildren(fqn);
+ log.debug("Fqn " + fqn + " has children " + children);
+ debugMessage("Fqn " + fqn + " has children " + children);
+ // to keep in line with the CacheLoader interface contract for this method.
+ return children.size() == 0 ? null : children;
+ }
+
+ private Set<Object> findChildren(Fqn p)
+ {
+ Set<Object> c = new HashSet<Object>();
+ for (Fqn f : getNodesMap().keySet())
+ {
+ if (!f.isRoot() && f.getParent().equals(p))
+ {
+ c.add(f.getLastElement());
+ }
+ }
+ return c;
+ }
+
+ public Map<Object, Object> get(Fqn name) throws Exception
+ {
+ DummyNode dn = getNodesMap().get(name);
+ Map<Object, Object> d = dn != null ? dn.data : null;
+
+ if (log.isDebugEnabled()) log.debug("Getting data for fqn " + name +
" = " + d);
+ debugMessage("Getting data for fqn " + name + " = " + d);
+ return stripNULLs(d);
+ }
+
+ private Map<Object, Object> stripNULLs(Map<Object, Object> data)
+ {
+ if (data == null) return null;
+ // otherwise make sure we replace NULL placeholders with nulls.
+ Map<Object, Object> d = new HashMap<Object, Object>(data);
+ if (d.containsKey(NULL))
+ {
+ Object v = d.remove(NULL);
+ d.put(null, v);
+ }
+ Set<Object> keys = new HashSet<Object>();
+ for (Map.Entry<Object, Object> e : d.entrySet())
+ {
+ if (e.getValue() == NULL)
+ {
+ keys.add(e.getKey());
+ }
+ }
+ for (Object k : keys)
+ {
+ d.put(k, null);
+ }
+ return d;
+ }
+
+ private Map<Object, Object> injectNULLs(Map<Object, Object> data)
+ {
+ if (data == null) return null;
+ // otherwise make sure we replace NULL placeholders with nulls.
+ Map<Object, Object> d = new HashMap<Object, Object>(data);
+ if (d.containsKey(null))
+ {
+ Object v = d.remove(null);
+ d.put(NULL, v);
+ }
+ Set<Object> keys = new HashSet<Object>();
+ for (Map.Entry<?, ?> e : d.entrySet())
+ {
+ if (e.getValue() == null)
+ {
+ keys.add(e.getKey());
+ }
+ }
+ for (Object k : keys)
+ {
+ d.put(k, NULL);
+ }
+ return d;
+ }
+
+
+ public boolean exists(Fqn name) throws Exception
+ {
+ debugMessage("Performing exists() on " + name);
+ return getNodesMap().containsKey(name == null ? NULL : name);
+ }
+
+ public Object put(Fqn name, Object key, Object value) throws Exception
+ {
+ DummyNode n = getNodesMap().get(name);
+ if (n == null)
+ {
+ n = new DummyNode(name);
+ }
+ Object k = key == null ? NULL : key;
+ Object v = value == null ? NULL : value;
+ Object old = n.data.put(k, v);
+
+ getNodesMap().put(name, n);
+ // we need to make sure parents get put in as well.
+ recursivelyPutParentsIfNeeded(name);
+ if (log.isDebugEnabled()) log.debug("Did a put on " + name + ", data
is " + n.data);
+ debugMessage("Did a put on " + name + ", data is " + n.data);
+ return old == NULL ? null : old;
+ }
+
+ public void put(Fqn name, Map<Object, Object> attributes) throws Exception
+ {
+ DummyNode n = getNodesMap().get(name);
+ if (n == null)
+ {
+ n = new DummyNode(name);
+ }
+ n.data.clear(); // emulate cache loaders overwriting any internal data map with new
data map passed in.
+ if (attributes != null) n.data.putAll(injectNULLs(attributes));
+ getNodesMap().put(name, n);
+ // we need to make sure parents get put in as well.
+ recursivelyPutParentsIfNeeded(name);
+ if (log.isDebugEnabled()) log.debug("Did a put on " + name + ", data
is " + n.data);
+ debugMessage("Did a put on " + name + ", data is " + n.data);
+ }
+
+ private void recursivelyPutParentsIfNeeded(Fqn node)
+ {
+ Fqn parent = node.getParent();
+ if (getNodesMap().containsKey(parent)) return; // nothing to do.
+
+ // else put the parent in.
+ getNodesMap().put(parent, new DummyNode(parent));
+ recursivelyPutParentsIfNeeded(parent);
+ }
+
+ public Object remove(Fqn fqn, Object key) throws Exception
+ {
+ log.debug("Removing data from " + fqn);
+ debugMessage("Removing data from " + fqn);
+ DummyNode n = getNodesMap().get(fqn);
+ if (n == null) n = new DummyNode(fqn);
+ Object old = n.data.remove(key == null ? NULL : key);
+ getNodesMap().put(fqn, n);
+ return old == NULL ? null : old;
+ }
+
+ public void remove(Fqn fqn) throws Exception
+ {
+ log.debug("Removing fqn " + fqn);
+ debugMessage("Removing fqn " + fqn);
+ getNodesMap().remove(fqn);
+ // remove children.
+ recursivelyRemoveChildren(fqn);
+ }
+
+ private void recursivelyRemoveChildren(Fqn removedParent)
+ {
+ for (Fqn f : getNodesMap().keySet())
+ {
+ if (f.getParent().equals(removedParent))
+ {
+ // remove the child node too
+ getNodesMap().remove(f);
+ // and it's children. Depth first.
+ recursivelyRemoveChildren(f);
+ }
+ }
+ }
+
+ public void removeData(Fqn fqn) throws Exception
+ {
+ log.debug("Removing data from " + fqn);
+ debugMessage("Removing data from " + fqn);
+ DummyNode n = getNodesMap().get(fqn);
+ if (n == null) n = new DummyNode(fqn);
+ n.data.clear();
+ getNodesMap().put(fqn, n);
+ }
+
+ public class DummyNode
+ {
+ Map<Object, Object> data = new ConcurrentHashMap<Object, Object>();
+ Fqn fqn;
+
+ public DummyNode(Fqn fqn)
+ {
+ this.fqn = fqn;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Node{" +
+ "data=" + data +
+ ", fqn=" + fqn +
+ '}';
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "DummyInMemoryCacheLoader{" +
+ "getNodesMap()=" + getNodesMap() +
+ '}';
+ }
+
+ protected void debugMessage(String msg)
+ {
+ if (log.isTraceEnabled()) log.trace(msg);
+ }
+
+ /**
+ * ALWAYS use this method instead of accessing the node map directly as it may be
overridden.
+ */
+ protected Map<Fqn, DummyNode> getNodesMap()
+ {
+ return nodes;
+ }
+
+ public void wipe()
+ {
+ nodes.clear();
+ }
+}
Property changes on:
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummyInMemoryCacheLoader.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummySharedInMemoryCacheLoader.java
(from rev 7308,
core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java)
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummySharedInMemoryCacheLoader.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummySharedInMemoryCacheLoader.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -0,0 +1,57 @@
+package org.jboss.cache.loader.testloaders;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * An extension of the {@link DummyInMemoryCacheLoader} that uses static maps for data,
children,
+ * etc. so it can be shared across instances, emulating a shared database or filesystem
cache loader.
+ * <p/>
+ * Since 2.1.0, this dummy cache loader will take an optional parameter, "bin",
which contains the name of the "bin" to use
+ * in the static field to store the content. This allows for tests to mimic multiple
shared cache loaders in the same cache.
+ *
+ * @author <a href="mailto:manik AT jboss DOT org">Manik
Surtani</a>
+ * @since 2.0.0
+ */
+public class DummySharedInMemoryCacheLoader extends DummyInMemoryCacheLoader
+{
+ protected static final Map<String, Map<Fqn, DummyNode>> BINS = new
ConcurrentHashMap<String, Map<Fqn, DummyNode>>();
+ private String bin = "_default_bin_";
+
+ @Override
+ public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig cfg)
+ {
+ super.setConfig(cfg);
+
+ if (config != null && config.getProperties() != null)
+ {
+ bin = config.getProperties().getProperty("bin");
+ if (bin == null)
+ {
+ throw new IllegalStateException("bin MUST be present for shared state
CL. This is because tests might run concurrently!");
+ }
+ }
+
+ if (!BINS.containsKey(bin)) BINS.put(bin, new ConcurrentHashMap<Fqn,
DummyNode>());
+ nodes = null; // set this to null so any method in superclass that uses this
directly will barf with an NPE
+ }
+
+ @Override
+ protected Map<Fqn, DummyNode> getNodesMap()
+ {
+ return BINS.get(bin);
+ }
+
+ @Override
+ public void wipe()
+ {
+ BINS.clear();
+ }
+
+ public void wipeBin() {
+ BINS.remove(bin);
+ }
+}
Property changes on:
core/trunk/src/test/java/org/jboss/cache/loader/testloaders/DummySharedInMemoryCacheLoader.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -14,7 +14,7 @@
import org.jboss.cache.interceptors.MarshalledValueInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.CacheInvocationDelegate;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java 2008-12-15 14:33:25
UTC (rev 7331)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java 2008-12-16 13:44:26
UTC (rev 7332)
@@ -1,6 +1,5 @@
package org.jboss.cache.mgmt;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -8,7 +7,7 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import static
org.jboss.cache.factories.UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig;
import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Modified:
core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -26,6 +26,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
/**
* Repeats the superclass tests, but with the multiplexer enabled.
@@ -38,7 +39,7 @@
{
private MultiplexerTestHelper muxHelper;
- @BeforeMethod(alwaysRun = true)
+ @BeforeTest
public void setUp() throws Exception
{
muxHelper = new MultiplexerTestHelper();
Modified:
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -5,7 +5,7 @@
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.notifications.event.Event;
import static org.jboss.cache.notifications.event.Event.Type.*;
Modified:
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,12 +1,11 @@
package org.jboss.cache.notifications;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
@@ -29,7 +28,7 @@
* @since 2.0.0
*/
@Test(groups = "functional", sequential = true, testName =
"notifications.NotificationThreadTest")
-public class NotificationThreadTest extends AbstractCacheLoaderTestBase
+public class NotificationThreadTest
{
private Cache<String, String> cache1, cache2;
@@ -52,7 +51,7 @@
conf2.setSyncRollbackPhase(true);
conf1.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
conf2.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- conf1.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
DummyInMemoryCacheLoader.class.getName(), (Properties)null, false, false, false));
+
conf1.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", DummyInMemoryCacheLoader.class.getName(), (Properties) null, false, false,
false, false, false));
cache1 = instance.createCache(conf1, false, getClass());
cache2 = instance.createCache(conf2, false, getClass());
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -18,8 +18,8 @@
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.OptimisticValidatorInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -8,7 +8,7 @@
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -25,7 +25,7 @@
{
protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
{
- return buildSingleCacheLoaderConfig(true, null,
"org.jboss.cache.loader.DummyInMemoryCacheLoader",
+ return buildSingleCacheLoaderConfig(true, null,
"org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader",
"", false, false, false, false, false);
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -7,12 +7,11 @@
package org.jboss.cache.passivation;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeActivated;
import org.jboss.cache.notifications.annotation.NodePassivated;
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -7,12 +7,11 @@
package org.jboss.cache.passivation;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.fail;
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -9,12 +9,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeActivated;
import org.jboss.cache.notifications.annotation.NodeLoaded;
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -17,7 +16,7 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.notifications.annotation.NodeActivated;
import org.jboss.cache.notifications.annotation.NodePassivated;
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -3,7 +3,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
-import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.lock.IsolationLevel;
@@ -29,7 +28,7 @@
* @version $Id$
*/
@Test(groups = "functional", testName =
"passivation.PassivationTestsBase")
-abstract public class PassivationTestsBase extends AbstractCacheLoaderTestBase
+abstract public class PassivationTestsBase
{
Log log = LogFactory.getLog(getClass());
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-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,8 +1,7 @@
package org.jboss.cache.passivation;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.testng.annotations.Test;
@Test(groups = {"functional"}, testName =
"passivation.PassivationToDummyInMemoryCacheLoaderTest")
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -21,20 +21,15 @@
*/
package org.jboss.cache.passivation;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.Region;
-import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
@@ -42,7 +37,7 @@
import java.util.Set;
@Test(groups = "functional", sequential = true, testName =
"passivation.ReplAndStateTransferWithPassivationTest")
-public class ReplAndStateTransferWithPassivationTest extends AbstractCacheLoaderTestBase
+public class ReplAndStateTransferWithPassivationTest
{
public void testStateTransferOfPassivatedState() throws Exception
{
@@ -176,7 +171,8 @@
}
c.setCacheMode(CacheMode.REPL_SYNC);
c.setNodeLockingScheme(nls);
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "bin="+name, false, true,
false);
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
DummySharedInMemoryCacheLoader.class.getName(),
+ "bin=" + name, false, true, false, false, false);
clc.setPassivation(true);
c.setCacheLoaderConfig(clc);
if (useBR)
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
@@ -36,8 +35,8 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
-import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummySharedInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeActivated;
import org.jboss.cache.notifications.annotation.NodeLoaded;
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -1,7 +1,6 @@
package org.jboss.cache.statetransfer;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
@@ -11,7 +10,7 @@
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-12-15
14:33:25 UTC (rev 7331)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-12-16
13:44:26 UTC (rev 7332)
@@ -22,20 +22,16 @@
package org.jboss.cache.statetransfer;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Region;
+import org.jboss.cache.*;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import org.testng.annotations.AfterMethod;
@@ -48,7 +44,6 @@
import java.util.Properties;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import org.jboss.cache.UnitTestCacheFactory;
/**
* Abstract superclass of the StateTransfer tests.
@@ -57,7 +52,7 @@
* @version $Revision$
*/
@Test(groups = {"functional"}, testName =
"statetransfer.StateTransferTestBase")
-public abstract class StateTransferTestBase extends AbstractCacheLoaderTestBase
+public abstract class StateTransferTestBase
{
protected static final int SUBTREE_SIZE = 10;
@@ -236,8 +231,9 @@
+ prop.getProperty("cache.jdbc.node.type") + "\n" +
"cache.jdbc.sql-concat="
+ prop.getProperty("cache.jdbc.sql-concat") + "\n"
+ "cache.jdbc.table.name="
+ prop.getProperty("cache.jdbc.table.name");
-
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false);
+
+ CacheLoaderConfig clc =
UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
"org.jboss.cache.loader.JDBCCacheLoader",
+ props, false, true, false, false, false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
}
@@ -254,7 +250,8 @@
tmp_location = escapeWindowsPath(tmp_location);
String props = "location = " + tmp_location + "\n";
- c.setCacheLoaderConfig(getSingleCacheLoaderConfig("",
cacheloaderClass, props, async, fetchPersistentState, false));
+
c.setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", cacheloaderClass,
+ props, async, fetchPersistentState, false, false, false));
}
}
}