[infinispan-commits] Infinispan SVN: r894 - in trunk: core/src/test/java/org/infinispan/replication and 3 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Sep 30 18:18:27 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-09-30 18:18:26 -0400 (Wed, 30 Sep 2009)
New Revision: 894
Modified:
trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java
trunk/core/src/test/java/org/infinispan/replication/AsyncAPISyncReplTest.java
trunk/core/src/test/java/org/infinispan/test/MultipleCacheManagersTest.java
trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
trunk/parent/pom.xml
Log:
Fixed broken tests and added test dependencies for JBossTM
Modified: trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java 2009-09-30 15:18:42 UTC (rev 893)
+++ trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java 2009-09-30 22:18:26 UTC (rev 894)
@@ -181,11 +181,10 @@
// ---- TX boundary commands
@Override
public Object visitCommitCommand(TxInvocationContext ctx, CommitCommand command) throws Throwable {
- if (ctx.isOriginLocal()) {
+ if (ctx.isOriginLocal() && ctx.hasModifications()) {
List<Address> recipients = new ArrayList<Address>(ctx.getTransactionParticipants());
rpcManager.invokeRemotely(recipients, command, configuration.isSyncCommitPhase(), true);
List<WriteCommand> mods = ctx.getModifications();
- if (trace) log.trace("CommitCommand is associated with a tx with modifications {0}", mods);
flushL1Cache(recipients.size(), getKeys(mods), false, null, configuration.isSyncCommitPhase());
}
return invokeNextInterceptor(ctx, command);
@@ -197,7 +196,7 @@
boolean sync = isSynchronous(ctx);
- if (ctx.isOriginLocal()) {
+ if (ctx.isOriginLocal() && ctx.hasModifications()) {
List<Address> recipients = new ArrayList<Address>(ctx.getTransactionParticipants());
if (trace) log.trace("Multicasting PrepareCommand to recipients : " + recipients);
// this method will return immediately if we're the only member (because exclude_self=true)
Modified: trunk/core/src/test/java/org/infinispan/replication/AsyncAPISyncReplTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/replication/AsyncAPISyncReplTest.java 2009-09-30 15:18:42 UTC (rev 893)
+++ trunk/core/src/test/java/org/infinispan/replication/AsyncAPISyncReplTest.java 2009-09-30 22:18:26 UTC (rev 894)
@@ -13,6 +13,7 @@
import org.infinispan.util.Util;
import org.testng.annotations.Test;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.Collections;
import java.util.List;
@@ -49,6 +50,8 @@
assert Util.safeEquals((real = c2.get(k)), v) : "Error on cache 2. Expected " + v + " and got " + real;
}
+
+ @Test(invocationCount = 100)
public void testAsyncMethods() throws ExecutionException, InterruptedException {
String v = "v";
@@ -62,7 +65,6 @@
// put
Future<String> f = c1.putAsync(key, v);
- System.out.println("Future is of type " + f.getClass().getName());
assert f != null;
assert !f.isDone();
assert c2.get(key) == null;
@@ -201,7 +203,9 @@
Future<String> f = c1.putAsync(key, v);
assert f != null;
assert f.isDone();
+ Transaction t = tm.suspend();
assert c2.get(key) == null;
+ tm.resume(t);
assert f.get() == null;
tm.commit();
asyncWait(true, PutKeyValueCommand.class);
@@ -211,7 +215,9 @@
f = c1.putAsync(key, v2);
assert f != null;
assert f.isDone();
+ t = tm.suspend();
assert c2.get(key).equals(v);
+ tm.resume(t);
assert !f.isCancelled();
assert f.get().equals(v);
tm.commit();
@@ -223,7 +229,9 @@
Future<Void> f2 = c1.putAllAsync(Collections.singletonMap(key, v3));
assert f2 != null;
assert f2.isDone();
+ t = tm.suspend();
assert c2.get(key).equals(v2);
+ tm.resume(t);
assert !f2.isCancelled();
assert f2.get() == null;
tm.commit();
@@ -235,7 +243,9 @@
f = c1.putIfAbsentAsync(key, v4);
assert f != null;
assert f.isDone();
+ t = tm.suspend();
assert c2.get(key).equals(v3);
+ tm.resume(t);
assert !f.isCancelled();
assert f.get().equals(v3);
tm.commit();
@@ -246,7 +256,9 @@
f = c1.removeAsync(key);
assert f != null;
assert f.isDone();
+ t = tm.suspend();
assert c2.get(key).equals(v3);
+ tm.resume(t);
assert !f.isCancelled();
assert f.get().equals(v3);
tm.commit();
@@ -258,7 +270,9 @@
f = c1.putIfAbsentAsync(key, v4);
assert f != null;
assert f.isDone();
+ t = tm.suspend();
assert c2.get(key) == null;
+ tm.resume(t);
assert !f.isCancelled();
assert f.get() == null;
tm.commit();
@@ -279,7 +293,9 @@
f3 = c1.removeAsync(key, v4);
assert f3 != null;
assert f3.isDone();
+ t = tm.suspend();
assert c2.get(key).equals(v4);
+ tm.resume(t);
assert !f3.isCancelled();
assert f3.get().equals(true);
tm.commit();
@@ -303,7 +319,9 @@
f = c1.replaceAsync(key, v5);
assert f != null;
assert f.isDone();
+ t = tm.suspend();
assert c2.get(key).equals(v);
+ tm.resume(t);
assert !f.isCancelled();
assert f.get().equals(v);
tm.commit();
@@ -324,7 +342,9 @@
f3 = c1.replaceAsync(key, v5, v6);
assert f3 != null;
assert f3.isDone();
+ t = tm.suspend();
assert c2.get(key).equals(v5);
+ tm.resume(t);
assert !f3.isCancelled();
assert f3.get().equals(true);
tm.commit();
Modified: trunk/core/src/test/java/org/infinispan/test/MultipleCacheManagersTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/MultipleCacheManagersTest.java 2009-09-30 15:18:42 UTC (rev 893)
+++ trunk/core/src/test/java/org/infinispan/test/MultipleCacheManagersTest.java 2009-09-30 22:18:26 UTC (rev 894)
@@ -113,8 +113,17 @@
*
* @return the new CacheManager
*/
+ ThreadLocal<Integer> cacheCount = new ThreadLocal<Integer>() {
+ @Override
+ protected Integer initialValue() {
+ return 0;
+ }
+ };
protected CacheManager addClusterEnabledCacheManager() {
- CacheManager cm = TestCacheManagerFactory.createClusteredCacheManager();
+ int cmNumber = cacheCount.get();
+ cacheCount.set(cmNumber + 1);
+ String cacheName = "Cache-" + Character.toUpperCase((char) ('A' + cmNumber));
+ CacheManager cm = TestCacheManagerFactory.createClusteredCacheManager(cacheName);
cacheManagers.add(cm);
return cm;
}
Modified: trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2009-09-30 15:18:42 UTC (rev 893)
+++ trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2009-09-30 22:18:26 UTC (rev 894)
@@ -50,13 +50,7 @@
* Creates an cache manager that does support clustering.
*/
public static CacheManager createClusteredCacheManager() {
- GlobalConfiguration globalConfiguration = GlobalConfiguration.getClusteredDefault();
- amendMarshaller(globalConfiguration);
-// amendJmx(globalConfiguration);
- Properties newTransportProps = new Properties();
- newTransportProps.put(JGroupsTransport.CONFIGURATION_STRING, JGroupsConfigBuilder.getJGroupsConfig());
- globalConfiguration.setTransportProperties(newTransportProps);
- return new DefaultCacheManager(globalConfiguration);
+ return createClusteredCacheManager((String) null);
}
/**
@@ -140,4 +134,14 @@
if (transactional) amendJTA(c);
return c;
}
+
+ public static CacheManager createClusteredCacheManager(String cacheName) {
+ GlobalConfiguration globalConfiguration = GlobalConfiguration.getClusteredDefault();
+ amendMarshaller(globalConfiguration);
+ if (cacheName != null) globalConfiguration.setTransportNodeName(cacheName);
+ Properties newTransportProps = new Properties();
+ newTransportProps.put(JGroupsTransport.CONFIGURATION_STRING, JGroupsConfigBuilder.getJGroupsConfig());
+ globalConfiguration.setTransportProperties(newTransportProps);
+ return new DefaultCacheManager(globalConfiguration);
+ }
}
Modified: trunk/parent/pom.xml
===================================================================
--- trunk/parent/pom.xml 2009-09-30 15:18:42 UTC (rev 893)
+++ trunk/parent/pom.xml 2009-09-30 22:18:26 UTC (rev 894)
@@ -107,6 +107,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>jboss.jbossts</groupId>
<artifactId>jbossts-common</artifactId>
<version>4.6.1.GA</version>
More information about the infinispan-commits
mailing list