Author: mircea.markus
Date: 2009-02-17 12:28:23 -0500 (Tue, 17 Feb 2009)
New Revision: 7708
Modified:
core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java
core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java
core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java
core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java
core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java
core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java
core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java
core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java
core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java
core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java
core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java
core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java
core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java
core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java
Log:
enforce syncCommit/Rollback phases
Modified: core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++ core/branches/flat/src/test/java/org/horizon/api/MixedModeTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -15,19 +15,19 @@
AdvancedCache localCache1, localCache2;
protected void createCacheManagers() throws Throwable {
- Configuration replSync = new Configuration();
+ Configuration replSync = getDefaultConfig();
replSync.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- Configuration replAsync = new Configuration();
+ Configuration replAsync = getDefaultConfig();
replAsync.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
- Configuration invalSync = new Configuration();
+ Configuration invalSync = getDefaultConfig();
invalSync.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
- Configuration invalAsync = new Configuration();
+ Configuration invalAsync = getDefaultConfig();
invalAsync.setCacheMode(Configuration.CacheMode.INVALIDATION_ASYNC);
- Configuration local = new Configuration();
+ Configuration local = getDefaultConfig();
local.setCacheMode(Configuration.CacheMode.LOCAL);
createClusteredCaches(2, "replSync", replSync);
Modified:
core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -35,7 +35,7 @@
ReplListener replListener1, replListener2;
protected void createCacheManagers() throws Throwable {
- Configuration c = new Configuration();
+ Configuration c = getDefaultConfig();
c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
createClusteredCaches(2, "replSync", c);
Modified: core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/SyncReplTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -29,7 +29,7 @@
private TreeCache<Object, Object> cache1, cache2;
protected void createCacheManagers() throws Throwable {
- Configuration c = new Configuration();
+ Configuration c = getDefaultConfig();
c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
c.setInvocationBatchingEnabled(true);
c.setFetchInMemoryState(false);
Modified: core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++ core/branches/flat/src/test/java/org/horizon/atomic/ClusteredAPITest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -4,9 +4,7 @@
import static org.horizon.atomic.AtomicHashMapTestAssertions.assertIsEmpty;
import static org.horizon.atomic.AtomicHashMapTestAssertions.assertIsEmptyMap;
import org.horizon.config.Configuration;
-import org.horizon.container.DataContainer;
import org.horizon.test.MultipleCacheManagersTest;
-import org.horizon.test.TestingUtil;
import org.horizon.transaction.DummyTransactionManager;
import org.horizon.transaction.DummyTransactionManagerLookup;
import org.testng.annotations.Test;
@@ -19,7 +17,7 @@
AtomicMapCache cache1, cache2;
protected void createCacheManagers() throws Throwable {
- Configuration c = new Configuration();
+ Configuration c = getDefaultConfig();
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
c.setInvocationBatchingEnabled(true);
@@ -41,17 +39,12 @@
assert map.get("blah").equals("blah");
assert map.containsKey("blah");
- System.out.println("Map on cache 2 is " +
cache2.getAtomicMap("map"));
-
assert cache2.getAtomicMap("map").size() == 2;
assert
cache2.getAtomicMap("map").get("blah").equals("blah");
assert cache2.getAtomicMap("map").containsKey("blah");
}
public void testReplicationRollback() throws Exception {
- System.out.println("ClusteredAPITest.testReplicationRollback");
- DataContainer dataContainer = TestingUtil.extractComponent(cache2,
DataContainer.class);
- System.out.println("dataContainer = " + dataContainer);
assertIsEmptyMap(cache2, "map");
AtomicMap map = cache1.getAtomicMap("map");
Modified: core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -14,7 +14,7 @@
Cache c1, c2;
protected void createCacheManagers() throws Throwable {
- Configuration cfg = new Configuration();
+ Configuration cfg = getDefaultConfig();
cfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
List<Cache> caches = createClusteredCaches(2, "cache", cfg);
c1 = caches.get(0);
Modified:
core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/invalidation/BaseInvalidationTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -32,7 +32,7 @@
protected boolean isSync;
protected void createCacheManagers() throws Throwable {
- Configuration c = new Configuration();
+ Configuration c = getDefaultConfig();
c.setStateRetrievalTimeout(1000);
c.setFetchInMemoryState(false);
c.setCacheMode(isSync ? Configuration.CacheMode.INVALIDATION_SYNC :
Configuration.CacheMode.INVALIDATION_ASYNC);
Modified:
core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/loader/PassivationFunctionalTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -24,7 +24,7 @@
*
* @author Manik Surtani
*/
-@Test(groups = "functional", sequential = true, testName =
"loader.PassivationFunctionalTest")
+@Test(groups = "functional", testName =
"loader.PassivationFunctionalTest")
public class PassivationFunctionalTest {
Cache cache;
CacheStore store;
Modified:
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -24,7 +24,7 @@
import java.util.List;
import java.util.Set;
-@Test(groups = "unit", testName =
"loader.decorators.ChainingCacheLoaderTest", sequential = true)
+@Test(groups = "unit", testName =
"loader.decorators.ChainingCacheLoaderTest")
public class ChainingCacheLoaderTest extends BaseCacheLoaderTest {
DummyInMemoryCacheLoader store1, store2;
Modified:
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -29,7 +29,7 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
-@Test(groups = "functional", sequential = true, testName =
"loader.decorators.SingletonStoreTest")
+@Test(groups = "functional", testName =
"loader.decorators.SingletonStoreTest")
public class SingletonStoreTest extends MultipleCacheManagersTest {
private static final Log log = LogFactory.getLog(SingletonStoreTest.class);
private static final AtomicInteger storeCounter = new AtomicInteger(0);
Modified: core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/marshall/MarshalledValueTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -46,7 +46,7 @@
String k = "key", v = "value";
protected void createCacheManagers() throws Throwable {
- Configuration replSync = new Configuration();
+ Configuration replSync = getDefaultConfig();
replSync.setCacheMode(Configuration.CacheMode.REPL_SYNC);
replSync.setUseLazyDeserialization(true);
@@ -211,7 +211,7 @@
Pojo pojo = new Pojo();
MarshalledValue mv = new MarshalledValue(pojo, true);
- Configuration c = new Configuration();
+ Configuration c = getDefaultConfig();
// ComponentRegistry cr = new ComponentRegistry(c, new
CacheDelegate("aaa"));
HorizonMarshaller marshaller = new HorizonMarshaller();
@@ -251,7 +251,7 @@
public void testCacheLoaders() throws CloneNotSupportedException {
tearDown();
- Configuration cacheCofig = new Configuration();
+ Configuration cacheCofig = getDefaultConfig();
cacheCofig.setCacheMode(Configuration.CacheMode.REPL_SYNC);
cacheCofig.setUseLazyDeserialization(true);
CacheLoaderManagerConfig clmc = new CacheLoaderManagerConfig();
Modified:
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -19,7 +19,7 @@
import java.util.LinkedList;
import java.util.List;
-@Test(groups = "functional", sequential = true, testName =
"notifications.CacheListenerCacheLoaderTest")
+@Test(groups = "functional", testName =
"notifications.CacheListenerCacheLoaderTest")
public class CacheListenerCacheLoaderTest {
CacheManager cm;
Modified: core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++ core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -1,13 +1,11 @@
package org.horizon.profiling;
import org.horizon.Cache;
-import org.horizon.test.TestingUtil;
import org.horizon.config.Configuration;
import org.horizon.lock.IsolationLevel;
-import org.horizon.logging.Log;
-import org.horizon.logging.LogFactory;
import org.horizon.profiling.testinternals.Generator;
import org.horizon.profiling.testinternals.TaskRunner;
+import org.horizon.test.TestingUtil;
import org.testng.annotations.Test;
import java.util.ArrayList;
@@ -40,8 +38,6 @@
private List<Object> keys = new ArrayList<Object>(MAX_OVERALL_KEYS);
- Log log = LogFactory.getLog(ProfileTest.class);
-
@Test(enabled = false)
public void testLocalMode() throws Exception {
Cache c = (Cache) cache;
Modified: core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++ core/branches/flat/src/test/java/org/horizon/replication/AsyncReplTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -29,7 +29,7 @@
Cache cache1, cache2;
protected void createCacheManagers() throws Throwable {
- Configuration asyncConfiguration = new Configuration();
+ Configuration asyncConfiguration = getDefaultConfig();
asyncConfiguration.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
asyncConfiguration.setSyncCommitPhase(true);
asyncConfiguration.setSyncRollbackPhase(true);
Modified:
core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/replication/BaseReplicatedAPITest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -22,7 +22,7 @@
protected boolean isSync;
protected void createCacheManagers() throws Throwable {
- Configuration c = new Configuration();
+ Configuration c = getDefaultConfig();
c.setStateRetrievalTimeout(1000);
c.setFetchInMemoryState(false);
c.setCacheMode(isSync ? Configuration.CacheMode.REPL_SYNC :
Configuration.CacheMode.REPL_ASYNC);
Modified:
core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/replication/ReplicationExceptionTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -35,7 +35,7 @@
private AdvancedCache cache1, cache2;
protected void createCacheManagers() throws Throwable {
- Configuration configuration = new Configuration();
+ Configuration configuration = getDefaultConfig();
configuration.setCacheMode(Configuration.CacheMode.REPL_SYNC);
configuration.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
Modified:
core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -38,7 +38,7 @@
private final static Log log = LogFactory.getLog(SyncCacheListenerTest.class);
protected void createCacheManagers() throws Throwable {
- Configuration conf = new Configuration();
+ Configuration conf = getDefaultConfig();
conf.setSyncCommitPhase(true);
conf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
conf.setIsolationLevel(IsolationLevel.SERIALIZABLE);
Modified: core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++ core/branches/flat/src/test/java/org/horizon/replication/SyncReplTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -35,7 +35,7 @@
String k = "key", v = "value";
protected void createCacheManagers() throws Throwable {
- Configuration replSync = new Configuration();
+ Configuration replSync = getDefaultConfig();
replSync.setCacheMode(Configuration.CacheMode.REPL_SYNC);
createClusteredCaches(2, "replSync", replSync);
@@ -64,7 +64,7 @@
assert cache1.isEmpty();
assert cache2.isEmpty();
- Configuration newConf = new Configuration();
+ Configuration newConf = getDefaultConfig();
newConf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
defineCacheOnAllManagers("newCache", newConf);
Cache altCache1 = manager(0).getCache("newCache");
@@ -95,7 +95,7 @@
assert cache1.isEmpty();
assert cache2.isEmpty();
- Configuration newConf = new Configuration();
+ Configuration newConf = getDefaultConfig();
newConf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
defineCacheOnAllManagers("newCache2", newConf);
Cache altCache1 = manager(0).getCache("newCache2");
@@ -123,7 +123,7 @@
Transport originalTransport = null;
RPCManagerImpl rpcManager = null;
try {
- Configuration asyncCache = new Configuration();
+ Configuration asyncCache = getDefaultConfig();
asyncCache.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
defineCacheOnAllManagers("asyncCache", asyncCache);
Cache asyncCache1 = manager(0).getCache("asyncCache");
Modified: core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++ core/branches/flat/src/test/java/org/horizon/test/AbstractCacheTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -23,8 +23,9 @@
* @author Mircea.Markus(a)jboss.com
*/
public class AbstractCacheTest {
- protected static final Log fwkLogger =
LogFactory.getLog("TestFrameworkLogger");
+ protected final Log log = LogFactory.getLog(getClass());
+
public void clearContent(CacheManager cacheManager) {
Set<Cache> runningCaches = getRunningCaches(cacheManager);
for (Cache cache : runningCaches) {
@@ -40,7 +41,7 @@
}
@SuppressWarnings(value = "unchecked")
- private Set<Cache> getRunningCaches(CacheManager cacheManager) {
+ protected Set<Cache> getRunningCaches(CacheManager cacheManager) {
ConcurrentMap<String, Cache> caches = (ConcurrentMap<String, Cache>)
TestingUtil.extractField(DefaultCacheManager.class, cacheManager, "caches");
Set<Cache> result = new HashSet<Cache>();
for (Cache cache : caches.values()) {
@@ -69,11 +70,11 @@
str = "a non-clustered cache manager";
else
str = "a cache manager at address " + a;
- fwkLogger.debug("Cleaning data for cache '{0}' on {1}",
cache.getName(), str);
+ log.debug("Cleaning data for cache '{0}' on {1}",
cache.getName(), str);
DataContainer dataContainer = TestingUtil.extractComponent(cache,
DataContainer.class);
- fwkLogger.debug("removeInMemoryData(): dataContainerBefore == {0}",
dataContainer);
+ log.debug("removeInMemoryData(): dataContainerBefore == {0}",
dataContainer);
dataContainer.clear();
- fwkLogger.debug("removeInMemoryData(): dataContainerAfter == {0}",
dataContainer);
+ log.debug("removeInMemoryData(): dataContainerAfter == {0}",
dataContainer);
}
private void clearRunningTx(Cache cache) {
Modified:
core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java 2009-02-17
16:48:58 UTC (rev 7707)
+++
core/branches/flat/src/test/java/org/horizon/test/MultipleCacheManagersTest.java 2009-02-17
17:28:23 UTC (rev 7708)
@@ -68,7 +68,8 @@
@AfterMethod
protected void clearContent() throws Throwable {
if (cleanup == CleanupPhase.AFTER_TEST) {
- fwkLogger.debug("*** Test method complete; clearing contents on all
caches.");
+ assertSupportedConfig();
+ log.debug("*** Test method complete; clearing contents on all
caches.");
if (cacheManagers.isEmpty())
throw new IllegalStateException("No caches registered! Use
registerCacheManager(Cache... caches) do that!");
for (CacheManager cacheManager : cacheManagers) {
@@ -79,6 +80,24 @@
}
}
+ /**
+ * @see #getDefaultConfig()
+ */
+ private void assertSupportedConfig() {
+ for (CacheManager cm : cacheManagers) {
+ for (Cache cache : getRunningCaches(cm)) {
+ Configuration config = cache.getConfiguration();
+ try {
+ assert config.isSyncCommitPhase();
+ assert config.isSyncRollbackPhase();
+ } catch (AssertionError e) {
+ log.error("Invalid config for cache: " + getClass().getName());
+ throw e;
+ }
+ }
+ }
+ }
+
final protected void registerCaches(CacheManager... cacheManagers) {
this.cacheManagers.addAll(Arrays.asList(cacheManagers));
}
@@ -142,6 +161,18 @@
}
/**
+ * When multiple test merhods operate on same cluster, sync commit and rollback are
mandatory. This is in order to
+ * make sure that an commit message will be dispatched in the same test method it was
triggered and it will not
+ * interfere with further log messages.
+ */
+ protected Configuration getDefaultConfig() {
+ Configuration configuration = new Configuration();
+ configuration.setSyncCommitPhase(true);
+ configuration.setSyncRollbackPhase(true);
+ return configuration;
+ }
+
+ /**
* Create the cache managers you need for your test. Note that the cache managers you
create *must* be created using
* {@link #addClusterEnabledCacheManager()}
*/