[infinispan-commits] Infinispan SVN: r2552 - in branches/4.2.x/core/src: test/java/org/infinispan/api/lru/read_committed and 1 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu Oct 21 10:59:16 EDT 2010
Author: mircea.markus
Date: 2010-10-21 10:59:16 -0400 (Thu, 21 Oct 2010)
New Revision: 2552
Removed:
branches/4.2.x/core/src/test/java/org/infinispan/distribution/ConsistentHashBackupTest.java
branches/4.2.x/core/src/test/java/org/infinispan/distribution/DistributionManagerImplTest.java
Modified:
branches/4.2.x/core/src/main/resources/config-samples/all.xml
branches/4.2.x/core/src/test/java/org/infinispan/api/lru/read_committed/CacheAPIMVCCTest.java
Log:
wrong commit
Modified: branches/4.2.x/core/src/main/resources/config-samples/all.xml
===================================================================
--- branches/4.2.x/core/src/main/resources/config-samples/all.xml 2010-10-21 14:04:39 UTC (rev 2551)
+++ branches/4.2.x/core/src/main/resources/config-samples/all.xml 2010-10-21 14:59:16 UTC (rev 2552)
@@ -93,7 +93,7 @@
<!--
Used to enable invocation batching and allow the use of Cache.startBatch()/endBatch() methods.
-->
- <invocationBatching enabled="false"/>
+ <invocationBatching enabled="true"/>
<!--
This element specifies that the cache is clustered.
Modified: branches/4.2.x/core/src/test/java/org/infinispan/api/lru/read_committed/CacheAPIMVCCTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/api/lru/read_committed/CacheAPIMVCCTest.java 2010-10-21 14:04:39 UTC (rev 2551)
+++ branches/4.2.x/core/src/test/java/org/infinispan/api/lru/read_committed/CacheAPIMVCCTest.java 2010-10-21 14:59:16 UTC (rev 2552)
@@ -3,6 +3,7 @@
import org.infinispan.api.CacheAPITest;
import org.infinispan.config.Configuration;
import org.infinispan.eviction.EvictionStrategy;
+import org.infinispan.test.TestingUtil;
import org.infinispan.util.concurrent.IsolationLevel;
import org.testng.annotations.Test;
@@ -20,4 +21,32 @@
cfg.setEvictionMaxEntries(1000);
return cfg;
}
+
+ public void testRollbackAfterClear() throws Exception {
+ String key = "key", value = "value";
+ int size = 0;
+ cache.put(key, value);
+ assert cache.get(key).equals(value);
+ size = 1;
+ assert size == cache.size() && size == cache.keySet().size() && size == cache.values().size() && size == cache.entrySet().size();
+ assert cache.keySet().contains(key);
+ assert cache.values().contains(value);
+
+ TestingUtil.getTransactionManager(cache).begin();
+ cache.clear();
+ assert cache.get(key) == null;
+ size = 0;
+ assert size == cache.size();
+ assert size == cache.keySet().size();
+ assert size == cache.values().size();
+ assert size == cache.entrySet().size();
+ TestingUtil.getTransactionManager(cache).rollback();
+
+ assert cache.get(key).equals(value);
+ size = 1;
+ assert size == cache.size() && size == cache.keySet().size() && size == cache.values().size() && size == cache.entrySet().size();
+ assert cache.keySet().contains(key);
+ assert cache.values().contains(value);
+ }
+
}
Deleted: branches/4.2.x/core/src/test/java/org/infinispan/distribution/ConsistentHashBackupTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/distribution/ConsistentHashBackupTest.java 2010-10-21 14:04:39 UTC (rev 2551)
+++ branches/4.2.x/core/src/test/java/org/infinispan/distribution/ConsistentHashBackupTest.java 2010-10-21 14:59:16 UTC (rev 2552)
@@ -1,88 +0,0 @@
-package org.infinispan.distribution;
-
-import org.infinispan.remoting.transport.Address;
-import org.infinispan.test.AbstractInfinispanTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Mircea.Markus at jboss.com
- * @since 4.2
- */
- at Test(groups = "functional", testName = "distribution.ConsistentHashBackupTest")
-public class ConsistentHashBackupTest extends AbstractInfinispanTest {
-
- List<Address> servers;
- DefaultConsistentHash ch;
-
- @BeforeTest
- public void setUp() {
- servers = new LinkedList<Address>();
- int numServers = 5;
- for (int i = 0; i < numServers; i++) {
- servers.add(new TestAddress(i));
- }
-
- ch = (DefaultConsistentHash) BaseDistFunctionalTest.createNewConsistentHash(servers);
- }
-
-
- private List<Address> getNext(Address a, int count) {
- List<Address> addressList = ch.getAddressOnTheWheel();
- int pos = addressList.indexOf(a);
- List<Address> result = new ArrayList<Address>();
- for (int i = 1; i <= count; i++) {
- result.add(addressList.get((pos + i) % addressList.size()) );
- }
- return result;
- }
-
- private List<Address> getPrevious(Address a, int count) {
- List<Address> addressList = ch.getAddressOnTheWheel();
- int pos = addressList.indexOf(a);
- List<Address> result = new ArrayList<Address>();
- for (int i = 1; i <= count; i++) {
- int index;
- if (pos - i < 0) {
- index = addressList.size() + (pos - i);
- } else {
- index = pos - i;
- }
- result.add(addressList.get((index)));
- }
- return result;
- }
-
- public void testGetBackupsForNode() {
- TestAddress testAddress = new TestAddress(0);
- List<Address> addressList = ch.getBackupsForNode(testAddress, 2);
- assert addressList.size() == 1;
-
- assert addressList.get(0).equals(getNext(testAddress, 1).get(0));
-
- TestAddress ta2 = new TestAddress(3);
- addressList = ch.getBackupsForNode(ta2, 3);
- assert addressList.size() == 2;
-
- assert addressList.equals(getNext(ta2, 2));
- }
-
- public void testNodesBackup() {
- TestAddress testAddress = new TestAddress(0);
- List<Address> addressList = ch.getNodesThatBackupHere(testAddress, 2);
- assert addressList.size() == 1;
- assert addressList.get(0).equals(getPrevious(testAddress, 1).get(0));
-
- TestAddress ta2 = new TestAddress(3);
- addressList = ch.getNodesThatBackupHere(ta2, 3);
- assert addressList.size() == 2;
-
- List<Address> prev = getPrevious(ta2, 2);
- assert addressList.containsAll(prev);
- assert prev.containsAll(addressList);
- }
-}
Deleted: branches/4.2.x/core/src/test/java/org/infinispan/distribution/DistributionManagerImplTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/distribution/DistributionManagerImplTest.java 2010-10-21 14:04:39 UTC (rev 2551)
+++ branches/4.2.x/core/src/test/java/org/infinispan/distribution/DistributionManagerImplTest.java 2010-10-21 14:59:16 UTC (rev 2552)
@@ -1,77 +0,0 @@
-package org.infinispan.distribution;
-
-import org.infinispan.config.Configuration;
-import org.infinispan.remoting.transport.Address;
-import org.infinispan.test.AbstractInfinispanTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Mircea.Markus at jboss.com
- * @since 4.2
- */
- at Test (groups = "functional", testName = "distribution.DistributionManagerImplTest")
-public class DistributionManagerImplTest extends AbstractInfinispanTest {
- List<Address> servers;
- DefaultConsistentHash ch;
- Address a0;
- Address a1;
- Address a2;
- Address a3;
- Address a4;
-
- @BeforeTest
- public void setUp() {
- servers = new LinkedList<Address>();
- int numServers = 5;
- for (int i = 0; i < numServers; i++) {
- servers.add(new TestAddress(i));
- }
- ch = (DefaultConsistentHash) BaseDistFunctionalTest.createNewConsistentHash(servers);
- a0 = ch.getAddressOnTheWheel().get(0);
- a1 = ch.getAddressOnTheWheel().get(1);
- a2 = ch.getAddressOnTheWheel().get(2);
- a3 = ch.getAddressOnTheWheel().get(3);
- a4 = ch.getAddressOnTheWheel().get(4);
- }
-
-
- /**
- * numOwners = 3. Let's a a2 leaves.
- */
- public void testLeaver() {
- DistributionManagerImpl dm = newDM(3);
- dm.setSelf(a0);
- assert dm.willReceiveLeaverState(a2) : " a0 will be the 2nd backup for a3's state";
- dm.setSelf(a1);
- assert !dm.willReceiveLeaverState(a2) : " a1 is not affected";
- dm.setSelf(a3);
- assert dm.willReceiveLeaverState(a2) : "this needs to receive state from a0";
- dm.setSelf(a4);
- assert dm.willReceiveLeaverState(a2) : "this needs to receive state from a1";
- }
-
- public void testWillSendLeaverState() {
- DistributionManagerImpl dm = newDM(3);
- dm.setSelf(a0);
- assert dm.willSendLeaverState(a2) : " a0 will need to send state to a3 so that it has 3 backups";
- dm.setSelf(a1);
- assert dm.willSendLeaverState(a2) : " a1 backups to a4";
- dm.setSelf(a3);
- assert dm.willSendLeaverState(a2) : "needs to send a2 state to a0 (new state backup)";
- dm.setSelf(a4);
- assert !dm.willSendLeaverState(a2) : "don't need to send any state as its backups are not affected";
- }
-
- private DistributionManagerImpl newDM(int numOwners) {
- DistributionManagerImpl dm = new DistributionManagerImpl();
- Configuration configuration = new Configuration();
- configuration.setNumOwners(numOwners);
- dm.setConfiguration(configuration);
- dm.setConsistentHash(ch);
- return dm;
- }
-}
More information about the infinispan-commits
mailing list