Author: jmesnil
Date: 2010-09-03 06:19:04 -0400 (Fri, 03 Sep 2010)
New Revision: 9641
Modified:
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java
Log:
add ClientSession... to crash() method to allow same process server to simulate a failure
Modified:
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
===================================================================
---
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java 2010-09-03
09:46:44 UTC (rev 9640)
+++
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java 2010-09-03
10:19:04 UTC (rev 9641)
@@ -13,6 +13,7 @@
package org.hornetq.tests.integration.cluster.util;
+import org.hornetq.api.core.client.ClientSession;
/**
* A RemoteProcessHornetQServer
@@ -31,20 +32,36 @@
{
this.configurationClassName = configurationClassName;
}
+
+ public boolean isInitialised()
+ {
+ return (serverProcess != null);
+ }
public void start() throws Exception
{
serverProcess = RemoteProcessHornetQServerSupport.start(configurationClassName);
+ Thread.sleep(2000);
}
public void stop() throws Exception
{
- RemoteProcessHornetQServerSupport.stop(serverProcess);
+ if (serverProcess != null)
+ {
+ RemoteProcessHornetQServerSupport.stop(serverProcess);
+ serverProcess = null;
+ Thread.sleep(2000);
+ }
}
- public void crash() throws Exception
+ public void crash(ClientSession... sessions) throws Exception
{
- RemoteProcessHornetQServerSupport.crash(serverProcess);
+ if (serverProcess != null)
+ {
+ RemoteProcessHornetQServerSupport.crash(serverProcess);
+ serverProcess = null;
+ Thread.sleep(2000);
+ }
}
// Constants -----------------------------------------------------
Modified:
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
===================================================================
---
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2010-09-03
09:46:44 UTC (rev 9640)
+++
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2010-09-03
10:19:04 UTC (rev 9641)
@@ -13,6 +13,14 @@
package org.hornetq.tests.integration.cluster.util;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import junit.framework.Assert;
+
+import org.hornetq.api.core.HornetQException;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.SessionFailureListener;
import org.hornetq.core.server.HornetQServer;
/**
@@ -32,6 +40,11 @@
this.server = server;
}
+ public boolean isInitialised()
+ {
+ return server.isInitialised();
+ }
+
public void start() throws Exception
{
server.start();
@@ -40,11 +53,34 @@
public void stop() throws Exception
{
server.stop();
+ Thread.sleep(2000);
}
- public void crash()
+ public void crash(ClientSession... sessions) throws Exception
{
- // FIXME...
+ final CountDownLatch latch = new CountDownLatch(sessions.length);
+
+ class MyListener implements SessionFailureListener
+ {
+ public void connectionFailed(final HornetQException me)
+ {
+ latch.countDown();
+ }
+
+ public void beforeReconnect(HornetQException exception)
+ {
+ }
+ }
+ for (ClientSession session : sessions)
+ {
+ session.addFailureListener(new MyListener());
+ }
+ server.stop();
+
+ // Wait to be informed of failure
+ boolean ok = latch.await(10000, TimeUnit.MILLISECONDS);
+
+ Assert.assertTrue(ok);
}
// Constants -----------------------------------------------------
Modified:
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java
===================================================================
---
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java 2010-09-03
09:46:44 UTC (rev 9640)
+++
branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java 2010-09-03
10:19:04 UTC (rev 9641)
@@ -13,6 +13,8 @@
package org.hornetq.tests.integration.cluster.util;
+import org.hornetq.api.core.client.ClientSession;
+
/**
* A TestServer
*
@@ -26,5 +28,7 @@
public void stop() throws Exception;
- public void crash() throws Exception;
+ public void crash(ClientSession... sessions) throws Exception;
+
+ public boolean isInitialised();
}