Author: clebert.suconic(a)jboss.com
Date: 2009-11-14 00:58:59 -0500 (Sat, 14 Nov 2009)
New Revision: 8284
Added:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeReconnectTest.java
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeStartTest.java
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeTest.java
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeWithDiscoveryGroupStartTest.java
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTestBase.java
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java
trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-55 - Netty Bridge Tests
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java 2009-11-13
20:52:21 UTC (rev 8283)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -31,9 +31,11 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.remoting.impl.invm.InVMConnector;
+import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.cluster.Bridge;
import org.hornetq.core.server.cluster.impl.BridgeImpl;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
@@ -50,31 +52,45 @@
{
private static final Logger log = Logger.getLogger(BridgeReconnectTest.class);
+ protected boolean isNetty()
+ {
+ return false;
+ }
+
+ /**
+ * @return
+ */
+ private String getConnector()
+ {
+ if (isNetty())
+ {
+ return NettyConnectorFactory.class.getName();
+ }
+ else
+ {
+ return InVMConnectorFactory.class.getName();
+ }
+ }
+
// Fail bridge and reconnecting immediately
public void testFailoverAndReconnectImmediately() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createHornetQServer(0, server0Params);
+ HornetQServer server0 = createHornetQServer(0, isNetty(), server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- HornetQServer server1 = createHornetQServer(1, server1Params);
+ HornetQServer server1 = createHornetQServer(1, isNetty(), server1Params);
Map<String, Object> server2Params = new HashMap<String, Object>();
- HornetQServer service2 = createHornetQServer(2, server2Params, true);
+ HornetQServer service2 = createHornetQServer(2, server2Params, isNetty(), true);
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params,
-
"server0tc");
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params, "server0tc");
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params,
-
"server1tc");
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params, "server1tc");
- TransportConfiguration server2tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server2Params,
-
"server2tc");
+ TransportConfiguration server2tc = new TransportConfiguration(getConnector(),
server2Params, "server2tc");
connectors.put(server1tc.getName(), server1tc);
@@ -182,27 +198,21 @@
public void testFailoverAndReconnectAfterAFewTries() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createHornetQServer(0, server0Params);
+ HornetQServer server0 = createHornetQServer(0, isNetty(), server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- HornetQServer server1 = createHornetQServer(1, server1Params);
+ HornetQServer server1 = createHornetQServer(1, isNetty(), server1Params);
Map<String, Object> server2Params = new HashMap<String, Object>();
- HornetQServer service2 = createHornetQServer(2, server2Params, true);
+ HornetQServer service2 = createHornetQServer(2, server2Params, isNetty(), true);
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params,
-
"server0tc");
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params, "server0tc");
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params,
-
"server1tc");
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params, "server1tc");
- TransportConfiguration server2tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server2Params,
-
"server2tc");
+ TransportConfiguration server2tc = new TransportConfiguration(getConnector(),
server2Params, "server2tc");
connectors.put(server1tc.getName(), server1tc);
@@ -314,20 +324,16 @@
public void testReconnectSameNode() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createHornetQServer(0, server0Params);
+ HornetQServer server0 = createHornetQServer(0, isNetty(), server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- HornetQServer server1 = createHornetQServer(1, server1Params);
+ HornetQServer server1 = createHornetQServer(1, isNetty(), server1Params);
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params,
-
"server0tc");
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params, "server0tc");
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params,
-
"server1tc");
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params, "server1tc");
connectors.put(server1tc.getName(), server1tc);
@@ -430,20 +436,16 @@
public void testShutdownServerCleanlyAndReconnectSameNode() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createHornetQServer(0, server0Params);
+ HornetQServer server0 = createHornetQServer(0, isNetty(), server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- HornetQServer server1 = createHornetQServer(1, server1Params);
+ HornetQServer server1 = createHornetQServer(1, isNetty(), server1Params);
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params,
-
"server0tc");
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params, "server0tc");
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params,
-
"server1tc");
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params, "server1tc");
connectors.put(server1tc.getName(), server1tc);
@@ -547,18 +549,18 @@
public void testFailoverThenFailAgainAndReconnect() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createHornetQServer(0, server0Params);
+ HornetQServer server0 = createHornetQServer(0, isNetty(), server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- HornetQServer server1 = createHornetQServer(1, server1Params);
+ HornetQServer server1 = createHornetQServer(1, isNetty(), server1Params);
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params,
"server0tc");
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params,
"server1tc");
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2009-11-13
20:52:21 UTC (rev 8283)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -32,6 +32,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.cluster.Bridge;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
@@ -49,14 +50,38 @@
{
private static final Logger log = Logger.getLogger(BridgeStartTest.class);
+ protected boolean isNetty()
+ {
+ return false;
+ }
+
+ private String getConnector()
+ {
+ if (isNetty())
+ {
+ return NettyConnectorFactory.class.getName();
+ }
+ else
+ {
+ return "org.hornetq.core.remoting.impl.invm.InVMConnectorFactory";
+ }
+ }
+
public void testStartStop() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createClusteredServerWithParams(0, true, server0Params);
+ HornetQServer server0 = createClusteredServerWithParams(isNetty(), 0, true,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- HornetQServer server1 = createClusteredServerWithParams(1, true, server1Params);
+ if (isNetty())
+ {
+ server1Params.put("port",
org.hornetq.integration.transports.netty.TransportConstants.DEFAULT_PORT + 1);
+ }
+ else
+ {
+ server1Params.put(SERVER_ID_PROP_NAME, 1);
+ }
+ HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, true,
server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -64,10 +89,8 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params);
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
server0.getConfiguration().setConnectorConfigurations(connectors);
@@ -196,11 +219,18 @@
// to be persisted
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createClusteredServerWithParams(0, true, server0Params);
+ HornetQServer server0 = createClusteredServerWithParams(isNetty(), 0, true,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- HornetQServer server1 = createClusteredServerWithParams(1, true, server1Params);
+ if (isNetty())
+ {
+ server1Params.put("port",
org.hornetq.integration.transports.netty.TransportConstants.DEFAULT_PORT + 1);
+ }
+ else
+ {
+ server1Params.put(SERVER_ID_PROP_NAME, 1);
+ }
+ HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, true,
server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -208,10 +238,8 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params);
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
server0.getConfiguration().setConnectorConfigurations(connectors);
@@ -387,11 +415,18 @@
public void testTargetServerNotAvailableNoReconnectTries() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createClusteredServerWithParams(0, false, server0Params);
+ HornetQServer server0 = createClusteredServerWithParams(isNetty(), 0, false,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- HornetQServer server1 = createClusteredServerWithParams(1, false, server1Params);
+ if (isNetty())
+ {
+ server1Params.put("port",
org.hornetq.integration.transports.netty.TransportConstants.DEFAULT_PORT + 1);
+ }
+ else
+ {
+ server1Params.put(SERVER_ID_PROP_NAME, 1);
+ }
+ HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, false,
server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -399,10 +434,8 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params);
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
server0.getConfiguration().setConnectorConfigurations(connectors);
@@ -516,11 +549,18 @@
public void testManualStopStart() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createClusteredServerWithParams(0, false, server0Params);
+ HornetQServer server0 = createClusteredServerWithParams(isNetty(), 0, false,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- HornetQServer server1 = createClusteredServerWithParams(1, false, server1Params);
+ if (isNetty())
+ {
+ server1Params.put("port",
org.hornetq.integration.transports.netty.TransportConstants.DEFAULT_PORT + 1);
+ }
+ else
+ {
+ server1Params.put(SERVER_ID_PROP_NAME, 1);
+ }
+ HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, false,
server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -528,10 +568,8 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- server1Params);
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
server0.getConfiguration().setConnectorConfigurations(connectors);
@@ -616,7 +654,7 @@
Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
log.info("stopping bridge manually");
-
+
bridge.stop();
for (int i = numMessages; i < numMessages * 2; i++)
@@ -633,10 +671,10 @@
bridge.start();
log.info("started bridge");
-
- //The previous messages will get resent, but with duplicate detection they will be
rejected
- //at the target
+ // The previous messages will get resent, but with duplicate detection they will be
rejected
+ // at the target
+
for (int i = numMessages; i < numMessages * 2; i++)
{
ClientMessage message = consumer1.receive(1000);
Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-13
20:52:21 UTC (rev 8283)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -32,6 +32,7 @@
import org.hornetq.core.config.cluster.QueueConfiguration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
@@ -48,7 +49,25 @@
public class BridgeTest extends ServiceTestBase
{
private static final Logger log = Logger.getLogger(BridgeTest.class);
+
+ protected boolean isNetty()
+ {
+ return false;
+ }
+ private String getConnector()
+ {
+ if (isNetty())
+ {
+ return NettyConnectorFactory.class.getName();
+ }
+ else
+ {
+ return "org.hornetq.core.remoting.impl.invm.InVMConnectorFactory";
+ }
+ }
+
+
public void testSimpleBridge() throws Exception
{
internaltestSimpleBridge(false, false);
@@ -77,11 +96,11 @@
try
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- server0 = createClusteredServerWithParams(0, useFiles, server0Params);
+ server0 = createClusteredServerWithParams(isNetty(), 0, useFiles,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- server1 = createClusteredServerWithParams(1, useFiles, server1Params);
+ addTargetParameters(server1Params);
+ server1 = createClusteredServerWithParams(isNetty(), 1, useFiles,
server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -89,10 +108,10 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
@@ -219,6 +238,21 @@
}
/**
+ * @param server1Params
+ */
+ private void addTargetParameters(Map<String, Object> server1Params)
+ {
+ if (isNetty())
+ {
+ server1Params.put("port",
org.hornetq.integration.transports.netty.TransportConstants.DEFAULT_PORT + 1);
+ }
+ else
+ {
+ server1Params.put(SERVER_ID_PROP_NAME, 1);
+ }
+ }
+
+ /**
* @param message
*/
private void readMessages(ClientMessage message)
@@ -260,11 +294,11 @@
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- server0 = createClusteredServerWithParams(0, useFiles, server0Params);
+ server0 = createClusteredServerWithParams(isNetty(), 0, useFiles,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- server1 = createClusteredServerWithParams(1, useFiles, server1Params);
+ addTargetParameters(server1Params);
+ server1 = createClusteredServerWithParams(isNetty(), 1, useFiles,
server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -272,9 +306,9 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
@@ -430,11 +464,11 @@
public void internaltestWithTransformer(boolean useFiles) throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createClusteredServerWithParams(0, false, server0Params);
+ HornetQServer server0 = createClusteredServerWithParams(isNetty(), 0, false,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- HornetQServer server1 = createClusteredServerWithParams(1, false, server1Params);
+ addTargetParameters(server1Params);
+ HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, false,
server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -442,9 +476,9 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
@@ -557,11 +591,11 @@
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- server0 = createClusteredServerWithParams(0, true, PAGE_SIZE, PAGE_MAX,
server0Params);
+ server0 = createClusteredServerWithParams(isNetty(), 0, true, PAGE_SIZE,
PAGE_MAX, server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- server1 = createClusteredServerWithParams(1, true, server1Params);
+ addTargetParameters(server1Params);
+ server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
@@ -569,10 +603,10 @@
final String queueName1 = "queue1";
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTestBase.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTestBase.java 2009-11-13
20:52:21 UTC (rev 8283)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTestBase.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -21,6 +21,8 @@
import org.hornetq.core.remoting.impl.invm.TransportConstants;
import org.hornetq.core.server.HornetQ;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.integration.transports.netty.NettyAcceptorFactory;
+import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
/**
@@ -34,12 +36,15 @@
*/
public abstract class BridgeTestBase extends UnitTestCase
{
- protected HornetQServer createHornetQServer(final int id, final Map<String,
Object> params)
+ protected HornetQServer createHornetQServer(final int id, final boolean netty, final
Map<String, Object> params)
{
- return createHornetQServer(id, params, false);
+ return createHornetQServer(id, params, netty, false);
}
- protected HornetQServer createHornetQServer(final int id, final Map<String,
Object> params, final boolean backup)
+ protected HornetQServer createHornetQServer(final int id,
+ final Map<String, Object> params,
+ final boolean netty,
+ final boolean backup)
{
Configuration serviceConf = new ConfigurationImpl();
serviceConf.setClustered(true);
@@ -51,10 +56,20 @@
serviceConf.setJournalDirectory(getJournalDir(id, false));
serviceConf.setPagingDirectory(getPageDir(id, false));
serviceConf.setLargeMessagesDirectory(getLargeMessagesDir(id, false));
-
- params.put(TransportConstants.SERVER_ID_PROP_NAME, id);
- serviceConf.getAcceptorConfigurations()
- .add(new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory",
params));
+
+ if (netty)
+ {
+
params.put(org.hornetq.integration.transports.netty.TransportConstants.PORT_PROP_NAME,
org.hornetq.integration.transports.netty.TransportConstants.DEFAULT_PORT + id);
+ serviceConf.getAcceptorConfigurations()
+ .add(new TransportConfiguration(NettyAcceptorFactory.class.getName(),
params));
+
+ }
+ else
+ {
+
params.put(org.hornetq.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME,
id);
+ serviceConf.getAcceptorConfigurations()
+ .add(new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory",
params));
+ }
HornetQServer service = HornetQ.newHornetQServer(serviceConf, true);
return service;
}
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java 2009-11-13
20:52:21 UTC (rev 8283)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -34,6 +34,9 @@
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.cluster.Bridge;
+import org.hornetq.integration.transports.netty.NettyAcceptorFactory;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.integration.transports.netty.TransportConstants;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
@@ -46,18 +49,31 @@
*/
public class BridgeWithDiscoveryGroupStartTest extends ServiceTestBase
{
+
+ protected boolean isNetty()
+ {
+ return false;
+ }
+
public void testStartStop() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
- HornetQServer server0 = createClusteredServerWithParams(0, true, server0Params);
+ HornetQServer server0 = createClusteredServerWithParams(isNetty(), 0, true,
server0Params);
Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(SERVER_ID_PROP_NAME, 1);
- HornetQServer server1 = createClusteredServerWithParams(1, true, server1Params);
+ if (isNetty())
+ {
+ server1Params.put("port", TransportConstants.DEFAULT_PORT + 1);
+ }
+ else
+ {
+ server1Params.put(SERVER_ID_PROP_NAME, 1);
+ }
+ HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, true,
server1Params);
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new
TransportConfiguration(InVMConnectorFactory.class.getName(), server0Params);
- TransportConfiguration server1tc = new
TransportConfiguration(InVMConnectorFactory.class.getName(), server1Params);
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
connectors.put(server1tc.getName(), server1tc);
server0.getConfiguration().setConnectorConfigurations(connectors);
@@ -201,4 +217,19 @@
server1.stop();
}
+
+ /**
+ * @return
+ */
+ private String getConnector()
+ {
+ if (isNetty())
+ {
+ return NettyConnectorFactory.class.getName();
+ }
+ else
+ {
+ return InVMConnectorFactory.class.getName();
+ }
+ }
}
Added:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeReconnectTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeReconnectTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeReconnectTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.cluster.bridge;
+
+/**
+ * A NettyBridgeReconnectTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class NettyBridgeReconnectTest extends BridgeReconnectTest
+{
+
+ // Constants -----------------------------------------------------
+
+ @Override
+ protected boolean isNetty()
+ {
+ return true;
+ }
+
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeStartTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeStartTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeStartTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.cluster.bridge;
+
+/**
+ * A NettyBridgeStartTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class NettyBridgeStartTest extends BridgeStartTest
+{
+
+ @Override
+ protected boolean isNetty()
+ {
+ return true;
+ }
+
+}
Added: trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.cluster.bridge;
+
+/**
+ * A NettyBridgeTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class NettyBridgeTest extends BridgeTest
+{
+ @Override
+ protected boolean isNetty()
+ {
+ return true;
+ }
+
+}
Added:
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeWithDiscoveryGroupStartTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeWithDiscoveryGroupStartTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/integration/cluster/bridge/NettyBridgeWithDiscoveryGroupStartTest.java 2009-11-14
05:58:59 UTC (rev 8284)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.cluster.bridge;
+
+/**
+ * A NettyBridgeWithDiscoveryGroupStartTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class NettyBridgeWithDiscoveryGroupStartTest extends
BridgeWithDiscoveryGroupStartTest
+{
+ @Override
+ protected boolean isNetty()
+ {
+ return true;
+ }
+}
Modified: trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2009-11-13 20:52:21 UTC
(rev 8283)
+++ trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2009-11-14 05:58:59 UTC
(rev 8284)
@@ -71,12 +71,12 @@
{
super();
}
-
+
public ServiceTestBase(String name)
{
super(name);
}
-
+
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
@@ -146,7 +146,6 @@
return createServer(realFiles, false);
}
-
protected HornetQServer createServer(final boolean realFiles, final boolean netty)
{
return createServer(realFiles, createDefaultConfig(netty), -1, -1, new
HashMap<String, AddressSettings>());
@@ -189,28 +188,52 @@
return server;
}
- protected HornetQServer createClusteredServerWithParams(final int index,
+ protected HornetQServer createClusteredServerWithParams(final boolean isNetty,
+ final int index,
final boolean realFiles,
final Map<String,
Object> params)
{
- return createServer(realFiles,
- createClusteredDefaultConfig(index, params,
INVM_ACCEPTOR_FACTORY),
- -1,
- -1,
- new HashMap<String, AddressSettings>());
+ if (isNetty)
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params,
NETTY_ACCEPTOR_FACTORY),
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>());
+ }
+ else
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params,
INVM_ACCEPTOR_FACTORY),
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>());
+ }
}
-
- protected HornetQServer createClusteredServerWithParams(final int index,
+
+ protected HornetQServer createClusteredServerWithParams(final boolean isNetty,
+ final int index,
final boolean realFiles,
final int pageSize,
final int maxAddressSize,
final Map<String,
Object> params)
{
- return createServer(realFiles,
- createClusteredDefaultConfig(index, params,
INVM_ACCEPTOR_FACTORY),
- pageSize,
- maxAddressSize,
- new HashMap<String, AddressSettings>());
+ if (isNetty)
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params,
NETTY_ACCEPTOR_FACTORY),
+ pageSize,
+ maxAddressSize,
+ new HashMap<String, AddressSettings>());
+ }
+ else
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params,
INVM_ACCEPTOR_FACTORY),
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>());
+ }
}
protected Configuration createDefaultConfig()
@@ -279,7 +302,7 @@
configuration.setLargeMessagesDirectory(getLargeMessagesDir());
configuration.setJournalCompactMinFiles(0);
configuration.setJournalCompactPercentage(0);
-
+
configuration.setFileDeploymentEnabled(false);
configuration.setJournalType(JournalType.ASYNCIO);
@@ -306,7 +329,7 @@
return createInVMFactory();
}
}
-
+
protected ClientSessionFactory createInVMFactory()
{
return createFactory(INVM_CONNECTOR_FACTORY);
@@ -355,7 +378,7 @@
message.getBody().writeBytes(b);
return message;
}
-
+
/**
* Deleting a file on LargeDire is an asynchronous process. Wee need to keep looking
for a while if the file hasn't been deleted yet
*/
@@ -387,7 +410,6 @@
validateNoFilesOnLargeDir(0);
}
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------