[infinispan-commits] Infinispan SVN: r554 - trunk/core/src/test/java/org/infinispan/distribution.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Jul 13 05:37:28 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-07-13 05:37:27 -0400 (Mon, 13 Jul 2009)
New Revision: 554
Modified:
trunk/core/src/test/java/org/infinispan/distribution/AsyncAPIAsyncDistTest.java
trunk/core/src/test/java/org/infinispan/distribution/AsyncAPISyncDistTest.java
trunk/core/src/test/java/org/infinispan/distribution/BaseDistCacheStoreTest.java
trunk/core/src/test/java/org/infinispan/distribution/BaseDistFunctionalTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistAsyncFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxUnsafeFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistAsyncUnsafeFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSkipRemoteLookupTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreNotSharedTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreSharedTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSyncFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxUnsafeFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSyncUnsafeFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/MagicKeyTest.java
Log:
Disabled DIST tests
Modified: trunk/core/src/test/java/org/infinispan/distribution/AsyncAPIAsyncDistTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/AsyncAPIAsyncDistTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/AsyncAPIAsyncDistTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,51 +1,47 @@
package org.infinispan.distribution;
-import org.infinispan.commands.write.WriteCommand;
-import org.infinispan.test.AbstractCacheTest;
-import org.infinispan.test.ReplListener;
-
// For some reason I had to comment this out to ensure the test was disabled!
//@Test(groups = "functional", testName = "distribution.AsyncAPIAsyncDistTest", enabled = false)
public class AsyncAPIAsyncDistTest extends AsyncAPISyncDistTest {
- ReplListener rl;
-
- public AsyncAPIAsyncDistTest() {
- cleanup = AbstractCacheTest.CleanupPhase.AFTER_METHOD;
- }
-
- @Override
- protected void createCacheManagers() throws Throwable {
- super.createCacheManagers();
- rl = new ReplListener(c2, true);
- }
-
- @Override
- protected boolean sync() {
- return false;
- }
-
- @Override
- protected void resetListeners() {
- rl.resetEager();
- }
-
- @Override
- protected void asyncWait(boolean tx, Class<? extends WriteCommand>... cmds) {
- if (tx) {
- if (cmds == null || cmds.length == 0)
- rl.expectAnyWithTx();
- else
- rl.expectWithTx(cmds);
- } else {
- if (cmds == null || cmds.length == 0)
- rl.expectAny();
- else
- rl.expect(cmds);
- }
-
-
- rl.waitForRpc();
- }
+// ReplListener rl;
+//
+// public AsyncAPIAsyncDistTest() {
+// cleanup = AbstractCacheTest.CleanupPhase.AFTER_METHOD;
+// }
+//
+// @Override
+// protected void createCacheManagers() throws Throwable {
+// super.createCacheManagers();
+// rl = new ReplListener(c2, true);
+// }
+//
+// @Override
+// protected boolean sync() {
+// return false;
+// }
+//
+// @Override
+// protected void resetListeners() {
+// rl.resetEager();
+// }
+//
+// @Override
+// protected void asyncWait(boolean tx, Class<? extends WriteCommand>... cmds) {
+// if (tx) {
+// if (cmds == null || cmds.length == 0)
+// rl.expectAnyWithTx();
+// else
+// rl.expectWithTx(cmds);
+// } else {
+// if (cmds == null || cmds.length == 0)
+// rl.expectAny();
+// else
+// rl.expect(cmds);
+// }
+//
+//
+// rl.waitForRpc();
+// }
}
\ No newline at end of file
Modified: trunk/core/src/test/java/org/infinispan/distribution/AsyncAPISyncDistTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/AsyncAPISyncDistTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/AsyncAPISyncDistTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,35 +1,27 @@
package org.infinispan.distribution;
-import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
-import org.infinispan.context.Flag;
import org.infinispan.replication.AsyncAPISyncReplTest;
-import org.infinispan.test.data.Key;
-import org.infinispan.transaction.lookup.DummyTransactionManagerLookup;
-import org.infinispan.util.Util;
-import java.util.List;
-
// For some reason I had to comment this out to ensure the test was disabled!
//@Test(groups = "functional", testName = "distribution.AsyncAPISyncDistTest", enabled = false)
public class AsyncAPISyncDistTest extends AsyncAPISyncReplTest {
- @SuppressWarnings("unchecked")
- @Override
- protected void createCacheManagers() throws Throwable {
- Configuration c =
- getDefaultClusteredConfig(sync() ? Configuration.CacheMode.DIST_SYNC : Configuration.CacheMode.DIST_ASYNC);
- c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- List<Cache<Key, String>> l = createClusteredCaches(2, getClass().getSimpleName(), c);
- c1 = l.get(0);
- c2 = l.get(1);
- }
-
- @Override
- protected void assertOnAllCaches(Key k, String v) {
- Object real;
- assert Util.safeEquals((real = c1.getAdvancedCache().get(k, Flag.SKIP_REMOTE_LOOKUP)), v) : "Error on cache 1. Expected " + v + " and got " + real;
- assert Util.safeEquals((real = c2.getAdvancedCache().get(k, Flag.SKIP_REMOTE_LOOKUP)), v) : "Error on cache 2. Expected " + v + " and got " + real;
- }
+// @SuppressWarnings("unchecked")
+// @Override
+// protected void createCacheManagers() throws Throwable {
+// Configuration c =
+// getDefaultClusteredConfig(sync() ? Configuration.CacheMode.DIST_SYNC : Configuration.CacheMode.DIST_ASYNC);
+// c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+// List<Cache<Key, String>> l = createClusteredCaches(2, getClass().getSimpleName(), c);
+// c1 = l.get(0);
+// c2 = l.get(1);
+// }
+//
+// @Override
+// protected void assertOnAllCaches(Key k, String v) {
+// Object real;
+// assert Util.safeEquals((real = c1.getAdvancedCache().get(k, Flag.SKIP_REMOTE_LOOKUP)), v) : "Error on cache 1. Expected " + v + " and got " + real;
+// assert Util.safeEquals((real = c2.getAdvancedCache().get(k, Flag.SKIP_REMOTE_LOOKUP)), v) : "Error on cache 2. Expected " + v + " and got " + real;
+// }
}
\ No newline at end of file
Modified: trunk/core/src/test/java/org/infinispan/distribution/BaseDistCacheStoreTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/BaseDistCacheStoreTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/BaseDistCacheStoreTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -21,31 +21,25 @@
*/
package org.infinispan.distribution;
-import org.infinispan.config.CacheLoaderManagerConfig;
-import org.infinispan.config.Configuration;
-import org.infinispan.loaders.dummy.DummyInMemoryCacheStore;
-import org.infinispan.manager.CacheManager;
-import org.infinispan.test.fwk.TestCacheManagerFactory;
-
/**
* DistSyncCacheStoreTest.
- *
+ *
* @author Galder Zamarreño
* @since 4.0
*/
public abstract class BaseDistCacheStoreTest extends BaseDistFunctionalTest {
- boolean shared;
- int id;
-
- @Override
- protected CacheManager addClusterEnabledCacheManager() {
- Configuration cfg = new Configuration();
- CacheLoaderManagerConfig clmc = new CacheLoaderManagerConfig();
- clmc.setShared(shared);
- clmc.addCacheLoaderConfig(new DummyInMemoryCacheStore.Cfg(getClass().getSimpleName() + "_" + id++));
- cfg.setCacheLoaderManagerConfig(clmc);
- CacheManager cm = TestCacheManagerFactory.createClusteredCacheManager(cfg);
- cacheManagers.add(cm);
- return cm;
- }
+// boolean shared;
+// int id;
+//
+// @Override
+// protected CacheManager addClusterEnabledCacheManager() {
+// Configuration cfg = new Configuration();
+// CacheLoaderManagerConfig clmc = new CacheLoaderManagerConfig();
+// clmc.setShared(shared);
+// clmc.addCacheLoaderConfig(new DummyInMemoryCacheStore.Cfg(getClass().getSimpleName() + "_" + id++));
+// cfg.setCacheLoaderManagerConfig(clmc);
+// CacheManager cm = TestCacheManagerFactory.createClusteredCacheManager(cfg);
+// cacheManagers.add(cm);
+// return cm;
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/BaseDistFunctionalTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/BaseDistFunctionalTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/BaseDistFunctionalTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,256 +1,241 @@
package org.infinispan.distribution;
-import org.infinispan.Cache;
-import org.infinispan.commands.VisitableCommand;
-import org.infinispan.commands.write.PutKeyValueCommand;
-import org.infinispan.config.Configuration;
-import static org.infinispan.config.Configuration.CacheMode.DIST_ASYNC;
-import static org.infinispan.config.Configuration.CacheMode.DIST_SYNC;
-import org.infinispan.container.DataContainer;
-import org.infinispan.container.entries.ImmortalCacheEntry;
-import org.infinispan.container.entries.InternalCacheEntry;
-import org.infinispan.container.entries.MortalCacheEntry;
-import org.infinispan.remoting.transport.Address;
import org.infinispan.test.MultipleCacheManagersTest;
-import org.infinispan.test.TestingUtil;
-import org.infinispan.transaction.lookup.DummyTransactionManagerLookup;
-import org.infinispan.util.concurrent.IsolationLevel;
-import org.testng.annotations.Test;
-import javax.transaction.TransactionManager;
-import java.io.Serializable;
-import java.util.List;
-
- at Test(groups = "functional", testName = "distribution.BaseDistFunctionalTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.BaseDistFunctionalTest", enabled = false)
public abstract class BaseDistFunctionalTest extends MultipleCacheManagersTest {
- protected Cache<Object, String> c1, c2, c3, c4;
- protected List<Cache<Object, String>> caches;
- protected boolean sync = true;
- protected boolean tx = false;
- protected boolean testRetVals = true;
+ protected void createCacheManagers() {
- protected void createCacheManagers() throws Throwable {
- Configuration c = getDefaultClusteredConfig(sync ? DIST_SYNC : DIST_ASYNC);
- if (!testRetVals) {
- c.setUnsafeUnreliableReturnValues(true);
- // we also need to use repeatable read for tests to work when we dont have reliable return values, since the
- // tests repeatedly queries changes
- c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- }
- if (tx) c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- caches = createClusteredCaches(4, "dist", c);
- c1 = caches.get(0);
- c2 = caches.get(1);
- c3 = caches.get(2);
- c4 = caches.get(3);
}
- // ----------------- HELPERS ----------------
-
- protected void initAndTest() {
- for (Cache<Object, String> c : caches) assert c.isEmpty();
-
- c1.put("k1", "value");
- asyncWait("k1", PutKeyValueCommand.class, getNonOwnersExcludingSelf("k1", addressOf(c1)));
- for (Cache<Object, String> c : caches)
- assert "value".equals(c.get("k1")) : "Failed on cache " + addressOf(c);
- assertOwnershipAndNonOwnership("k1");
- }
-
- protected static Address addressOf(Cache<?, ?> cache) {
- return cache.getCacheManager().getAddress();
- }
-
- protected Cache<Object, String> getFirstNonOwner(String key) {
- return getNonOwners(key)[0];
- }
-
- protected Cache<Object, String> getSecondNonOwner(String key) {
- return getNonOwners(key)[1];
- }
-
- protected void assertOnAllCachesAndOwnership(Object key, String value) {
- for (Cache<Object, String> c : caches) {
- Object realVal = c.get(key);
- if (value == null) {
- assert realVal == null : "Expecting [" + key + "] to equal [" + value + "] on cache ["
- + addressOf(c) + "] but was [" + realVal + "]";
- } else {
- assert value.equals(realVal) : "Expecting [" + key + "] to equal [" + value + "] on cache ["
- + addressOf(c) + "] but was [" + realVal + "]";
- }
- }
- if (value != null) assertOwnershipAndNonOwnership(key);
- }
-
- protected void assertOwnershipAndNonOwnership(Object key) {
- for (Cache<Object, String> c : caches) {
- DataContainer dc = c.getAdvancedCache().getDataContainer();
- if (isOwner(c, key)) {
- InternalCacheEntry ice = dc.get(key);
- assert ice != null : "Fail on cache " + addressOf(c) + ": dc.get(" + key + ") returned null!";
- assert ice instanceof ImmortalCacheEntry : "Fail on cache " + addressOf(c) + ": dc.get(" + key + ") returned " + dc.get(key);
- } else {
- if (dc.containsKey(key)) {
- assert dc.get(key) instanceof MortalCacheEntry : "Fail on cache " + addressOf(c) + ": dc.get(" + key + ") returned " + dc.get(key);
- assert dc.get(key).getLifespan() == c1.getConfiguration().getL1Lifespan();
- }
- }
- }
- }
-
- protected void assertIsInL1(Cache<?, ?> cache, Object key) {
- DataContainer dc = cache.getAdvancedCache().getDataContainer();
- InternalCacheEntry ice = dc.get(key);
- assert ice != null : "Entry for key [" + key + "] should be in data container on cache at [" + addressOf(cache) + "]!";
- assert !(ice instanceof ImmortalCacheEntry) : "Entry for key [" + key + "] should have a lifespan on cache at [" + addressOf(cache) + "]!";
- }
-
- protected void assertIsNotInL1(Cache<?, ?> cache, Object key) {
- DataContainer dc = cache.getAdvancedCache().getDataContainer();
- InternalCacheEntry ice = dc.get(key);
- assert ice == null : "Entry for key [" + key + "] should not be in data container on cache at [" + addressOf(cache) + "]!";
- }
-
- protected void assertIsInContainerImmortal(Cache<?, ?> cache, Object key) {
- DataContainer dc = cache.getAdvancedCache().getDataContainer();
- InternalCacheEntry ice = dc.get(key);
- assert ice != null : "Entry for key [" + key + "] should be in data container on cache at [" + addressOf(cache) + "]!";
- assert ice instanceof ImmortalCacheEntry : "Entry for key [" + key + "] on cache at [" + addressOf(cache) + "] should be immortal but was [" + ice + "]!";
- }
-
- protected static boolean isOwner(Cache<?, ?> c, Object key) {
- DistributionManager dm = c.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
- List<Address> ownerAddresses = dm.locate(key);
- for (Address a : ownerAddresses) {
- if (addressOf(c).equals(a)) return true;
- }
- return false;
- }
-
- protected static boolean isFirstOwner(Cache<?, ?> c, Object key) {
- DistributionManager dm = c.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
- List<Address> ownerAddresses = dm.locate(key);
- return addressOf(c).equals(ownerAddresses.get(0));
- }
-
- protected Cache<Object, String>[] getOwners(Object key) {
- Cache<Object, String>[] owners = new Cache[2];
- int i = 0;
- for (Cache<Object, String> c : caches) {
- if (isOwner(c, key)) owners[i++] = c;
- }
- return owners;
- }
-
- protected Cache<Object, String>[] getNonOwnersExcludingSelf(Object key, Address self) {
- Cache<Object, String>[] nonOwners = getNonOwners(key);
- boolean selfInArray = false;
- for (Cache<?, ?> c : nonOwners) {
- if (addressOf(c).equals(self)) {
- selfInArray = true;
- break;
- }
- }
-
- if (selfInArray) {
- Cache<Object, String>[] nonOwnersExclSelf = new Cache[nonOwners.length - 1];
- int i = 0;
- for (Cache<Object, String> c : nonOwners) {
- if (!addressOf(c).equals(self)) nonOwnersExclSelf[i++] = c;
- }
- return nonOwnersExclSelf;
- } else {
- return nonOwners;
- }
- }
-
- protected Cache<Object, String>[] getNonOwners(Object key) {
- Cache<Object, String>[] nonOwners = new Cache[2];
- int i = 0;
- for (Cache<Object, String> c : caches) {
- if (!isOwner(c, key)) nonOwners[i++] = c;
- }
- return nonOwners;
- }
-
- protected List<Address> residentAddresses(Object key) {
- DistributionManager dm = c1.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
- return dm.locate(key);
- }
-
- protected DistributionManager getDistributionManager(Cache<?, ?> c) {
- return c.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
- }
-
- /**
- * Blocks and waits for a replication event on async caches
- *
- * @param key key that causes the replication. Used to determine which caches to listen on. If null, all caches
- * are checked
- * @param command command to listen for
- * @param caches on which this key should be invalidated
- */
- protected void asyncWait(Object key, Class<? extends VisitableCommand> command, Cache<?, ?>... caches) {
- // no op.
- }
-
- protected TransactionManager getTransactionManager(Cache<?, ?> cache) {
- return TestingUtil.getTransactionManager(cache);
- }
-
- /**
- * A special type of key that if passed a cache in its constructor, will ensure it will always be assigned to that
- * cache (plus however many additional caches in the hash space)
- */
- protected static class MagicKey implements Serializable {
- int hashcode;
- String address;
-
- public MagicKey(Cache<?, ?> toMapTo) {
- address = addressOf(toMapTo).toString();
- for (int i = 0; i < toMapTo.getCacheManager().getMembers().size(); i++) {
- // create a dummy object with this hashcode
- final int hc = i;
- Object dummy = new Object() {
- @Override
- public int hashCode() {
- return hc;
- }
- };
-
- if (BaseDistFunctionalTest.isFirstOwner(toMapTo, dummy)) {
- // we have found a hashcode that works!
- hashcode = hc;
- break;
- }
- }
- }
-
- @Override
- public int hashCode() {
- return hashcode;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- MagicKey magicKey = (MagicKey) o;
-
- if (hashcode != magicKey.hashcode) return false;
- if (address != null ? !address.equals(magicKey.address) : magicKey.address != null) return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "MagicKey{" +
- "hashcode=" + hashcode +
- ", address='" + address + '\'' +
- '}';
- }
- }
+// protected Cache<Object, String> c1, c2, c3, c4;
+// protected List<Cache<Object, String>> caches;
+// protected boolean sync = true;
+// protected boolean tx = false;
+// protected boolean testRetVals = true;
+//
+// protected void createCacheManagers() throws Throwable {
+// Configuration c = getDefaultClusteredConfig(sync ? DIST_SYNC : DIST_ASYNC);
+// if (!testRetVals) {
+// c.setUnsafeUnreliableReturnValues(true);
+// // we also need to use repeatable read for tests to work when we dont have reliable return values, since the
+// // tests repeatedly queries changes
+// c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+// }
+// if (tx) c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+// caches = createClusteredCaches(4, "dist", c);
+// c1 = caches.get(0);
+// c2 = caches.get(1);
+// c3 = caches.get(2);
+// c4 = caches.get(3);
+// }
+//
+// // ----------------- HELPERS ----------------
+//
+// protected void initAndTest() {
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+//
+// c1.put("k1", "value");
+// asyncWait("k1", PutKeyValueCommand.class, getNonOwnersExcludingSelf("k1", addressOf(c1)));
+// for (Cache<Object, String> c : caches)
+// assert "value".equals(c.get("k1")) : "Failed on cache " + addressOf(c);
+// assertOwnershipAndNonOwnership("k1");
+// }
+//
+// protected static Address addressOf(Cache<?, ?> cache) {
+// return cache.getCacheManager().getAddress();
+// }
+//
+// protected Cache<Object, String> getFirstNonOwner(String key) {
+// return getNonOwners(key)[0];
+// }
+//
+// protected Cache<Object, String> getSecondNonOwner(String key) {
+// return getNonOwners(key)[1];
+// }
+//
+// protected void assertOnAllCachesAndOwnership(Object key, String value) {
+// for (Cache<Object, String> c : caches) {
+// Object realVal = c.get(key);
+// if (value == null) {
+// assert realVal == null : "Expecting [" + key + "] to equal [" + value + "] on cache ["
+// + addressOf(c) + "] but was [" + realVal + "]";
+// } else {
+// assert value.equals(realVal) : "Expecting [" + key + "] to equal [" + value + "] on cache ["
+// + addressOf(c) + "] but was [" + realVal + "]";
+// }
+// }
+// if (value != null) assertOwnershipAndNonOwnership(key);
+// }
+//
+// protected void assertOwnershipAndNonOwnership(Object key) {
+// for (Cache<Object, String> c : caches) {
+// DataContainer dc = c.getAdvancedCache().getDataContainer();
+// if (isOwner(c, key)) {
+// InternalCacheEntry ice = dc.get(key);
+// assert ice != null : "Fail on cache " + addressOf(c) + ": dc.get(" + key + ") returned null!";
+// assert ice instanceof ImmortalCacheEntry : "Fail on cache " + addressOf(c) + ": dc.get(" + key + ") returned " + dc.get(key);
+// } else {
+// if (dc.containsKey(key)) {
+// assert dc.get(key) instanceof MortalCacheEntry : "Fail on cache " + addressOf(c) + ": dc.get(" + key + ") returned " + dc.get(key);
+// assert dc.get(key).getLifespan() == c1.getConfiguration().getL1Lifespan();
+// }
+// }
+// }
+// }
+//
+// protected void assertIsInL1(Cache<?, ?> cache, Object key) {
+// DataContainer dc = cache.getAdvancedCache().getDataContainer();
+// InternalCacheEntry ice = dc.get(key);
+// assert ice != null : "Entry for key [" + key + "] should be in data container on cache at [" + addressOf(cache) + "]!";
+// assert !(ice instanceof ImmortalCacheEntry) : "Entry for key [" + key + "] should have a lifespan on cache at [" + addressOf(cache) + "]!";
+// }
+//
+// protected void assertIsNotInL1(Cache<?, ?> cache, Object key) {
+// DataContainer dc = cache.getAdvancedCache().getDataContainer();
+// InternalCacheEntry ice = dc.get(key);
+// assert ice == null : "Entry for key [" + key + "] should not be in data container on cache at [" + addressOf(cache) + "]!";
+// }
+//
+// protected void assertIsInContainerImmortal(Cache<?, ?> cache, Object key) {
+// DataContainer dc = cache.getAdvancedCache().getDataContainer();
+// InternalCacheEntry ice = dc.get(key);
+// assert ice != null : "Entry for key [" + key + "] should be in data container on cache at [" + addressOf(cache) + "]!";
+// assert ice instanceof ImmortalCacheEntry : "Entry for key [" + key + "] on cache at [" + addressOf(cache) + "] should be immortal but was [" + ice + "]!";
+// }
+//
+// protected static boolean isOwner(Cache<?, ?> c, Object key) {
+// DistributionManager dm = c.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
+// List<Address> ownerAddresses = dm.locate(key);
+// for (Address a : ownerAddresses) {
+// if (addressOf(c).equals(a)) return true;
+// }
+// return false;
+// }
+//
+// protected static boolean isFirstOwner(Cache<?, ?> c, Object key) {
+// DistributionManager dm = c.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
+// List<Address> ownerAddresses = dm.locate(key);
+// return addressOf(c).equals(ownerAddresses.get(0));
+// }
+//
+// protected Cache<Object, String>[] getOwners(Object key) {
+// Cache<Object, String>[] owners = new Cache[2];
+// int i = 0;
+// for (Cache<Object, String> c : caches) {
+// if (isOwner(c, key)) owners[i++] = c;
+// }
+// return owners;
+// }
+//
+// protected Cache<Object, String>[] getNonOwnersExcludingSelf(Object key, Address self) {
+// Cache<Object, String>[] nonOwners = getNonOwners(key);
+// boolean selfInArray = false;
+// for (Cache<?, ?> c : nonOwners) {
+// if (addressOf(c).equals(self)) {
+// selfInArray = true;
+// break;
+// }
+// }
+//
+// if (selfInArray) {
+// Cache<Object, String>[] nonOwnersExclSelf = new Cache[nonOwners.length - 1];
+// int i = 0;
+// for (Cache<Object, String> c : nonOwners) {
+// if (!addressOf(c).equals(self)) nonOwnersExclSelf[i++] = c;
+// }
+// return nonOwnersExclSelf;
+// } else {
+// return nonOwners;
+// }
+// }
+//
+// protected Cache<Object, String>[] getNonOwners(Object key) {
+// Cache<Object, String>[] nonOwners = new Cache[2];
+// int i = 0;
+// for (Cache<Object, String> c : caches) {
+// if (!isOwner(c, key)) nonOwners[i++] = c;
+// }
+// return nonOwners;
+// }
+//
+// protected List<Address> residentAddresses(Object key) {
+// DistributionManager dm = c1.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
+// return dm.locate(key);
+// }
+//
+// protected DistributionManager getDistributionManager(Cache<?, ?> c) {
+// return c.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class);
+// }
+//
+// /**
+// * Blocks and waits for a replication event on async caches
+// *
+// * @param key key that causes the replication. Used to determine which caches to listen on. If null, all caches
+// * are checked
+// * @param command command to listen for
+// * @param caches on which this key should be invalidated
+// */
+// protected void asyncWait(Object key, Class<? extends VisitableCommand> command, Cache<?, ?>... caches) {
+// // no op.
+// }
+//
+// protected TransactionManager getTransactionManager(Cache<?, ?> cache) {
+// return TestingUtil.getTransactionManager(cache);
+// }
+//
+// /**
+// * A special type of key that if passed a cache in its constructor, will ensure it will always be assigned to that
+// * cache (plus however many additional caches in the hash space)
+// */
+// protected static class MagicKey implements Serializable {
+// int hashcode;
+// String address;
+//
+// public MagicKey(Cache<?, ?> toMapTo) {
+// address = addressOf(toMapTo).toString();
+// for (int i = 0; i < toMapTo.getCacheManager().getMembers().size(); i++) {
+// // create a dummy object with this hashcode
+// final int hc = i;
+// Object dummy = new Object() {
+// @Override
+// public int hashCode() {
+// return hc;
+// }
+// };
+//
+// if (BaseDistFunctionalTest.isFirstOwner(toMapTo, dummy)) {
+// // we have found a hashcode that works!
+// hashcode = hc;
+// break;
+// }
+// }
+// }
+//
+// @Override
+// public int hashCode() {
+// return hashcode;
+// }
+//
+// @Override
+// public boolean equals(Object o) {
+// if (this == o) return true;
+// if (o == null || getClass() != o.getClass()) return false;
+//
+// MagicKey magicKey = (MagicKey) o;
+//
+// if (hashcode != magicKey.hashcode) return false;
+// if (address != null ? !address.equals(magicKey.address) : magicKey.address != null) return false;
+//
+// return true;
+// }
+//
+// @Override
+// public String toString() {
+// return "MagicKey{" +
+// "hashcode=" + hashcode +
+// ", address='" + address + '\'' +
+// '}';
+// }
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistAsyncFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistAsyncFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistAsyncFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,58 +1,49 @@
package org.infinispan.distribution;
-import org.infinispan.Cache;
-import org.infinispan.commands.VisitableCommand;
-import org.infinispan.commands.write.InvalidateL1Command;
-import org.infinispan.test.ReplListener;
-import org.testng.annotations.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
- at Test(groups = "functional", testName = "distribution.DistAsyncFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistAsyncFuncTest", enabled = false)
public class DistAsyncFuncTest extends DistSyncFuncTest {
- ReplListener r1, r2, r3, r4;
- ReplListener[] r;
- Map<Cache<?, ?>, ReplListener> listenerLookup;
-
- public DistAsyncFuncTest() {
- sync = false;
- tx = false;
- testRetVals = true;
- }
-
- @Override
- protected void createCacheManagers() throws Throwable {
- super.createCacheManagers();
- r1 = new ReplListener(c1, true, true);
- r2 = new ReplListener(c2, true, true);
- r3 = new ReplListener(c3, true, true);
- r4 = new ReplListener(c4, true, true);
- r = new ReplListener[]{r1, r2, r3, r4};
- listenerLookup = new HashMap<Cache<?, ?>, ReplListener>();
- for (ReplListener rl : r) listenerLookup.put(rl.getCache(), rl);
- }
-
-
- @Override
- protected void asyncWait(Object key, Class<? extends VisitableCommand> command, Cache<?, ?>... cachesOnWhichKeyShouldInval) {
- if (key == null) {
- // test all caches.
- for (ReplListener rl : r) rl.expect(command);
- for (ReplListener rl : r) rl.waitForRpc();
- } else {
- for (Cache<?, ?> c : getOwners(key)) {
- listenerLookup.get(c).expect(command);
- listenerLookup.get(c).waitForRpc();
- }
-
- if (cachesOnWhichKeyShouldInval != null) {
- for (Cache<?, ?> c : cachesOnWhichKeyShouldInval) {
- listenerLookup.get(c).expect(InvalidateL1Command.class);
- listenerLookup.get(c).waitForRpc();
- }
- }
- }
- }
+// ReplListener r1, r2, r3, r4;
+// ReplListener[] r;
+// Map<Cache<?, ?>, ReplListener> listenerLookup;
+//
+// public DistAsyncFuncTest() {
+// sync = false;
+// tx = false;
+// testRetVals = true;
+// }
+//
+// @Override
+// protected void createCacheManagers() throws Throwable {
+// super.createCacheManagers();
+// r1 = new ReplListener(c1, true, true);
+// r2 = new ReplListener(c2, true, true);
+// r3 = new ReplListener(c3, true, true);
+// r4 = new ReplListener(c4, true, true);
+// r = new ReplListener[]{r1, r2, r3, r4};
+// listenerLookup = new HashMap<Cache<?, ?>, ReplListener>();
+// for (ReplListener rl : r) listenerLookup.put(rl.getCache(), rl);
+// }
+//
+//
+// @Override
+// protected void asyncWait(Object key, Class<? extends VisitableCommand> command, Cache<?, ?>... cachesOnWhichKeyShouldInval) {
+// if (key == null) {
+// // test all caches.
+// for (ReplListener rl : r) rl.expect(command);
+// for (ReplListener rl : r) rl.waitForRpc();
+// } else {
+// for (Cache<?, ?> c : getOwners(key)) {
+// listenerLookup.get(c).expect(command);
+// listenerLookup.get(c).waitForRpc();
+// }
+//
+// if (cachesOnWhichKeyShouldInval != null) {
+// for (Cache<?, ?> c : cachesOnWhichKeyShouldInval) {
+// listenerLookup.get(c).expect(InvalidateL1Command.class);
+// listenerLookup.get(c).waitForRpc();
+// }
+// }
+// }
+// }
}
\ No newline at end of file
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,83 +1,69 @@
package org.infinispan.distribution;
-import org.infinispan.Cache;
-import org.infinispan.commands.VisitableCommand;
-import org.infinispan.commands.write.InvalidateL1Command;
-import org.infinispan.test.ReplListener;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
- at Test(groups = "functional", testName = "distribution.DistAsyncTxFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistAsyncTxFuncTest", enabled = false)
public class DistAsyncTxFuncTest extends DistSyncTxFuncTest {
- ReplListener r1, r2, r3, r4;
- ReplListener[] r;
- Map<Cache<?, ?>, ReplListener> listenerLookup;
-
- public DistAsyncTxFuncTest() {
- sync = false;
- tx = true;
- testRetVals = true;
- cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
- }
-
- @Override
- protected void createCacheManagers() throws Throwable {
- super.createCacheManagers();
- r1 = new ReplListener(c1, true, true);
- r2 = new ReplListener(c2, true, true);
- r3 = new ReplListener(c3, true, true);
- r4 = new ReplListener(c4, true, true);
- r = new ReplListener[]{r1, r2, r3, r4};
- listenerLookup = new HashMap<Cache<?, ?>, ReplListener>();
- for (ReplListener rl : r) listenerLookup.put(rl.getCache(), rl);
- }
-
- @Override
- protected void asyncWait(Object key, Class<? extends VisitableCommand> command, Cache<?, ?>... cachesOnWhichKeyShouldInval) {
- if (cachesOnWhichKeyShouldInval == null) cachesOnWhichKeyShouldInval = new Cache[0];
- List<Cache<?, ?>> cachesOnWhichKeyShouldInvalList = new ArrayList(Arrays.asList(cachesOnWhichKeyShouldInval));
- if (key == null) {
- // test all caches.
- for (ReplListener rl : r) rl.expect(command);
- for (ReplListener rl : r) rl.waitForRpc();
- } else {
- for (Cache<?, ?> c : getOwners(key)) {
- if (cachesOnWhichKeyShouldInvalList.remove(c)) {
- listenerLookup.get(c).expect(command, InvalidateL1Command.class);
- } else {
- listenerLookup.get(c).expect(command);
- }
- listenerLookup.get(c).waitForRpc();
- }
-
- for (Cache<?, ?> c : cachesOnWhichKeyShouldInvalList) {
- listenerLookup.get(c).expect(InvalidateL1Command.class);
- listenerLookup.get(c).waitForRpc();
- }
- }
- }
-
- @Override
- protected void asyncTxWait(Object... keys) {
- // Wait for a tx completion event
- if (keys != null) {
- Set<Cache<?, ?>> cachesInTx = new HashSet<Cache<?, ?>>();
- for (Object k : keys) {
- cachesInTx.addAll(Arrays.asList(getOwners(k)));
- }
-
- for (Cache<?, ?> c : cachesInTx) {
- listenerLookup.get(c).expectAnyWithTx();
- listenerLookup.get(c).waitForRpc();
- }
- }
- }
+// ReplListener r1, r2, r3, r4;
+// ReplListener[] r;
+// Map<Cache<?, ?>, ReplListener> listenerLookup;
+//
+// public DistAsyncTxFuncTest() {
+// sync = false;
+// tx = true;
+// testRetVals = true;
+// cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
+// }
+//
+// @Override
+// protected void createCacheManagers() throws Throwable {
+// super.createCacheManagers();
+// r1 = new ReplListener(c1, true, true);
+// r2 = new ReplListener(c2, true, true);
+// r3 = new ReplListener(c3, true, true);
+// r4 = new ReplListener(c4, true, true);
+// r = new ReplListener[]{r1, r2, r3, r4};
+// listenerLookup = new HashMap<Cache<?, ?>, ReplListener>();
+// for (ReplListener rl : r) listenerLookup.put(rl.getCache(), rl);
+// }
+//
+// @Override
+// protected void asyncWait(Object key, Class<? extends VisitableCommand> command, Cache<?, ?>... cachesOnWhichKeyShouldInval) {
+// if (cachesOnWhichKeyShouldInval == null) cachesOnWhichKeyShouldInval = new Cache[0];
+// List<Cache<?, ?>> cachesOnWhichKeyShouldInvalList = new ArrayList(Arrays.asList(cachesOnWhichKeyShouldInval));
+// if (key == null) {
+// // test all caches.
+// for (ReplListener rl : r) rl.expect(command);
+// for (ReplListener rl : r) rl.waitForRpc();
+// } else {
+// for (Cache<?, ?> c : getOwners(key)) {
+// if (cachesOnWhichKeyShouldInvalList.remove(c)) {
+// listenerLookup.get(c).expect(command, InvalidateL1Command.class);
+// } else {
+// listenerLookup.get(c).expect(command);
+// }
+// listenerLookup.get(c).waitForRpc();
+// }
+//
+// for (Cache<?, ?> c : cachesOnWhichKeyShouldInvalList) {
+// listenerLookup.get(c).expect(InvalidateL1Command.class);
+// listenerLookup.get(c).waitForRpc();
+// }
+// }
+// }
+//
+// @Override
+// protected void asyncTxWait(Object... keys) {
+// // Wait for a tx completion event
+// if (keys != null) {
+// Set<Cache<?, ?>> cachesInTx = new HashSet<Cache<?, ?>>();
+// for (Object k : keys) {
+// cachesInTx.addAll(Arrays.asList(getOwners(k)));
+// }
+//
+// for (Cache<?, ?> c : cachesInTx) {
+// listenerLookup.get(c).expectAnyWithTx();
+// listenerLookup.get(c).waitForRpc();
+// }
+// }
+// }
}
\ No newline at end of file
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxUnsafeFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxUnsafeFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxUnsafeFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,13 +1,11 @@
package org.infinispan.distribution;
-import org.testng.annotations.Test;
-
- at Test(groups = "functional", testName = "distribution.DistAsyncTxUnsafeFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistAsyncTxUnsafeFuncTest", enabled = false)
public class DistAsyncTxUnsafeFuncTest extends DistAsyncTxFuncTest {
- public DistAsyncTxUnsafeFuncTest() {
- sync = false;
- tx = true;
- testRetVals = false;
- cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
- }
+// public DistAsyncTxUnsafeFuncTest() {
+// sync = false;
+// tx = true;
+// testRetVals = false;
+// cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistAsyncUnsafeFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistAsyncUnsafeFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistAsyncUnsafeFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,12 +1,10 @@
package org.infinispan.distribution;
-import org.testng.annotations.Test;
-
- at Test(groups = "functional", testName = "distribution.DistAsyncUnsafeFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistAsyncUnsafeFuncTest", enabled = false)
public class DistAsyncUnsafeFuncTest extends DistAsyncFuncTest {
- public DistAsyncUnsafeFuncTest() {
- sync = false;
- tx = false;
- testRetVals = false;
- }
+// public DistAsyncUnsafeFuncTest() {
+// sync = false;
+// tx = false;
+// testRetVals = false;
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSkipRemoteLookupTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSkipRemoteLookupTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSkipRemoteLookupTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,52 +1,49 @@
package org.infinispan.distribution;
-import static org.infinispan.context.Flag.SKIP_REMOTE_LOOKUP;
-import org.testng.annotations.Test;
-
- at Test(groups = "functional", testName = "distribution.DistSkipRemoteLookupTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistSkipRemoteLookupTest", enabled = false)
public class DistSkipRemoteLookupTest extends BaseDistFunctionalTest {
- public void testSkipLookupOnGet() {
- MagicKey k1 = new MagicKey(c1);
- c1.put(k1, "value");
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsNotInL1(c3, k1);
- assertIsNotInL1(c4, k1);
-
- assert c4.getAdvancedCache().get(k1, SKIP_REMOTE_LOOKUP) == null;
-
- assertOwnershipAndNonOwnership(k1);
- }
-
- public void testCorrectFunctionalityOnConditionalWrite() {
- MagicKey k1 = new MagicKey(c1);
- c1.put(k1, "value");
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsNotInL1(c3, k1);
- assertIsNotInL1(c4, k1);
-
- assert c4.getAdvancedCache().putIfAbsent(k1, "new_val", SKIP_REMOTE_LOOKUP) == null;
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsNotInL1(c3, k1);
- assertIsInL1(c4, k1);
- }
-
- public void testCorrectFunctionalityOnUnconditionalWrite() {
- MagicKey k1 = new MagicKey(c1);
- c1.put(k1, "value");
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsNotInL1(c3, k1);
- assertIsNotInL1(c4, k1);
-
- assert c4.getAdvancedCache().put(k1, "new_val", SKIP_REMOTE_LOOKUP) == null;
- assert c3.get(k1).equals("new_val");
- assertOnAllCachesAndOwnership(k1, "new_val");
- }
+// public void testSkipLookupOnGet() {
+// MagicKey k1 = new MagicKey(c1);
+// c1.put(k1, "value");
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsNotInL1(c3, k1);
+// assertIsNotInL1(c4, k1);
+//
+// assert c4.getAdvancedCache().get(k1, SKIP_REMOTE_LOOKUP) == null;
+//
+// assertOwnershipAndNonOwnership(k1);
+// }
+//
+// public void testCorrectFunctionalityOnConditionalWrite() {
+// MagicKey k1 = new MagicKey(c1);
+// c1.put(k1, "value");
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsNotInL1(c3, k1);
+// assertIsNotInL1(c4, k1);
+//
+// assert c4.getAdvancedCache().putIfAbsent(k1, "new_val", SKIP_REMOTE_LOOKUP) == null;
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsNotInL1(c3, k1);
+// assertIsInL1(c4, k1);
+// }
+//
+// public void testCorrectFunctionalityOnUnconditionalWrite() {
+// MagicKey k1 = new MagicKey(c1);
+// c1.put(k1, "value");
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsNotInL1(c3, k1);
+// assertIsNotInL1(c4, k1);
+//
+// assert c4.getAdvancedCache().put(k1, "new_val", SKIP_REMOTE_LOOKUP) == null;
+// assert c3.get(k1).equals("new_val");
+// assertOnAllCachesAndOwnership(k1, "new_val");
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreNotSharedTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreNotSharedTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreNotSharedTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -21,161 +21,146 @@
*/
package org.infinispan.distribution;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.infinispan.Cache;
-import org.infinispan.commands.write.ClearCommand;
-import org.infinispan.commands.write.PutKeyValueCommand;
-import org.infinispan.commands.write.RemoveCommand;
-import org.infinispan.commands.write.ReplaceCommand;
-import org.infinispan.loaders.CacheLoaderManager;
-import org.infinispan.loaders.CacheStore;
-import org.infinispan.test.TestingUtil;
-import org.infinispan.util.logging.Log;
-import org.infinispan.util.logging.LogFactory;
-import org.testng.annotations.Test;
-
/**
* DistSyncSharedTest.
- *
+ *
* @author Galder Zamarreño
* @since 4.0
*/
- at Test(groups = "functional", testName = "distribution.DistSyncCacheStoreNotSharedTest", enabled = true)
+//@Test(groups = "functional", testName = "distribution.DistSyncCacheStoreNotSharedTest", enabled = true)
public class DistSyncCacheStoreNotSharedTest extends BaseDistCacheStoreTest {
- private static final Log log = LogFactory.getLog(DistSyncCacheStoreNotSharedTest.class);
-
- public DistSyncCacheStoreNotSharedTest() {
- sync = true;
- tx = false;
- testRetVals = true;
- shared = false;
- }
-
- public void testPutFromNonOwner() throws Exception {
- String key = "k2", value = "value2";
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- Cache<Object, String> nonOwner = getFirstNonOwner(key);
- CacheStore nonOwnerStore = TestingUtil.extractComponent(nonOwner, CacheLoaderManager.class).getCacheStore();
- assert !nonOwnerStore.containsKey(key);
- Object retval = nonOwner.put(key, value);
- asyncWait(key, PutKeyValueCommand.class, getSecondNonOwner(key));
- assert !nonOwnerStore.containsKey(key);
- if (testRetVals) assert retval == null;
- assertOnAllCachesAndOwnership(key, value);
- }
-
- public void testPutFromOwner() throws Exception {
- String key = "k3", value = "value3";
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- getOwners(key)[0].put(key, value);
- asyncWait(key, PutKeyValueCommand.class, getNonOwners(key));
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.containsKey(key);
- } else {
- assertIsNotInL1(c, key);
- assert !store.containsKey(key);
- }
- }
- }
-
- public void testPutAll() throws Exception {
- String k1 = "1", v1 = "one", k2 = "2", v2 = "two", k3 = "3", v3 = "three", k4 = "4", v4 = "four";
- String[] keys = new String[]{k1, k2, k3, k4};
- Map<String, String> data = new HashMap<String, String>();
- data.put(k1, v1);
- data.put(k2, v2);
- data.put(k3, v3);
- data.put(k4, v4);
-
- c1.putAll(data);
-
- for (String key : keys) {
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.containsKey(key);
- } else {
- assert !store.containsKey(key);
- }
- }
- }
- }
-
- public void testRemoveFromNonOwner() throws Exception {
- String key = "k1", value = "value";
- initAndTest();
-
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.load(key).getValue().equals(value);
- } else {
- assert !store.containsKey(key);
- }
- }
-
- Object retval = getFirstNonOwner(key).remove(key);
- asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
- if (testRetVals) assert "value".equals(retval);
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- assert !store.containsKey(key);
- }
- }
-
- public void testReplaceFromNonOwner() throws Exception {
- String key = "k1", value = "value", value2 = "v2";
- initAndTest();
-
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.load(key).getValue().equals(value);
- } else {
- assert !store.containsKey(key);
- }
- }
-
- Object retval = getFirstNonOwner(key).replace(key, value2);
- asyncWait(key, ReplaceCommand.class, getSecondNonOwner(key));
- if (testRetVals) assert value.equals(retval);
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.load(key).getValue().equals(value2);
- } else {
- assert !store.containsKey(key);
- }
- }
- }
-
- public void testClear() throws Exception {
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- for (int i = 0; i < 5; i++) {
- getOwners("k" + i)[0].put("k" + i, "value" + i);
- asyncWait("k" + i, PutKeyValueCommand.class, getNonOwners("k" + i));
- }
- // this will fill up L1 as well
- for (int i = 0; i < 5; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
- for (Cache<Object, String> c : caches) assert !c.isEmpty();
- c1.clear();
- asyncWait(null, ClearCommand.class);
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- for (int i = 0; i < 5; i++) {
- String key = "k" + i;
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- assert !store.containsKey(key);
- }
- }
- }
+// private static final Log log = LogFactory.getLog(DistSyncCacheStoreNotSharedTest.class);
+//
+// public DistSyncCacheStoreNotSharedTest() {
+// sync = true;
+// tx = false;
+// testRetVals = true;
+// shared = false;
+// }
+//
+// public void testPutFromNonOwner() throws Exception {
+// String key = "k2", value = "value2";
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// Cache<Object, String> nonOwner = getFirstNonOwner(key);
+// CacheStore nonOwnerStore = TestingUtil.extractComponent(nonOwner, CacheLoaderManager.class).getCacheStore();
+// assert !nonOwnerStore.containsKey(key);
+// Object retval = nonOwner.put(key, value);
+// asyncWait(key, PutKeyValueCommand.class, getSecondNonOwner(key));
+// assert !nonOwnerStore.containsKey(key);
+// if (testRetVals) assert retval == null;
+// assertOnAllCachesAndOwnership(key, value);
+// }
+//
+// public void testPutFromOwner() throws Exception {
+// String key = "k3", value = "value3";
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// getOwners(key)[0].put(key, value);
+// asyncWait(key, PutKeyValueCommand.class, getNonOwners(key));
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.containsKey(key);
+// } else {
+// assertIsNotInL1(c, key);
+// assert !store.containsKey(key);
+// }
+// }
+// }
+//
+// public void testPutAll() throws Exception {
+// String k1 = "1", v1 = "one", k2 = "2", v2 = "two", k3 = "3", v3 = "three", k4 = "4", v4 = "four";
+// String[] keys = new String[]{k1, k2, k3, k4};
+// Map<String, String> data = new HashMap<String, String>();
+// data.put(k1, v1);
+// data.put(k2, v2);
+// data.put(k3, v3);
+// data.put(k4, v4);
+//
+// c1.putAll(data);
+//
+// for (String key : keys) {
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.containsKey(key);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+// }
+// }
+//
+// public void testRemoveFromNonOwner() throws Exception {
+// String key = "k1", value = "value";
+// initAndTest();
+//
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.load(key).getValue().equals(value);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+//
+// Object retval = getFirstNonOwner(key).remove(key);
+// asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
+// if (testRetVals) assert "value".equals(retval);
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// assert !store.containsKey(key);
+// }
+// }
+//
+// public void testReplaceFromNonOwner() throws Exception {
+// String key = "k1", value = "value", value2 = "v2";
+// initAndTest();
+//
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.load(key).getValue().equals(value);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+//
+// Object retval = getFirstNonOwner(key).replace(key, value2);
+// asyncWait(key, ReplaceCommand.class, getSecondNonOwner(key));
+// if (testRetVals) assert value.equals(retval);
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.load(key).getValue().equals(value2);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+// }
+//
+// public void testClear() throws Exception {
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// for (int i = 0; i < 5; i++) {
+// getOwners("k" + i)[0].put("k" + i, "value" + i);
+// asyncWait("k" + i, PutKeyValueCommand.class, getNonOwners("k" + i));
+// }
+// // this will fill up L1 as well
+// for (int i = 0; i < 5; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
+// for (Cache<Object, String> c : caches) assert !c.isEmpty();
+// c1.clear();
+// asyncWait(null, ClearCommand.class);
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// for (int i = 0; i < 5; i++) {
+// String key = "k" + i;
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// assert !store.containsKey(key);
+// }
+// }
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreSharedTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreSharedTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSyncCacheStoreSharedTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -21,190 +21,177 @@
*/
package org.infinispan.distribution;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.infinispan.Cache;
-import org.infinispan.commands.write.ClearCommand;
-import org.infinispan.commands.write.PutKeyValueCommand;
-import org.infinispan.commands.write.RemoveCommand;
-import org.infinispan.commands.write.ReplaceCommand;
-import org.infinispan.loaders.CacheLoaderManager;
-import org.infinispan.loaders.CacheStore;
-import org.infinispan.test.TestingUtil;
-import org.testng.annotations.Test;
-
/**
* DistSyncCacheStoreSharedTest.
- *
+ *
* @author Galder Zamarreño
* @since 4.0
*/
- at Test(groups = "functional", testName = "distribution.DistSyncCacheStoreSharedTest", enabled = true)
+//@Test(groups = "functional", testName = "distribution.DistSyncCacheStoreSharedTest", enabled = true)
public class DistSyncCacheStoreSharedTest extends BaseDistCacheStoreTest {
- public DistSyncCacheStoreSharedTest() {
- sync = true;
- tx = false;
- testRetVals = true;
- shared = true;
- }
-
- public void testPutFromNonOwner() throws Exception {
- String key = "k4", value = "value4";
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- Cache<Object, String> nonOwner = getFirstNonOwner(key);
- CacheStore nonOwnerStore = TestingUtil.extractComponent(nonOwner, CacheLoaderManager.class).getCacheStore();
- assert !nonOwnerStore.containsKey(key);
- Object retval = nonOwner.put(key, value);
- asyncWait(key, PutKeyValueCommand.class, getSecondNonOwner(key));
-
- Cache[] owners = getOwners(key);
- CacheStore store = TestingUtil.extractComponent(owners[0], CacheLoaderManager.class).getCacheStore();
- assertIsInContainerImmortal(owners[0], key);
- assert store.containsKey(key);
-
- for (int i = 1; i < owners.length; i++) {
- store = TestingUtil.extractComponent(owners[i], CacheLoaderManager.class).getCacheStore();
- assertIsInContainerImmortal(owners[i], key);
- assert !store.containsKey(key);
- }
-
- for (Cache<Object, String> c : caches) {
- store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (!isOwner(c, key)) {
- assert !store.containsKey(key);
- }
- }
-
- if (testRetVals) assert retval == null;
- assertOnAllCachesAndOwnership(key, value);
- }
-
- public void testPutFromOwner() throws Exception {
- String key = "k5", value = "value5";
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- Cache[] owners = getOwners(key);
- Object retval = owners[0].put(key, value);
- asyncWait(key, PutKeyValueCommand.class, getNonOwners(key));
- CacheStore store = TestingUtil.extractComponent(owners[0], CacheLoaderManager.class).getCacheStore();
- assertIsInContainerImmortal(owners[0], key);
- assert store.containsKey(key);
-
- for (int i = 1; i < owners.length; i++) {
- store = TestingUtil.extractComponent(owners[i], CacheLoaderManager.class).getCacheStore();
- assertIsInContainerImmortal(owners[i], key);
- assert !store.containsKey(key);
- }
-
- for (Cache<Object, String> c : caches) {
- store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (!isOwner(c, key)) {
- assert !store.containsKey(key);
- }
- }
-
- if (testRetVals) assert retval == null;
- assertOnAllCachesAndOwnership(key, value);
- }
-
-
- public void testPutAll() throws Exception {
- String k1 = "1", v1 = "one", k2 = "2", v2 = "two", k3 = "3", v3 = "three", k4 = "4", v4 = "four";
- String[] keys = new String[]{k1, k2, k3, k4};
- Map<String, String> data = new HashMap<String, String>();
- data.put(k1, v1);
- data.put(k2, v2);
- data.put(k3, v3);
- data.put(k4, v4);
-
- c1.putAll(data);
-
- for (String key : keys) {
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isFirstOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.containsKey(key);
- } else {
- assert !store.containsKey(key);
- }
- }
- }
- }
-
- public void testRemoveFromNonOwner() throws Exception {
- String key = "k1", value = "value";
- initAndTest();
-
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isFirstOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.load(key).getValue().equals(value);
- } else {
- assert !store.containsKey(key);
- }
- }
-
- Object retval = getFirstNonOwner(key).remove(key);
- asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
- if (testRetVals) assert value.equals(retval);
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- assert !store.containsKey(key);
- }
- }
-
- public void testReplaceFromNonOwner() throws Exception {
- String key = "k1", value = "value", value2 = "v2";
- initAndTest();
-
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isFirstOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.load(key).getValue().equals(value);
- } else {
- assert !store.containsKey(key);
- }
- }
-
- Object retval = getFirstNonOwner(key).replace(key, value2);
- asyncWait(key, ReplaceCommand.class, getSecondNonOwner(key));
- if (testRetVals) assert value.equals(retval);
- for (Cache<Object, String> c : caches) {
- CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
- if (isFirstOwner(c, key)) {
- assertIsInContainerImmortal(c, key);
- assert store.load(key).getValue().equals(value2);
- } else {
- assert !store.containsKey(key);
- }
- }
- }
-
- public void testClear() throws Exception {
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- for (int i = 0; i < 5; i++) {
- getOwners("k" + i)[0].put("k" + i, "value" + i);
- asyncWait("k" + i, PutKeyValueCommand.class, getNonOwners("k" + i));
- }
- // this will fill up L1 as well
- for (int i = 0; i < 5; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
- for (Cache<Object, String> c : caches) assert !c.isEmpty();
- c1.clear();
- asyncWait(null, ClearCommand.class);
- for (Cache<Object, String> c : caches) assert c.isEmpty();
-
- /* We only check c1 because on a shared situation, no matter where the clear is called,
- * it should clear the whole store regardless. Bear in mind that in the test, even though
- * the cache store is shared, each cache has each own cache store, that allows for checking
- * who execute puts, removes...etc. */
- CacheStore store = TestingUtil.extractComponent(c1, CacheLoaderManager.class).getCacheStore();
- for (int i = 0; i < 5; i++) {
- String key = "k" + i;
- assert !store.containsKey(key);
- }
- }
+// public DistSyncCacheStoreSharedTest() {
+// sync = true;
+// tx = false;
+// testRetVals = true;
+// shared = true;
+// }
+//
+// public void testPutFromNonOwner() throws Exception {
+// String key = "k4", value = "value4";
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// Cache<Object, String> nonOwner = getFirstNonOwner(key);
+// CacheStore nonOwnerStore = TestingUtil.extractComponent(nonOwner, CacheLoaderManager.class).getCacheStore();
+// assert !nonOwnerStore.containsKey(key);
+// Object retval = nonOwner.put(key, value);
+// asyncWait(key, PutKeyValueCommand.class, getSecondNonOwner(key));
+//
+// Cache[] owners = getOwners(key);
+// CacheStore store = TestingUtil.extractComponent(owners[0], CacheLoaderManager.class).getCacheStore();
+// assertIsInContainerImmortal(owners[0], key);
+// assert store.containsKey(key);
+//
+// for (int i = 1; i < owners.length; i++) {
+// store = TestingUtil.extractComponent(owners[i], CacheLoaderManager.class).getCacheStore();
+// assertIsInContainerImmortal(owners[i], key);
+// assert !store.containsKey(key);
+// }
+//
+// for (Cache<Object, String> c : caches) {
+// store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (!isOwner(c, key)) {
+// assert !store.containsKey(key);
+// }
+// }
+//
+// if (testRetVals) assert retval == null;
+// assertOnAllCachesAndOwnership(key, value);
+// }
+//
+// public void testPutFromOwner() throws Exception {
+// String key = "k5", value = "value5";
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// Cache[] owners = getOwners(key);
+// Object retval = owners[0].put(key, value);
+// asyncWait(key, PutKeyValueCommand.class, getNonOwners(key));
+// CacheStore store = TestingUtil.extractComponent(owners[0], CacheLoaderManager.class).getCacheStore();
+// assertIsInContainerImmortal(owners[0], key);
+// assert store.containsKey(key);
+//
+// for (int i = 1; i < owners.length; i++) {
+// store = TestingUtil.extractComponent(owners[i], CacheLoaderManager.class).getCacheStore();
+// assertIsInContainerImmortal(owners[i], key);
+// assert !store.containsKey(key);
+// }
+//
+// for (Cache<Object, String> c : caches) {
+// store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (!isOwner(c, key)) {
+// assert !store.containsKey(key);
+// }
+// }
+//
+// if (testRetVals) assert retval == null;
+// assertOnAllCachesAndOwnership(key, value);
+// }
+//
+//
+// public void testPutAll() throws Exception {
+// String k1 = "1", v1 = "one", k2 = "2", v2 = "two", k3 = "3", v3 = "three", k4 = "4", v4 = "four";
+// String[] keys = new String[]{k1, k2, k3, k4};
+// Map<String, String> data = new HashMap<String, String>();
+// data.put(k1, v1);
+// data.put(k2, v2);
+// data.put(k3, v3);
+// data.put(k4, v4);
+//
+// c1.putAll(data);
+//
+// for (String key : keys) {
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isFirstOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.containsKey(key);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+// }
+// }
+//
+// public void testRemoveFromNonOwner() throws Exception {
+// String key = "k1", value = "value";
+// initAndTest();
+//
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isFirstOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.load(key).getValue().equals(value);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+//
+// Object retval = getFirstNonOwner(key).remove(key);
+// asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
+// if (testRetVals) assert value.equals(retval);
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// assert !store.containsKey(key);
+// }
+// }
+//
+// public void testReplaceFromNonOwner() throws Exception {
+// String key = "k1", value = "value", value2 = "v2";
+// initAndTest();
+//
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isFirstOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.load(key).getValue().equals(value);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+//
+// Object retval = getFirstNonOwner(key).replace(key, value2);
+// asyncWait(key, ReplaceCommand.class, getSecondNonOwner(key));
+// if (testRetVals) assert value.equals(retval);
+// for (Cache<Object, String> c : caches) {
+// CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
+// if (isFirstOwner(c, key)) {
+// assertIsInContainerImmortal(c, key);
+// assert store.load(key).getValue().equals(value2);
+// } else {
+// assert !store.containsKey(key);
+// }
+// }
+// }
+//
+// public void testClear() throws Exception {
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// for (int i = 0; i < 5; i++) {
+// getOwners("k" + i)[0].put("k" + i, "value" + i);
+// asyncWait("k" + i, PutKeyValueCommand.class, getNonOwners("k" + i));
+// }
+// // this will fill up L1 as well
+// for (int i = 0; i < 5; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
+// for (Cache<Object, String> c : caches) assert !c.isEmpty();
+// c1.clear();
+// asyncWait(null, ClearCommand.class);
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+//
+// /* We only check c1 because on a shared situation, no matter where the clear is called,
+// * it should clear the whole store regardless. Bear in mind that in the test, even though
+// * the cache store is shared, each cache has each own cache store, that allows for checking
+// * who execute puts, removes...etc. */
+// CacheStore store = TestingUtil.extractComponent(c1, CacheLoaderManager.class).getCacheStore();
+// for (int i = 0; i < 5; i++) {
+// String key = "k" + i;
+// assert !store.containsKey(key);
+// }
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSyncFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSyncFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSyncFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,198 +1,185 @@
package org.infinispan.distribution;
-import org.infinispan.Cache;
-import org.infinispan.commands.write.ClearCommand;
-import org.infinispan.commands.write.PutKeyValueCommand;
-import org.infinispan.commands.write.RemoveCommand;
-import org.infinispan.commands.write.ReplaceCommand;
-import org.infinispan.test.TestingUtil;
-import org.infinispan.util.ObjectDuplicator;
-import org.testng.annotations.Test;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
- at Test(groups = "functional", testName = "distribution.DistSyncFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistSyncFuncTest", enabled = false)
public class DistSyncFuncTest extends BaseDistFunctionalTest {
- public DistSyncFuncTest() {
- sync = true;
- tx = false;
- testRetVals = true;
- }
-
- public void testBasicDistribution() {
- for (Cache<Object, String> c : caches) assert c.isEmpty();
-
- getOwners("k1")[0].put("k1", "value");
-
- asyncWait("k1", PutKeyValueCommand.class, getNonOwners("k1"));
-
- for (Cache<Object, String> c : caches) {
- if (isOwner(c, "k1")) {
- assertIsInContainerImmortal(c, "k1");
- } else {
- assertIsNotInL1(c, "k1");
- }
- }
-
- // should be available everywhere!
- assertOnAllCachesAndOwnership("k1", "value");
-
- // and should now be in L1
-
- for (Cache<Object, String> c : caches) {
- if (isOwner(c, "k1")) {
- assertIsInContainerImmortal(c, "k1");
- } else {
- assertIsInL1(c, "k1");
- }
- }
- }
-
- public void testPutFromNonOwner() {
- initAndTest();
- Cache<Object, String> nonOwner = getFirstNonOwner("k1");
-
- Object retval = nonOwner.put("k1", "value2");
- asyncWait("k1", PutKeyValueCommand.class, getSecondNonOwner("k1"));
-
- if (testRetVals) assert "value".equals(retval);
- assertOnAllCachesAndOwnership("k1", "value2");
- }
-
- public void testPutIfAbsentFromNonOwner() {
- initAndTest();
- Object retval = getFirstNonOwner("k1").putIfAbsent("k1", "value2");
-
- if (testRetVals) assert "value".equals(retval);
-
- assertOnAllCachesAndOwnership("k1", "value");
-
- c1.clear();
- asyncWait(null, ClearCommand.class);
-
- retval = getFirstNonOwner("k1").putIfAbsent("k1", "value2");
- asyncWait("k1", PutKeyValueCommand.class, getSecondNonOwner("k1"));
- if (testRetVals) assert null == retval;
-
- assertOnAllCachesAndOwnership("k1", "value2");
- }
-
- public void testRemoveFromNonOwner() {
- initAndTest();
- Object retval = getFirstNonOwner("k1").remove("k1");
- asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
- if (testRetVals) assert "value".equals(retval);
-
- assertOnAllCachesAndOwnership("k1", null);
- }
-
- public void testConditionalRemoveFromNonOwner() {
- initAndTest();
- boolean retval = getFirstNonOwner("k1").remove("k1", "value2");
- if (testRetVals) assert !retval : "Should not have removed entry";
-
- assertOnAllCachesAndOwnership("k1", "value");
-
- assert caches.get(1).get("k1").equals("value");
-
- Cache<Object, String> owner = getFirstNonOwner("k1");
-
- retval = owner.remove("k1", "value");
- asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
- if (testRetVals) assert retval : "Should have removed entry";
-
- assert caches.get(1).get("k1") == null: "expected null but received " + caches.get(1).get("k1");
- assertOnAllCachesAndOwnership("k1", null);
- }
-
- public void testReplaceFromNonOwner() {
- initAndTest();
- Object retval = getFirstNonOwner("k1").replace("k1", "value2");
- if (testRetVals) assert "value".equals(retval);
-
- asyncWait("k1", ReplaceCommand.class, getSecondNonOwner("k1"));
-
- assertOnAllCachesAndOwnership("k1", "value2");
-
- c1.clear();
- asyncWait(null, ClearCommand.class);
-
- retval = getFirstNonOwner("k1").replace("k1", "value2");
- if (testRetVals) assert retval == null;
-
- assertOnAllCachesAndOwnership("k1", null);
- }
-
- public void testConditionalReplaceFromNonOwner() {
- initAndTest();
- Cache<Object, String> nonOwner = getFirstNonOwner("k1");
- boolean retval = nonOwner.replace("k1", "valueX", "value2");
- if (testRetVals) assert !retval : "Should not have replaced";
-
- assertOnAllCachesAndOwnership("k1", "value");
-
- assert !nonOwner.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class).isLocal("k1");
- retval = nonOwner.replace("k1", "value", "value2");
- asyncWait("k1", ReplaceCommand.class, getSecondNonOwner("k1"));
- if (testRetVals) assert retval : "Should have replaced";
-
- assertOnAllCachesAndOwnership("k1", "value2");
- }
-
- public void testClear() {
- for (Cache<Object, String> c : caches) assert c.isEmpty();
-
- for (int i = 0; i < 10; i++) {
- getOwners("k" + i)[0].put("k" + i, "value" + i);
- asyncWait("k" + i, PutKeyValueCommand.class, getNonOwners("k" + i));
- }
-
- // this will fill up L1 as well
- for (int i = 0; i < 10; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
-
- for (Cache<Object, String> c : caches) assert !c.isEmpty();
-
- c1.clear();
- asyncWait(null, ClearCommand.class);
-
- for (Cache<Object, String> c : caches) assert c.isEmpty();
- }
-
- public void testKeyValueEntryCollections() {
- c1.put("1", "one");
- asyncWait("1", PutKeyValueCommand.class, getNonOwnersExcludingSelf("1", addressOf(c1)));
- c2.put("2", "two");
- asyncWait("2", PutKeyValueCommand.class, getNonOwnersExcludingSelf("2", addressOf(c2)));
- c3.put("3", "three");
- asyncWait("3", PutKeyValueCommand.class, getNonOwnersExcludingSelf("3", addressOf(c3)));
- c4.put("4", "four");
- asyncWait("4", PutKeyValueCommand.class, getNonOwnersExcludingSelf("4", addressOf(c4)));
-
- for (Cache c : caches) {
- Set expKeys = TestingUtil.getInternalKeys(c);
- Collection expValues = TestingUtil.getInternalValues(c);
-
- Set expKeyEntries = ObjectDuplicator.duplicateSet(expKeys);
- Collection expValueEntries = ObjectDuplicator.duplicateCollection(expValues);
-
- Set keys = c.keySet();
- for (Object key : keys) assert expKeys.remove(key);
- assert expKeys.isEmpty() : "Did not see keys " + expKeys + " in iterator!";
-
- Collection values = c.values();
- for (Object value : values) assert expValues.remove(value);
- assert expValues.isEmpty() : "Did not see keys " + expValues + " in iterator!";
-
- Set<Map.Entry> entries = c.entrySet();
- for (Map.Entry entry : entries) {
- assert expKeyEntries.remove(entry.getKey());
- assert expValueEntries.remove(entry.getValue());
- }
- assert expKeyEntries.isEmpty() : "Did not see keys " + expKeyEntries + " in iterator!";
- assert expValueEntries.isEmpty() : "Did not see keys " + expValueEntries + " in iterator!";
- }
- }
+// public DistSyncFuncTest() {
+// sync = true;
+// tx = false;
+// testRetVals = true;
+// }
+//
+// public void testBasicDistribution() {
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+//
+// getOwners("k1")[0].put("k1", "value");
+//
+// asyncWait("k1", PutKeyValueCommand.class, getNonOwners("k1"));
+//
+// for (Cache<Object, String> c : caches) {
+// if (isOwner(c, "k1")) {
+// assertIsInContainerImmortal(c, "k1");
+// } else {
+// assertIsNotInL1(c, "k1");
+// }
+// }
+//
+// // should be available everywhere!
+// assertOnAllCachesAndOwnership("k1", "value");
+//
+// // and should now be in L1
+//
+// for (Cache<Object, String> c : caches) {
+// if (isOwner(c, "k1")) {
+// assertIsInContainerImmortal(c, "k1");
+// } else {
+// assertIsInL1(c, "k1");
+// }
+// }
+// }
+//
+// public void testPutFromNonOwner() {
+// initAndTest();
+// Cache<Object, String> nonOwner = getFirstNonOwner("k1");
+//
+// Object retval = nonOwner.put("k1", "value2");
+// asyncWait("k1", PutKeyValueCommand.class, getSecondNonOwner("k1"));
+//
+// if (testRetVals) assert "value".equals(retval);
+// assertOnAllCachesAndOwnership("k1", "value2");
+// }
+//
+// public void testPutIfAbsentFromNonOwner() {
+// initAndTest();
+// Object retval = getFirstNonOwner("k1").putIfAbsent("k1", "value2");
+//
+// if (testRetVals) assert "value".equals(retval);
+//
+// assertOnAllCachesAndOwnership("k1", "value");
+//
+// c1.clear();
+// asyncWait(null, ClearCommand.class);
+//
+// retval = getFirstNonOwner("k1").putIfAbsent("k1", "value2");
+// asyncWait("k1", PutKeyValueCommand.class, getSecondNonOwner("k1"));
+// if (testRetVals) assert null == retval;
+//
+// assertOnAllCachesAndOwnership("k1", "value2");
+// }
+//
+// public void testRemoveFromNonOwner() {
+// initAndTest();
+// Object retval = getFirstNonOwner("k1").remove("k1");
+// asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
+// if (testRetVals) assert "value".equals(retval);
+//
+// assertOnAllCachesAndOwnership("k1", null);
+// }
+//
+// public void testConditionalRemoveFromNonOwner() {
+// initAndTest();
+// boolean retval = getFirstNonOwner("k1").remove("k1", "value2");
+// if (testRetVals) assert !retval : "Should not have removed entry";
+//
+// assertOnAllCachesAndOwnership("k1", "value");
+//
+// assert caches.get(1).get("k1").equals("value");
+//
+// Cache<Object, String> owner = getFirstNonOwner("k1");
+//
+// retval = owner.remove("k1", "value");
+// asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
+// if (testRetVals) assert retval : "Should have removed entry";
+//
+// assert caches.get(1).get("k1") == null: "expected null but received " + caches.get(1).get("k1");
+// assertOnAllCachesAndOwnership("k1", null);
+// }
+//
+// public void testReplaceFromNonOwner() {
+// initAndTest();
+// Object retval = getFirstNonOwner("k1").replace("k1", "value2");
+// if (testRetVals) assert "value".equals(retval);
+//
+// asyncWait("k1", ReplaceCommand.class, getSecondNonOwner("k1"));
+//
+// assertOnAllCachesAndOwnership("k1", "value2");
+//
+// c1.clear();
+// asyncWait(null, ClearCommand.class);
+//
+// retval = getFirstNonOwner("k1").replace("k1", "value2");
+// if (testRetVals) assert retval == null;
+//
+// assertOnAllCachesAndOwnership("k1", null);
+// }
+//
+// public void testConditionalReplaceFromNonOwner() {
+// initAndTest();
+// Cache<Object, String> nonOwner = getFirstNonOwner("k1");
+// boolean retval = nonOwner.replace("k1", "valueX", "value2");
+// if (testRetVals) assert !retval : "Should not have replaced";
+//
+// assertOnAllCachesAndOwnership("k1", "value");
+//
+// assert !nonOwner.getAdvancedCache().getComponentRegistry().getComponent(DistributionManager.class).isLocal("k1");
+// retval = nonOwner.replace("k1", "value", "value2");
+// asyncWait("k1", ReplaceCommand.class, getSecondNonOwner("k1"));
+// if (testRetVals) assert retval : "Should have replaced";
+//
+// assertOnAllCachesAndOwnership("k1", "value2");
+// }
+//
+// public void testClear() {
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+//
+// for (int i = 0; i < 10; i++) {
+// getOwners("k" + i)[0].put("k" + i, "value" + i);
+// asyncWait("k" + i, PutKeyValueCommand.class, getNonOwners("k" + i));
+// }
+//
+// // this will fill up L1 as well
+// for (int i = 0; i < 10; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
+//
+// for (Cache<Object, String> c : caches) assert !c.isEmpty();
+//
+// c1.clear();
+// asyncWait(null, ClearCommand.class);
+//
+// for (Cache<Object, String> c : caches) assert c.isEmpty();
+// }
+//
+// public void testKeyValueEntryCollections() {
+// c1.put("1", "one");
+// asyncWait("1", PutKeyValueCommand.class, getNonOwnersExcludingSelf("1", addressOf(c1)));
+// c2.put("2", "two");
+// asyncWait("2", PutKeyValueCommand.class, getNonOwnersExcludingSelf("2", addressOf(c2)));
+// c3.put("3", "three");
+// asyncWait("3", PutKeyValueCommand.class, getNonOwnersExcludingSelf("3", addressOf(c3)));
+// c4.put("4", "four");
+// asyncWait("4", PutKeyValueCommand.class, getNonOwnersExcludingSelf("4", addressOf(c4)));
+//
+// for (Cache c : caches) {
+// Set expKeys = TestingUtil.getInternalKeys(c);
+// Collection expValues = TestingUtil.getInternalValues(c);
+//
+// Set expKeyEntries = ObjectDuplicator.duplicateSet(expKeys);
+// Collection expValueEntries = ObjectDuplicator.duplicateCollection(expValues);
+//
+// Set keys = c.keySet();
+// for (Object key : keys) assert expKeys.remove(key);
+// assert expKeys.isEmpty() : "Did not see keys " + expKeys + " in iterator!";
+//
+// Collection values = c.values();
+// for (Object value : values) assert expValues.remove(value);
+// assert expValues.isEmpty() : "Did not see keys " + expValues + " in iterator!";
+//
+// Set<Map.Entry> entries = c.entrySet();
+// for (Map.Entry entry : entries) {
+// assert expKeyEntries.remove(entry.getKey());
+// assert expValueEntries.remove(entry.getValue());
+// }
+// assert expKeyEntries.isEmpty() : "Did not see keys " + expKeyEntries + " in iterator!";
+// assert expValueEntries.isEmpty() : "Did not see keys " + expValueEntries + " in iterator!";
+// }
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,336 +1,328 @@
package org.infinispan.distribution;
-import org.infinispan.Cache;
-import org.infinispan.commands.write.PutKeyValueCommand;
-import org.infinispan.test.TestingUtil;
-import org.infinispan.util.concurrent.locks.LockManager;
-import org.testng.annotations.Test;
-
-import javax.transaction.TransactionManager;
-
- at Test(groups = "functional", testName = "distribution.DistSyncTxFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistSyncTxFuncTest", enabled = false)
public class DistSyncTxFuncTest extends BaseDistFunctionalTest {
- public DistSyncTxFuncTest() {
- sync = true;
- tx = true;
- testRetVals = true;
- cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
- }
-
- protected void asyncTxWait(Object... keys) {
- // no op. Meant to be overridden
- }
-
- protected void init(MagicKey k1, MagicKey k2) {
- // neither key maps on to c4
- c2.put(k1, "value1");
- asyncWait(k1, PutKeyValueCommand.class, c1, c3, c4);
-
- c2.put(k2, "value2");
- asyncWait(k2, PutKeyValueCommand.class, c1, c3, c4);
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
- }
-
- public void testTransactionsSpanningKeysCommit() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- // now test a transaction that spans both keys.
- TransactionManager tm4 = getTransactionManager(c4);
- asserLocked(c3, false, k1);
- tm4.begin();
- c4.put(k1, "new_value1");
- c4.put(k2, "new_value2");
- tm4.commit();
-
- asyncTxWait("new_value1","new_value2");
-
- asserLocked(c3, false, k1);
- asserLocked(c3, false, k2);
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsInL1(c4, k1);
- assertIsInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- asserLocked(c4, false, k1, k2);
- asserLocked(c3, false, k1);
- asserLocked(c3, false, k2);
- asserLocked(c1, false, k1, k2);
- asserLocked(c2, false, k1, k2);
- checkOwnership(k1, k2, "new_value1", "new_value2");
- }
-
- void asserLocked(Cache c, boolean isLocked, Object... keys) {
- LockManager lm = TestingUtil.extractComponent(c, LockManager.class);
- for (Object key : keys) {
- assert isLocked == lm.isLocked(key) : " expecting key '" + key + "' to be " + (isLocked ? " locked " :
- "not locked + \n Lock owner is:" + lm.getOwner(key));
- }
- }
-
- protected void checkOwnership(MagicKey k1, MagicKey k2, String v1, String v2) {
- assertOnAllCachesAndOwnership(k1, v1);
- assertOnAllCachesAndOwnership(k2, v2);
-
- assertIsInL1(c4, k1);
- assertIsInL1(c4, k2);
- assertIsInL1(c1, k2);
- assertIsInL1(c3, k1);
- }
-
- public void testTransactionsSpanningKeysRollback() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- // now test a transaction that spans both keys.
- TransactionManager tm4 = getTransactionManager(c4);
- tm4.begin();
- c4.put(k1, "new_value1");
- c4.put(k2, "new_value2");
- tm4.rollback();
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- checkOwnership(k1, k2, "value1", "value2");
- }
-
- public void testPutFromNonOwner() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- TransactionManager tm4 = getTransactionManager(c4);
- tm4.begin();
- Object ret = c4.put(k1, "new_value");
- if (testRetVals) assert "value1".equals(ret);
- ret = c4.put(k2, "new_value");
- if (testRetVals) assert "value2".equals(ret);
- tm4.rollback();
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- checkOwnership(k1, k2, "value1", "value2");
- }
-
- public void testPutIfAbsentFromNonOwner() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- TransactionManager tm4 = getTransactionManager(c4);
- LockManager lockManager4 = TestingUtil.extractComponent(c4, LockManager.class);
-
- tm4.begin();
- Object ret = c4.putIfAbsent(k1, "new_value");
- if (testRetVals) assert "value1".equals(ret) : "Was expecting value1 but was " + ret;
- ret = c4.putIfAbsent(k2, "new_value");
- if (testRetVals) assert "value2".equals(ret) : "Was expecting value2 but was " + ret;
-
- assert c4.get(k1).equals("value1");
- assert c4.get(k2).equals("value2");
-
- assert lockManager4.isLocked(k1);
- assert lockManager4.isLocked(k2);
-
- tm4.rollback();
-
- assert !lockManager4.isLocked(k1);
- assert !lockManager4.isLocked(k2);
-
- assert c2.get(k1).equals("value1");
- assert c2.get(k2).equals("value2");
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- checkOwnership(k1, k2, "value1", "value2");
- }
-
- public void testRemoveFromNonOwner() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- TransactionManager tm4 = getTransactionManager(c4);
- tm4.begin();
- Object ret = c4.remove(k1);
- if (testRetVals) assert "value1".equals(ret);
- ret = c4.remove(k2);
- if (testRetVals) assert "value2".equals(ret);
-
- assert !c4.containsKey(k1);
- assert !c4.containsKey(k2);
- tm4.rollback();
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- checkOwnership(k1, k2, "value1", "value2");
- }
-
- public void testConditionalRemoveFromNonOwner() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- TransactionManager tm4 = getTransactionManager(c4);
- tm4.begin();
- boolean ret = c4.remove(k1, "valueX");
- if (testRetVals) assert !ret;
- ret = c4.remove(k2, "valueX");
- if (testRetVals) assert !ret;
-
- assert c4.containsKey(k1);
- assert c4.containsKey(k2);
-
- ret = c4.remove(k1, "value1");
- if (testRetVals) assert ret;
- ret = c4.remove(k2, "value2");
- if (testRetVals) assert ret;
-
- assert !c4.containsKey(k1);
- assert !c4.containsKey(k2);
- tm4.rollback();
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- checkOwnership(k1, k2, "value1", "value2");
- }
-
- public void testReplaceFromNonOwner() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- TransactionManager tm4 = getTransactionManager(c4);
- tm4.begin();
- Object ret = c4.replace(k1, "new_value");
- if (testRetVals) assert "value1".equals(ret);
- ret = c4.replace(k2, "new_value");
- if (testRetVals) assert "value2".equals(ret);
-
- assert "new_value".equals(c4.get(k1));
- assert "new_value".equals(c4.get(k2));
- tm4.rollback();
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- checkOwnership(k1, k2, "value1", "value2");
- }
-
- public void testConditionalReplaceFromNonOwner() throws Exception {
- // we need 2 keys that reside on different caches...
- MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
- MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
-
- init(k1, k2);
-
- TransactionManager tm4 = getTransactionManager(c4);
- tm4.begin();
- boolean ret = c4.replace(k1, "valueX", "new_value");
- if (testRetVals) assert !ret;
- ret = c4.replace(k2, "valueX", "new_value");
- if (testRetVals) assert !ret;
-
- assert "value1".equals(c4.get(k1));
- assert "value2".equals(c4.get(k2));
-
- ret = c4.replace(k1, "value1", "new_value");
- if (testRetVals) assert ret;
- ret = c4.replace(k2, "value2", "new_value");
- if (testRetVals) assert ret;
-
- assert "new_value".equals(c4.get(k1));
- assert "new_value".equals(c4.get(k2));
- tm4.rollback();
-
- assertIsInContainerImmortal(c1, k1);
- assertIsInContainerImmortal(c2, k1);
- assertIsInContainerImmortal(c2, k2);
- assertIsInContainerImmortal(c3, k2);
-
- assertIsNotInL1(c4, k1);
- assertIsNotInL1(c4, k2);
- assertIsNotInL1(c1, k2);
- assertIsNotInL1(c3, k1);
-
- checkOwnership(k1, k2, "value1", "value2");
- }
+// public DistSyncTxFuncTest() {
+// sync = true;
+// tx = true;
+// testRetVals = true;
+// cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
+// }
+//
+// protected void asyncTxWait(Object... keys) {
+// // no op. Meant to be overridden
+// }
+//
+// protected void init(MagicKey k1, MagicKey k2) {
+// // neither key maps on to c4
+// c2.put(k1, "value1");
+// asyncWait(k1, PutKeyValueCommand.class, c1, c3, c4);
+//
+// c2.put(k2, "value2");
+// asyncWait(k2, PutKeyValueCommand.class, c1, c3, c4);
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+// }
+//
+// public void testTransactionsSpanningKeysCommit() throws Exception {
+ // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// // now test a transaction that spans both keys.
+// TransactionManager tm4 = getTransactionManager(c4);
+// asserLocked(c3, false, k1);
+// tm4.begin();
+// c4.put(k1, "new_value1");
+// c4.put(k2, "new_value2");
+// tm4.commit();
+//
+// asyncTxWait("new_value1","new_value2");
+//
+// asserLocked(c3, false, k1);
+// asserLocked(c3, false, k2);
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsInL1(c4, k1);
+// assertIsInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// asserLocked(c4, false, k1, k2);
+// asserLocked(c3, false, k1);
+// asserLocked(c3, false, k2);
+// asserLocked(c1, false, k1, k2);
+// asserLocked(c2, false, k1, k2);
+// checkOwnership(k1, k2, "new_value1", "new_value2");
+// }
+//
+// void asserLocked(Cache c, boolean isLocked, Object... keys) {
+// LockManager lm = TestingUtil.extractComponent(c, LockManager.class);
+// for (Object key : keys) {
+// assert isLocked == lm.isLocked(key) : " expecting key '" + key + "' to be " + (isLocked ? " locked " :
+// "not locked + \n Lock owner is:" + lm.getOwner(key));
+// }
+// }
+//
+// protected void checkOwnership(MagicKey k1, MagicKey k2, String v1, String v2) {
+// assertOnAllCachesAndOwnership(k1, v1);
+// assertOnAllCachesAndOwnership(k2, v2);
+//
+// assertIsInL1(c4, k1);
+// assertIsInL1(c4, k2);
+// assertIsInL1(c1, k2);
+// assertIsInL1(c3, k1);
+// }
+//
+// public void testTransactionsSpanningKeysRollback() throws Exception {
+// // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// // now test a transaction that spans both keys.
+// TransactionManager tm4 = getTransactionManager(c4);
+// tm4.begin();
+// c4.put(k1, "new_value1");
+// c4.put(k2, "new_value2");
+// tm4.rollback();
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// checkOwnership(k1, k2, "value1", "value2");
+// }
+//
+// public void testPutFromNonOwner() throws Exception {
+// // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// TransactionManager tm4 = getTransactionManager(c4);
+// tm4.begin();
+// Object ret = c4.put(k1, "new_value");
+// if (testRetVals) assert "value1".equals(ret);
+// ret = c4.put(k2, "new_value");
+// if (testRetVals) assert "value2".equals(ret);
+// tm4.rollback();
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// checkOwnership(k1, k2, "value1", "value2");
+// }
+//
+// public void testPutIfAbsentFromNonOwner() throws Exception {
+// // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// TransactionManager tm4 = getTransactionManager(c4);
+// LockManager lockManager4 = TestingUtil.extractComponent(c4, LockManager.class);
+//
+// tm4.begin();
+// Object ret = c4.putIfAbsent(k1, "new_value");
+// if (testRetVals) assert "value1".equals(ret) : "Was expecting value1 but was " + ret;
+// ret = c4.putIfAbsent(k2, "new_value");
+// if (testRetVals) assert "value2".equals(ret) : "Was expecting value2 but was " + ret;
+//
+// assert c4.get(k1).equals("value1");
+// assert c4.get(k2).equals("value2");
+//
+// assert lockManager4.isLocked(k1);
+// assert lockManager4.isLocked(k2);
+//
+// tm4.rollback();
+//
+// assert !lockManager4.isLocked(k1);
+// assert !lockManager4.isLocked(k2);
+//
+// assert c2.get(k1).equals("value1");
+// assert c2.get(k2).equals("value2");
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// checkOwnership(k1, k2, "value1", "value2");
+// }
+//
+// public void testRemoveFromNonOwner() throws Exception {
+// // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// TransactionManager tm4 = getTransactionManager(c4);
+// tm4.begin();
+// Object ret = c4.remove(k1);
+// if (testRetVals) assert "value1".equals(ret);
+// ret = c4.remove(k2);
+// if (testRetVals) assert "value2".equals(ret);
+//
+// assert !c4.containsKey(k1);
+// assert !c4.containsKey(k2);
+// tm4.rollback();
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// checkOwnership(k1, k2, "value1", "value2");
+// }
+//
+// public void testConditionalRemoveFromNonOwner() throws Exception {
+// // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// TransactionManager tm4 = getTransactionManager(c4);
+// tm4.begin();
+// boolean ret = c4.remove(k1, "valueX");
+// if (testRetVals) assert !ret;
+// ret = c4.remove(k2, "valueX");
+// if (testRetVals) assert !ret;
+//
+// assert c4.containsKey(k1);
+// assert c4.containsKey(k2);
+//
+// ret = c4.remove(k1, "value1");
+// if (testRetVals) assert ret;
+// ret = c4.remove(k2, "value2");
+// if (testRetVals) assert ret;
+//
+// assert !c4.containsKey(k1);
+// assert !c4.containsKey(k2);
+// tm4.rollback();
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// checkOwnership(k1, k2, "value1", "value2");
+// }
+//
+// public void testReplaceFromNonOwner() throws Exception {
+// // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// TransactionManager tm4 = getTransactionManager(c4);
+// tm4.begin();
+// Object ret = c4.replace(k1, "new_value");
+// if (testRetVals) assert "value1".equals(ret);
+// ret = c4.replace(k2, "new_value");
+// if (testRetVals) assert "value2".equals(ret);
+//
+// assert "new_value".equals(c4.get(k1));
+// assert "new_value".equals(c4.get(k2));
+// tm4.rollback();
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// checkOwnership(k1, k2, "value1", "value2");
+// }
+//
+// public void testConditionalReplaceFromNonOwner() throws Exception {
+// // we need 2 keys that reside on different caches...
+// MagicKey k1 = new MagicKey(c1); // maps on to c1 and c2
+// MagicKey k2 = new MagicKey(c2); // maps on to c2 and c3
+//
+// init(k1, k2);
+//
+// TransactionManager tm4 = getTransactionManager(c4);
+// tm4.begin();
+// boolean ret = c4.replace(k1, "valueX", "new_value");
+// if (testRetVals) assert !ret;
+// ret = c4.replace(k2, "valueX", "new_value");
+// if (testRetVals) assert !ret;
+//
+// assert "value1".equals(c4.get(k1));
+// assert "value2".equals(c4.get(k2));
+//
+// ret = c4.replace(k1, "value1", "new_value");
+// if (testRetVals) assert ret;
+// ret = c4.replace(k2, "value2", "new_value");
+// if (testRetVals) assert ret;
+//
+// assert "new_value".equals(c4.get(k1));
+// assert "new_value".equals(c4.get(k2));
+// tm4.rollback();
+//
+// assertIsInContainerImmortal(c1, k1);
+// assertIsInContainerImmortal(c2, k1);
+// assertIsInContainerImmortal(c2, k2);
+// assertIsInContainerImmortal(c3, k2);
+//
+// assertIsNotInL1(c4, k1);
+// assertIsNotInL1(c4, k2);
+// assertIsNotInL1(c1, k2);
+// assertIsNotInL1(c3, k1);
+//
+// checkOwnership(k1, k2, "value1", "value2");
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxUnsafeFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxUnsafeFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxUnsafeFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,13 +1,11 @@
package org.infinispan.distribution;
-import org.testng.annotations.Test;
-
- at Test(groups = "functional", testName = "distribution.DistSyncTxUnsafeFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistSyncTxUnsafeFuncTest", enabled = false)
public class DistSyncTxUnsafeFuncTest extends DistSyncTxFuncTest {
- public DistSyncTxUnsafeFuncTest() {
- sync = true;
- tx = true;
- testRetVals = false;
- cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
- }
+// public DistSyncTxUnsafeFuncTest() {
+// sync = true;
+// tx = true;
+// testRetVals = false;
+// cleanup = CleanupPhase.AFTER_METHOD; // ensure any stale TXs are wiped
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSyncUnsafeFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSyncUnsafeFuncTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSyncUnsafeFuncTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,12 +1,10 @@
package org.infinispan.distribution;
-import org.testng.annotations.Test;
-
- at Test(groups = "functional", testName = "distribution.DistSyncUnsafeFuncTest", enabled = false)
+//@Test(groups = "functional", testName = "distribution.DistSyncUnsafeFuncTest", enabled = false)
public class DistSyncUnsafeFuncTest extends DistSyncFuncTest {
- public DistSyncUnsafeFuncTest() {
- sync = true;
- tx = false;
- testRetVals = false;
- }
+// public DistSyncUnsafeFuncTest() {
+// sync = true;
+// tx = false;
+// testRetVals = false;
+// }
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/MagicKeyTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/MagicKeyTest.java 2009-07-13 08:33:03 UTC (rev 553)
+++ trunk/core/src/test/java/org/infinispan/distribution/MagicKeyTest.java 2009-07-13 09:37:27 UTC (rev 554)
@@ -1,33 +1,30 @@
package org.infinispan.distribution;
-import org.testng.annotations.Test;
-
-
- at Test(groups = "unit", testName = "distribution.MagicKeyTest", enabled = false)
+//@Test(groups = "unit", testName = "distribution.MagicKeyTest", enabled = false)
public class MagicKeyTest extends BaseDistFunctionalTest {
- public void testMagicKeys() {
- BaseDistFunctionalTest.MagicKey k1 = new BaseDistFunctionalTest.MagicKey(c1);
- assert getDistributionManager(c1).isLocal(k1);
- assert getDistributionManager(c2).isLocal(k1);
- assert !getDistributionManager(c3).isLocal(k1);
- assert !getDistributionManager(c4).isLocal(k1);
-
- BaseDistFunctionalTest.MagicKey k2 = new BaseDistFunctionalTest.MagicKey(c2);
- assert !getDistributionManager(c1).isLocal(k2);
- assert getDistributionManager(c2).isLocal(k2);
- assert getDistributionManager(c3).isLocal(k2);
- assert !getDistributionManager(c4).isLocal(k2);
-
- BaseDistFunctionalTest.MagicKey k3 = new BaseDistFunctionalTest.MagicKey(c3);
- assert !getDistributionManager(c1).isLocal(k3);
- assert !getDistributionManager(c2).isLocal(k3);
- assert getDistributionManager(c3).isLocal(k3);
- assert getDistributionManager(c4).isLocal(k3);
-
- BaseDistFunctionalTest.MagicKey k4 = new BaseDistFunctionalTest.MagicKey(c4);
- assert getDistributionManager(c1).isLocal(k4);
- assert !getDistributionManager(c2).isLocal(k4);
- assert !getDistributionManager(c3).isLocal(k4);
- assert getDistributionManager(c4).isLocal(k4);
- }
+// public void testMagicKeys() {
+// BaseDistFunctionalTest.MagicKey k1 = new BaseDistFunctionalTest.MagicKey(c1);
+// assert getDistributionManager(c1).isLocal(k1);
+// assert getDistributionManager(c2).isLocal(k1);
+// assert !getDistributionManager(c3).isLocal(k1);
+// assert !getDistributionManager(c4).isLocal(k1);
+//
+// BaseDistFunctionalTest.MagicKey k2 = new BaseDistFunctionalTest.MagicKey(c2);
+// assert !getDistributionManager(c1).isLocal(k2);
+// assert getDistributionManager(c2).isLocal(k2);
+// assert getDistributionManager(c3).isLocal(k2);
+// assert !getDistributionManager(c4).isLocal(k2);
+//
+// BaseDistFunctionalTest.MagicKey k3 = new BaseDistFunctionalTest.MagicKey(c3);
+// assert !getDistributionManager(c1).isLocal(k3);
+// assert !getDistributionManager(c2).isLocal(k3);
+// assert getDistributionManager(c3).isLocal(k3);
+// assert getDistributionManager(c4).isLocal(k3);
+//
+// BaseDistFunctionalTest.MagicKey k4 = new BaseDistFunctionalTest.MagicKey(c4);
+// assert getDistributionManager(c1).isLocal(k4);
+// assert !getDistributionManager(c2).isLocal(k4);
+// assert !getDistributionManager(c3).isLocal(k4);
+// assert getDistributionManager(c4).isLocal(k4);
+// }
}
More information about the infinispan-commits
mailing list