[infinispan-commits] Infinispan SVN: r1807 - trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Tue May 18 11:43:29 EDT 2010
Author: mircea.markus
Date: 2010-05-18 11:43:29 -0400 (Tue, 18 May 2010)
New Revision: 1807
Added:
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheContainerTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerNotStartedTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerStoppedTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ServerRestartTest.java
Modified:
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CSAIntegrationTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DistTopologyChange.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ReplTopologyChangeTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/WorkerThread.java
Log:
updated test and javadocs, fixed various issues
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CSAIntegrationTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CSAIntegrationTest.java 2010-05-18 15:42:20 UTC (rev 1806)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CSAIntegrationTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -64,7 +64,7 @@
cm3.defineConfiguration(CACHE_NAME, config);
hotRodServer1 = TestHelper.startHotRodServer(manager(0));
- hotRodServer2 = TestHelper.startHotRodServer(manager(1));
+ hotRodServer2 = TestHelper.startHotRodServer(manager(1));
hotRodServer3 = TestHelper.startHotRodServer(manager(2));
assert manager(0).getCache(CACHE_NAME) != null;
@@ -139,7 +139,6 @@
List<byte[]> keys = new ArrayList<byte[]>();
for (int i = 0; i < 500; i++) {
- System.out.println("i = " + i);
byte[] key = generateKey(i);
keys.add(key);
remoteCache.put(new String(key), "value");
Added: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheContainerTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheContainerTest.java (rev 0)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheContainerTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -0,0 +1,54 @@
+package org.infinispan.client.hotrod;
+
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+
+/**
+ * // TODO: Document this
+ * - todo factorize code with CacheManagerNotStartedTest
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(groups = "functional", testName = "client.hotrod.CacheContainerTest")
+public class CacheContainerTest extends SingleCacheManagerTest {
+
+ private static final String CACHE_NAME = "someName";
+
+ CacheManager cacheManager = null;
+ HotRodServer hotrodServer = null;
+ RemoteCacheManager remoteCacheManager;
+
+ @Override
+ protected CacheManager createCacheManager() throws Exception {
+ cacheManager = TestCacheManagerFactory.createLocalCacheManager();
+ cacheManager.defineConfiguration(CACHE_NAME, new Configuration());
+ hotrodServer = TestHelper.startHotRodServer(cacheManager);
+ remoteCacheManager = new RemoteCacheManager("localhost:" + hotrodServer.getPort(), true);
+ return cacheManager;
+ }
+
+ @AfterTest(alwaysRun = true)
+ public void release() {
+ if (cacheManager != null) cacheManager.stop();
+ if (hotrodServer != null) hotrodServer.stop();
+ }
+
+ public void testObtainingSameInstanceMultipleTimes() {
+ Cache<Object,Object> objectCache = remoteCacheManager.getCache();
+ Cache<Object,Object> objectCache2 = remoteCacheManager.getCache();
+ assert objectCache == objectCache2;
+ }
+
+ public void testObtainingSameInstanceMultipleTimes2() {
+ Cache<Object,Object> objectCache = remoteCacheManager.getCache(CACHE_NAME);
+ Cache<Object,Object> objectCache2 = remoteCacheManager.getCache(CACHE_NAME);
+ assert objectCache == objectCache2;
+ }
+}
Added: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerNotStartedTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerNotStartedTest.java (rev 0)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerNotStartedTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -0,0 +1,118 @@
+package org.infinispan.client.hotrod;
+
+import org.infinispan.client.hotrod.exceptions.RemoteCacheManagerNotStartedException;
+import org.infinispan.config.Configuration;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+
+import java.util.HashMap;
+
+/**
+ * // TODO: Document this
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test (testName = "client.hotrod.CacheManagerNotStartedTest", groups = "functional")
+public class CacheManagerNotStartedTest extends SingleCacheManagerTest {
+
+ private static final String CACHE_NAME = "someName";
+
+ CacheManager cacheManager = null;
+ HotRodServer hotrodServer = null;
+ RemoteCacheManager remoteCacheManager;
+
+ @Override
+ protected CacheManager createCacheManager() throws Exception {
+ cacheManager = TestCacheManagerFactory.createLocalCacheManager();
+ cacheManager.defineConfiguration(CACHE_NAME, new Configuration());
+ hotrodServer = TestHelper.startHotRodServer(cacheManager);
+ remoteCacheManager = new RemoteCacheManager("localhost:" + hotrodServer.getHost(), false);
+ return cacheManager;
+ }
+
+ @AfterTest(alwaysRun = true)
+ public void release() {
+ if (cacheManager != null) cacheManager.stop();
+ if (hotrodServer != null) hotrodServer.stop();
+ }
+
+ public void testGetCacheOperations() {
+ assert remoteCacheManager.getCache() != null;
+ assert remoteCacheManager.getCache(CACHE_NAME) != null;
+ assert !remoteCacheManager.isStarted();
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testGetCacheOperations2() {
+ remoteCacheManager.getCache().put("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testGetCacheOperations3() {
+ remoteCacheManager.getCache(CACHE_NAME).put("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testPut() {
+ cache().put("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testPutAsync() {
+ cache().putAsync("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testGet() {
+ cache().get("k");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testReplace() {
+ cache().replace("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testReplaceAsync() {
+ cache().replaceAsync("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testPutAll() {
+ cache().putAll(new HashMap<Object, Object>());
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testPutAllAsync() {
+ cache().putAllAsync(new HashMap<Object, Object>());
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testVersionedGet() {
+ cache().getVersioned("key");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testVersionedRemove() {
+ cache().removeWithVersion("key", 12312321l);
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testVersionedRemoveAsync() {
+ cache().removeWithVersionAsync("key", 12312321l);
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class)
+ public void testPing() {
+ cache().ping();
+ }
+
+ private RemoteCache<Object, Object> cache() {
+ return remoteCacheManager.getCache();
+ }
+}
Added: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerStoppedTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerStoppedTest.java (rev 0)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/CacheManagerStoppedTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -0,0 +1,129 @@
+package org.infinispan.client.hotrod;
+
+import org.infinispan.client.hotrod.exceptions.RemoteCacheManagerNotStartedException;
+import org.infinispan.config.Configuration;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+
+import java.util.HashMap;
+
+/**
+ * // TODO: Document this
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test (testName = "client.hotrod.CacheManagerStoppedTest", groups = "functional")
+public class CacheManagerStoppedTest extends SingleCacheManagerTest {
+
+ private static final String CACHE_NAME = "someName";
+
+ CacheManager cacheManager = null;
+ HotRodServer hotrodServer = null;
+ RemoteCacheManager remoteCacheManager;
+
+ @Override
+ protected CacheManager createCacheManager() throws Exception {
+ cacheManager = TestCacheManagerFactory.createLocalCacheManager();
+ cacheManager.defineConfiguration(CACHE_NAME, new Configuration());
+ hotrodServer = TestHelper.startHotRodServer(cacheManager);
+ remoteCacheManager = new RemoteCacheManager("localhost:" + hotrodServer.getPort(), true);
+ return cacheManager;
+ }
+
+ @AfterTest(alwaysRun = true)
+ public void release() {
+ if (cacheManager != null) cacheManager.stop();
+ if (hotrodServer != null) hotrodServer.stop();
+ }
+
+ public void testGetCacheOperations() {
+ assert remoteCacheManager.getCache() != null;
+ assert remoteCacheManager.getCache(CACHE_NAME) != null;
+ cache().ping();
+ cache().put("k", "v");
+ assert cache().get("k").equals("v");
+ }
+
+ @Test (dependsOnMethods = "testGetCacheOperations")
+ public void testStopCacheManager() {
+ assert remoteCacheManager.isStarted();
+ remoteCacheManager.stop();
+ assert !remoteCacheManager.isStarted();
+ assert remoteCacheManager.getCache() != null;
+ assert remoteCacheManager.getCache(CACHE_NAME) != null;
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testGetCacheOperations2() {
+ remoteCacheManager.getCache().put("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testGetCacheOperations3() {
+ remoteCacheManager.getCache(CACHE_NAME).put("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testPut() {
+ cache().put("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testPutAsync() {
+ cache().putAsync("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testGet() {
+ cache().get("k");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testReplace() {
+ cache().replace("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testReplaceAsync() {
+ cache().replaceAsync("k", "v");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testPutAll() {
+ cache().putAll(new HashMap<Object, Object>());
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testPutAllAsync() {
+ cache().putAllAsync(new HashMap<Object, Object>());
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testVersionedGet() {
+ cache().getVersioned("key");
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testVersionedRemove() {
+ cache().removeWithVersion("key", 12312321l);
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testVersionedRemoveAsync() {
+ cache().removeWithVersionAsync("key", 12312321l);
+ }
+
+ @Test(expectedExceptions = RemoteCacheManagerNotStartedException.class, dependsOnMethods = "testStopCacheManager")
+ public void testPing() {
+ cache().ping();
+ }
+
+ private RemoteCache<Object, Object> cache() {
+ return remoteCacheManager.getCache();
+ }
+}
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java 2010-05-18 15:42:20 UTC (rev 1806)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -151,7 +151,7 @@
for (int i = 0; i < 10; i++) {
log.trace("Active for server " + hrServ1Addr + " are:" + connectionPool.getNumActive(hrServ1Addr));
log.trace("Active for server " + hrServ2Addr + " are:" + connectionPool.getNumActive(hrServ2Addr));
- if (connectionPool.getNumActive(hrServ1Addr) == 1 && connectionPool.getNumActive(hrServ1Addr) == 1) break;
+ if (connectionPool.getNumActive(hrServ1Addr) == 1 && connectionPool.getNumActive(hrServ2Addr) == 1) break;
Thread.sleep(1000);
}
log.info("Connection pool is " + connectionPool);
@@ -165,7 +165,7 @@
for (int i = 0; i < 10; i++) {
log.trace("Active for server " + hrServ1Addr + " are:" + connectionPool.getNumActive(hrServ1Addr));
log.trace("Active for server " + hrServ2Addr + " are:" + connectionPool.getNumActive(hrServ2Addr));
- if (connectionPool.getNumActive(hrServ1Addr) == 2 && connectionPool.getNumActive(hrServ1Addr) == 2) break;
+ if (connectionPool.getNumActive(hrServ1Addr) == 2 && connectionPool.getNumActive(hrServ2Addr) == 2) break;
Thread.sleep(1000);
}
assertEquals(0, connectionPool.getNumIdle(hrServ1Addr));
Added: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java (rev 0)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -0,0 +1,36 @@
+package org.infinispan.client.hotrod;
+
+import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash;
+import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashFactory;
+import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashV1;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+/**
+ * Tester for ConsistentHashFactory.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test(testName = "client.hotrod.ConsistentHashFactoryTest", groups = "functional")
+public class ConsistentHashFactoryTest {
+
+ public void testPropertyCorrectlyRead() {
+ Properties propos = new Properties();
+ String value = "org.infinispan.client.hotrod.impl.consistenthash.SomeCustomConsitentHashV1";
+ propos.put("consistent-hash.1", value);
+ ConsistentHashFactory chf = new ConsistentHashFactory();
+ chf.init(propos);
+ String s = chf.getVersion2ConsistentHash().get(1);
+ assert s != null;
+ assert value.equals(s);
+ }
+
+ public void testNoChDefined() {
+ ConsistentHashFactory chf = new ConsistentHashFactory();
+ ConsistentHash hash = chf.newConsistentHash(1);
+ assert hash != null;
+ assert hash.getClass().equals(ConsistentHashV1.class);
+ }
+}
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DistTopologyChange.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DistTopologyChange.java 2010-05-18 15:42:20 UTC (rev 1806)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DistTopologyChange.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod;
import org.infinispan.config.Configuration;
+import org.testng.annotations.Test;
/**
* // TODO: Document this
@@ -8,6 +9,7 @@
* @author Mircea.Markus at jboss.com
* @since 4.1
*/
+ at Test(groups = "functional" , testName = "client.hotrod.DistTopologyChangeTest")
public class DistTopologyChange extends ReplTopologyChangeTest {
protected Configuration.CacheMode getCacheMode() {
return Configuration.CacheMode.DIST_SYNC;
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java 2010-05-18 15:42:20 UTC (rev 1806)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -88,6 +88,14 @@
remoteCacheManager.stop();
}
+ public void testStringAndBooleanConstructor() {
+ RemoteCacheManager remoteCacheManager = new RemoteCacheManager("localhost:"+hotrodServer.getPort(), false);
+ assert !remoteCacheManager.isStarted();
+ remoteCacheManager.start();
+ assertWorks(remoteCacheManager);
+ remoteCacheManager.stop();
+ }
+
private void assertWorks(RemoteCacheManager remoteCacheManager) {
RemoteCache<Object, Object> cache = remoteCacheManager.getCache();
assert cache.ping();
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ReplTopologyChangeTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ReplTopologyChangeTest.java 2010-05-18 15:42:20 UTC (rev 1806)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ReplTopologyChangeTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -23,7 +23,7 @@
* @author Mircea.Markus at jboss.com
* @since 4.1
*/
- at Test (testName = "client.hotrod.MultipleCacheManagersTest", groups = "functional")
+ at Test(testName = "client.hotrod.ReplTopologyChangeTest", groups = "functional")
public class ReplTopologyChangeTest extends MultipleCacheManagersTest {
HotRodServer hotRodServer1;
@@ -36,12 +36,12 @@
private Configuration config;
@Override
- protected void assertSupportedConfig() {
+ protected void assertSupportedConfig() {
}
@AfterMethod
@Override
- protected void clearContent() throws Throwable {
+ protected void clearContent() throws Throwable {
}
@Override
@@ -62,7 +62,7 @@
TestingUtil.blockUntilCacheStatusAchieved(manager(0).getCache(), ComponentStatus.RUNNING, 10000);
TestingUtil.blockUntilCacheStatusAchieved(manager(1).getCache(), ComponentStatus.RUNNING, 10000);
- manager(0).getCache().put("k","v");
+ manager(0).getCache().put("k", "v");
manager(0).getCache().get("k").equals("v");
manager(1).getCache().get("k").equals("v");
@@ -98,8 +98,14 @@
TestingUtil.blockUntilCacheStatusAchieved(manager(1).getCache(), ComponentStatus.RUNNING, 10000);
TestingUtil.blockUntilCacheStatusAchieved(manager(2).getCache(), ComponentStatus.RUNNING, 10000);
- expectTopologyChange(new InetSocketAddress("localhost",hotRodServer3.getPort()), true);
- assertEquals(3, tcpConnectionFactory.getServers().size());
+ try {
+ expectTopologyChange(new InetSocketAddress("localhost", hotRodServer3.getPort()), true);
+ assertEquals(3, tcpConnectionFactory.getServers().size());
+ } finally {
+ log.info("Members are: " + manager(0).getCache().getAdvancedCache().getRpcManager().getTransport().getMembers());
+ log.info("Members are: " + manager(1).getCache().getAdvancedCache().getRpcManager().getTransport().getMembers());
+ log.info("Members are: " + manager(2).getCache().getAdvancedCache().getRpcManager().getTransport().getMembers());
+ }
}
@Test(dependsOnMethods = "testAddNewServer")
@@ -111,8 +117,14 @@
TestingUtil.blockUntilCacheStatusAchieved(manager(1).getCache(), ComponentStatus.RUNNING, 10000);
InetSocketAddress server3Address = new InetSocketAddress("localhost", hotRodServer3.getPort());
- expectTopologyChange(server3Address, false);
- assertEquals(2, tcpConnectionFactory.getServers().size());
+ try {
+ expectTopologyChange(server3Address, false);
+ assertEquals(2, tcpConnectionFactory.getServers().size());
+ } finally {
+ log.info("Members are: " + manager(0).getCache().getAdvancedCache().getRpcManager().getTransport().getMembers());
+ log.info("Members are: " + manager(1).getCache().getAdvancedCache().getRpcManager().getTransport().getMembers());
+ log.info("Members are: " + manager(2).getCache().getAdvancedCache().getRpcManager().getTransport().getMembers());
+ }
}
private void expectTopologyChange(InetSocketAddress server1Address, boolean added) {
Added: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ServerRestartTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ServerRestartTest.java (rev 0)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ServerRestartTest.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -0,0 +1,69 @@
+package org.infinispan.client.hotrod;
+
+import org.infinispan.Cache;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+/**
+ * // TODO: Document this
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test
+public class ServerRestartTest extends SingleCacheManagerTest {
+
+ private static Log log = LogFactory.getLog(HotRodIntegrationTest.class);
+
+ RemoteCache defaultRemote;
+ private RemoteCacheManager remoteCacheManager;
+
+ protected HotRodServer hotrodServer;
+
+
+ @Override
+ protected CacheManager createCacheManager() throws Exception {
+ cacheManager = TestCacheManagerFactory.createLocalCacheManager();
+ cacheManager.getCache();
+
+
+ hotrodServer = TestHelper.startHotRodServer(cacheManager);
+ log.info("Started server on port: " + hotrodServer.getPort());
+
+ Properties config = new Properties();
+ config.put("hotrod-servers", "127.0.0.1:" + hotrodServer.getPort());
+ config.put("timeBetweenEvictionRunsMillis", "2000");
+ remoteCacheManager = new RemoteCacheManager(config);
+ defaultRemote = remoteCacheManager.getCache();
+ return cacheManager;
+ }
+
+
+ @AfterClass
+ public void testDestroyRemoteCacheFactory() {
+ remoteCacheManager.stop();
+ hotrodServer.stop();
+ }
+
+ public void testServerShutdown() throws Exception {
+ defaultRemote.put("k","v");
+ assert defaultRemote.get("k").equals("v");
+
+ int port = hotrodServer.getPort();
+ hotrodServer.stop();
+ hotrodServer.start("localhost", port, cacheManager, 2, 2, 20000);
+
+ Thread.sleep(3000);
+
+ assert defaultRemote.get("k").equals("v");
+ defaultRemote.put("k","v");
+ }
+}
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/WorkerThread.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/WorkerThread.java 2010-05-18 15:42:20 UTC (rev 1806)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/WorkerThread.java 2010-05-18 15:43:29 UTC (rev 1807)
@@ -31,7 +31,7 @@
volatile String value;
public WorkerThread(RemoteCache<String, String> remoteCache) {
- super("WorkerThread-" + WORKER_INDEX.getAndDecrement());
+ super("WorkerThread-" + WORKER_INDEX.getAndIncrement());
this.remoteCache = remoteCache;
start();
}
@@ -88,7 +88,7 @@
this.key = key;
this.value = value;
try {
- trace("::put::send contains: " + send.peek());
+ trace("::putAsync::send contains: " + send.peek());
send.put(PUT_ASYNC);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
More information about the infinispan-commits
mailing list