Author: ataylor
Date: 2010-11-22 08:11:45 -0500 (Mon, 22 Nov 2010)
New Revision: 9919
Modified:
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java
Log:
make sure bridge tests clearup resources
Modified:
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java 2010-11-22
10:53:44 UTC (rev 9918)
+++
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java 2010-11-22
13:11:45 UTC (rev 9919)
@@ -144,66 +144,76 @@
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
service2.getConfiguration().setQueueConfigurations(queueConfigs1);
- service2.start();
- server1.start();
- server0.start();
+ ServerLocator locator = null;
+ try
+ {
+ service2.start();
+ server1.start();
+ server0.start();
- BridgeReconnectTest.log.info("** failing connection");
- // Now we will simulate a failure of the bridge connection between server0 and
server1
- /*Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
- RemotingConnection forwardingConnection = getForwardingConnection(bridge);
- forwardingConnection.fail(new HornetQException(HornetQException.NOT_CONNECTED));*/
- server0.kill();
+ BridgeReconnectTest.log.info("** failing connection");
+ // Now we will simulate a failure of the bridge connection between server0 and
server1
+ /*Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
+ RemotingConnection forwardingConnection = getForwardingConnection(bridge);
+ forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));*/
+ server0.kill();
- waitForServerStart(service2);
+ waitForServerStart(service2);
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server2tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server2tc);
- ClientSessionFactory csf0 = locator.createSessionFactory(server2tc);
+ ClientSessionFactory csf0 = locator.createSessionFactory(server2tc);
- ClientSession session0 = csf0.createSession(false, true, true);
+ ClientSession session0 = csf0.createSession(false, true, true);
- ClientProducer prod0 = session0.createProducer(testAddress);
-
- ClientSessionFactory csf2 = locator.createSessionFactory(server2tc);
+ ClientProducer prod0 = session0.createProducer(testAddress);
- ClientSession session2 = csf2.createSession(false, true, true);
+ ClientSessionFactory csf2 = locator.createSessionFactory(server2tc);
- ClientConsumer cons2 = session2.createConsumer(queueName0);
+ ClientSession session2 = csf2.createSession(false, true, true);
- session2.start();
-
- final int numMessages = 10;
+ ClientConsumer cons2 = session2.createConsumer(queueName0);
- SimpleString propKey = new SimpleString("propkey");
+ session2.start();
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(true);
- message.putIntProperty(propKey, i);
+ final int numMessages = 10;
- prod0.send(message);
+ SimpleString propKey = new SimpleString("propkey");
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(true);
+ message.putIntProperty(propKey, i);
+
+ prod0.send(message);
+ }
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage r1 = cons2.receive(1500);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ }
+
+ session0.close();
+ session2.close();
}
+ finally
+ {
+ if (locator != null)
+ {
+ locator.close();
+ }
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage r1 = cons2.receive(1500);
- Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ server0.stop();
+ server1.stop();
+ service2.stop();
}
- session0.close();
- session2.close();
- locator.close();
-
- server0.stop();
- server1.stop();
- service2.stop();
-
Assert.assertEquals(0, server0.getRemotingService().getConnections().size());
Assert.assertEquals(0, server1.getRemotingService().getConnections().size());
Assert.assertEquals(0, service2.getRemotingService().getConnections().size());
@@ -283,56 +293,66 @@
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
service2.getConfiguration().setQueueConfigurations(queueConfigs1);
- service2.start();
- server1.start();
- server0.start();
- // Now we will simulate a failure of the bridge connection between server0 and
server1
- server0.kill();
+ ServerLocator locator = null;
+ try
+ {
+ service2.start();
+ server1.start();
+ server0.start();
+ // Now we will simulate a failure of the bridge connection between server0 and
server1
+ server0.kill();
- ServerLocator locator = HornetQClient.createServerLocatorWithHA(server2tc);
- locator.setReconnectAttempts(100);
- ClientSessionFactory csf0 = locator.createSessionFactory(server2tc);
- ClientSession session0 = csf0.createSession(false, true, true);
+ locator = HornetQClient.createServerLocatorWithHA(server2tc);
+ locator.setReconnectAttempts(100);
+ ClientSessionFactory csf0 = locator.createSessionFactory(server2tc);
+ ClientSession session0 = csf0.createSession(false, true, true);
- ClientSessionFactory csf2 = locator.createSessionFactory(server2tc);
- ClientSession session2 = csf2.createSession(false, true, true);
+ ClientSessionFactory csf2 = locator.createSessionFactory(server2tc);
+ ClientSession session2 = csf2.createSession(false, true, true);
- ClientProducer prod0 = session0.createProducer(testAddress);
+ ClientProducer prod0 = session0.createProducer(testAddress);
- ClientConsumer cons2 = session2.createConsumer(queueName0);
+ ClientConsumer cons2 = session2.createConsumer(queueName0);
- session2.start();
-
+ session2.start();
- final int numMessages = 10;
- SimpleString propKey = new SimpleString("propkey");
+ final int numMessages = 10;
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
- message.putIntProperty(propKey, i);
+ SimpleString propKey = new SimpleString("propkey");
- prod0.send(message);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
+ message.putIntProperty(propKey, i);
+
+ prod0.send(message);
+ }
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage r1 = cons2.receive(1500);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ }
+
+ session0.close();
+ session2.close();
}
+ finally
+ {
+ if (locator != null)
+ {
+ locator.close();
+ }
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage r1 = cons2.receive(1500);
- Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ server0.stop();
+ server1.stop();
+ service2.stop();
}
- session0.close();
- session2.close();
- locator.close();
-
- server0.stop();
- server1.stop();
- service2.stop();
-
Assert.assertEquals(0, server0.getRemotingService().getConnections().size());
Assert.assertEquals(0, server1.getRemotingService().getConnections().size());
Assert.assertEquals(0, service2.getRemotingService().getConnections().size());
@@ -401,59 +421,69 @@
queueConfigs1.add(queueConfig1);
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
- server1.start();
- server0.start();
+ ServerLocator locator = null;
+ try
+ {
+ server1.start();
+ server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithHA(server0tc,
server1tc);
- ClientSessionFactory csf0 = locator.createSessionFactory(server0tc);
- ClientSession session0 = csf0.createSession(false, true, true);
+ locator = HornetQClient.createServerLocatorWithHA(server0tc, server1tc);
+ ClientSessionFactory csf0 = locator.createSessionFactory(server0tc);
+ ClientSession session0 = csf0.createSession(false, true, true);
- ClientSessionFactory csf1 = locator.createSessionFactory(server1tc);
- ClientSession session1 = csf1.createSession(false, true, true);
+ ClientSessionFactory csf1 = locator.createSessionFactory(server1tc);
+ ClientSession session1 = csf1.createSession(false, true, true);
- ClientProducer prod0 = session0.createProducer(testAddress);
+ ClientProducer prod0 = session0.createProducer(testAddress);
- ClientConsumer cons1 = session1.createConsumer(queueName0);
+ ClientConsumer cons1 = session1.createConsumer(queueName0);
- session1.start();
+ session1.start();
- // Now we will simulate a failure of the bridge connection between server0 and
server1
- Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
- RemotingConnection forwardingConnection = getForwardingConnection(bridge);
- InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = reconnectAttempts - 1;
- forwardingConnection.fail(new HornetQException(HornetQException.NOT_CONNECTED));
+ // Now we will simulate a failure of the bridge connection between server0 and
server1
+ Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
+ RemotingConnection forwardingConnection = getForwardingConnection(bridge);
+ InVMConnector.failOnCreateConnection = true;
+ InVMConnector.numberOfFailures = reconnectAttempts - 1;
+ forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));
- forwardingConnection = getForwardingConnection(bridge);
- forwardingConnection.fail(new HornetQException(HornetQException.NOT_CONNECTED));
+ forwardingConnection = getForwardingConnection(bridge);
+ forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));
- final int numMessages = 10;
+ final int numMessages = 10;
- SimpleString propKey = new SimpleString("propkey");
+ SimpleString propKey = new SimpleString("propkey");
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
- message.putIntProperty(propKey, i);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
+ message.putIntProperty(propKey, i);
- prod0.send(message);
+ prod0.send(message);
+ }
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage r1 = cons1.receive(1500);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ }
+
+ session0.close();
+ session1.close();
}
+ finally
+ {
+ if (locator != null)
+ {
+ locator.close();
+ }
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage r1 = cons1.receive(1500);
- Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ server0.stop();
+ server1.stop();
}
- session0.close();
- session1.close();
- locator.close();
-
- server0.stop();
- server1.stop();
-
Assert.assertEquals(0, server0.getRemotingService().getConnections().size());
Assert.assertEquals(0, server1.getRemotingService().getConnections().size());
}
@@ -533,65 +563,75 @@
queueConfigs1.add(queueConfig1);
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
- server1.start();
- server0.start();
+ ServerLocator locator = null;
+ try
+ {
+ server1.start();
+ server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithHA(server0tc,
server1tc);
- ClientSessionFactory csf0 = locator.createSessionFactory(server0tc);
- ClientSession session0 = csf0.createSession(false, true, true);
+ locator = HornetQClient.createServerLocatorWithHA(server0tc, server1tc);
+ ClientSessionFactory csf0 = locator.createSessionFactory(server0tc);
+ ClientSession session0 = csf0.createSession(false, true, true);
- ClientProducer prod0 = session0.createProducer(testAddress);
+ ClientProducer prod0 = session0.createProducer(testAddress);
- BridgeReconnectTest.log.info("stopping server1");
- server1.stop();
+ BridgeReconnectTest.log.info("stopping server1");
+ server1.stop();
- if (sleep)
- {
- Thread.sleep(2 * clientFailureCheckPeriod);
- }
+ if (sleep)
+ {
+ Thread.sleep(2 * clientFailureCheckPeriod);
+ }
- BridgeReconnectTest.log.info("restarting server1");
- server1.start();
- BridgeReconnectTest.log.info("server 1 restarted");
+ BridgeReconnectTest.log.info("restarting server1");
+ server1.start();
+ BridgeReconnectTest.log.info("server 1 restarted");
- ClientSessionFactory csf1 = locator.createSessionFactory(server1tc);
- ClientSession session1 = csf1.createSession(false, true, true);
+ ClientSessionFactory csf1 = locator.createSessionFactory(server1tc);
+ ClientSession session1 = csf1.createSession(false, true, true);
- ClientConsumer cons1 = session1.createConsumer(queueName0);
+ ClientConsumer cons1 = session1.createConsumer(queueName0);
- session1.start();
+ session1.start();
- final int numMessages = 10;
+ final int numMessages = 10;
- SimpleString propKey = new SimpleString("propkey");
+ SimpleString propKey = new SimpleString("propkey");
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
- message.putIntProperty(propKey, i);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
+ message.putIntProperty(propKey, i);
- prod0.send(message);
- }
+ prod0.send(message);
+ }
- BridgeReconnectTest.log.info("sent messages");
+ BridgeReconnectTest.log.info("sent messages");
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage r1 = cons1.receive(30000);
- Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
- BridgeReconnectTest.log.info("got message " +
r1.getObjectProperty(propKey));
- }
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage r1 = cons1.receive(30000);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ BridgeReconnectTest.log.info("got message " +
r1.getObjectProperty(propKey));
+ }
- BridgeReconnectTest.log.info("got messages");
+ BridgeReconnectTest.log.info("got messages");
- session0.close();
- session1.close();
+ session0.close();
+ session1.close();
+ }
+ finally
+ {
+ if (locator != null)
+ {
+ locator.close();
+ }
- locator.close();
+ server0.stop();
+ server1.stop();
+ }
- server0.stop();
- server1.stop();
Assert.assertEquals(0, server0.getRemotingService().getConnections().size());
Assert.assertEquals(0, server1.getRemotingService().getConnections().size());
@@ -658,76 +698,86 @@
queueConfigs1.add(queueConfig1);
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
- server1.start();
- server0.start();
+ ServerLocator locator = null;
+ try
+ {
+ server1.start();
+ server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithHA(server0tc,
server1tc);
- ClientSessionFactory csf0 = locator.createSessionFactory(server0tc);
- ClientSession session0 = csf0.createSession(false, true, true);
+ locator = HornetQClient.createServerLocatorWithHA(server0tc, server1tc);
+ ClientSessionFactory csf0 = locator.createSessionFactory(server0tc);
+ ClientSession session0 = csf0.createSession(false, true, true);
- ClientSessionFactory csf1 = locator.createSessionFactory(server1tc);
- ClientSession session1 = csf1.createSession(false, true, true);
+ ClientSessionFactory csf1 = locator.createSessionFactory(server1tc);
+ ClientSession session1 = csf1.createSession(false, true, true);
- ClientProducer prod0 = session0.createProducer(testAddress);
+ ClientProducer prod0 = session0.createProducer(testAddress);
- ClientConsumer cons1 = session1.createConsumer(queueName0);
+ ClientConsumer cons1 = session1.createConsumer(queueName0);
- session1.start();
+ session1.start();
- Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
- RemotingConnection forwardingConnection = getForwardingConnection(bridge);
- InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = reconnectAttempts - 1;
- forwardingConnection.fail(new HornetQException(HornetQException.NOT_CONNECTED));
+ Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
+ RemotingConnection forwardingConnection = getForwardingConnection(bridge);
+ InVMConnector.failOnCreateConnection = true;
+ InVMConnector.numberOfFailures = reconnectAttempts - 1;
+ forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));
- final int numMessages = 10;
+ final int numMessages = 10;
- SimpleString propKey = new SimpleString("propkey");
+ SimpleString propKey = new SimpleString("propkey");
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
- message.putIntProperty(propKey, i);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
+ message.putIntProperty(propKey, i);
- prod0.send(message);
- }
+ prod0.send(message);
+ }
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage r1 = cons1.receive(1500);
- Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
- }
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage r1 = cons1.receive(1500);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ }
- // Fail again - should reconnect
- forwardingConnection = ((BridgeImpl)bridge).getForwardingConnection();
- InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = reconnectAttempts - 1;
- forwardingConnection.fail(new HornetQException(HornetQException.NOT_CONNECTED));
+ // Fail again - should reconnect
+ forwardingConnection = ((BridgeImpl)bridge).getForwardingConnection();
+ InVMConnector.failOnCreateConnection = true;
+ InVMConnector.numberOfFailures = reconnectAttempts - 1;
+ forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
- message.putIntProperty(propKey, i);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
+ message.putIntProperty(propKey, i);
- prod0.send(message);
+ prod0.send(message);
+ }
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage r1 = cons1.receive(1500);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ }
+
+ session0.close();
+ session1.close();
}
+ finally
+ {
+ if (locator != null)
+ {
+ locator.close();
+ }
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage r1 = cons1.receive(1500);
- Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ server0.stop();
+ server1.stop();
}
- session0.close();
- session1.close();
- locator.close();
-
- server0.stop();
- server1.stop();
-
Assert.assertEquals(0, server0.getRemotingService().getConnections().size());
Assert.assertEquals(0, server1.getRemotingService().getConnections().size());
}
Modified:
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2010-11-22
10:53:44 UTC (rev 9918)
+++
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2010-11-22
13:11:45 UTC (rev 9919)
@@ -79,7 +79,7 @@
server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
}
HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, true,
server1Params);
-
+ ServerLocator locator = null;
try
{
final String testAddress = "testAddress";
@@ -132,7 +132,7 @@
server1.start();
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
@@ -213,6 +213,11 @@
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
+
server0.stop();
server1.stop();
@@ -286,14 +291,14 @@
List<CoreQueueConfiguration> queueConfigs1 = new
ArrayList<CoreQueueConfiguration>();
queueConfigs1.add(queueConfig1);
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
-
+ ServerLocator locator = null;
try
{
// Don't start server 1 yet
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
@@ -422,6 +427,11 @@
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
+
server0.stop();
server1.stop();
@@ -448,7 +458,7 @@
final String queueName0 = "queue0";
final String forwardAddress = "forwardAddress";
final String queueName1 = "queue1";
-
+ ServerLocator locator = null;
try
{
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
@@ -497,7 +507,7 @@
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
@@ -564,10 +574,14 @@
sf0.close();
- locator.close();
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
+
server0.stop();
server1.stop();
@@ -595,7 +609,7 @@
final String queueName0 = "queue0";
final String forwardAddress = "forwardAddress";
final String queueName1 = "queue1";
-
+ ServerLocator locator = null;
try
{
Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
@@ -644,7 +658,7 @@
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
@@ -759,11 +773,13 @@
session0.close();
sf0.close();
-
- locator.close();
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
server0.stop();
server1.stop();
Modified:
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2010-11-22
10:53:44 UTC (rev 9918)
+++
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2010-11-22
13:11:45 UTC (rev 9919)
@@ -88,7 +88,7 @@
{
HornetQServer server0 = null;
HornetQServer server1 = null;
-
+ ServerLocator locator = null;
try
{
Map<String, Object> server0Params = new HashMap<String, Object>();
@@ -153,7 +153,7 @@
server1.start();
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
@@ -214,11 +214,13 @@
sf1.close();
- locator.close();
-
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
try
{
server0.stop();
@@ -290,7 +292,7 @@
{
HornetQServer server0 = null;
HornetQServer server1 = null;
-
+ ServerLocator locator = null;
try
{
@@ -350,7 +352,7 @@
server1.start();
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
@@ -430,12 +432,14 @@
sf0.close();
sf1.close();
-
- locator.close();
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
try
{
server0.stop();
@@ -520,72 +524,82 @@
queueConfigs1.add(queueConfig1);
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
- server1.start();
- server0.start();
+ ServerLocator locator = null;
+ try
+ {
+ server1.start();
+ server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
- ClientSession session0 = sf0.createSession(false, true, true);
+ ClientSession session0 = sf0.createSession(false, true, true);
- ClientSession session1 = sf1.createSession(false, true, true);
+ ClientSession session1 = sf1.createSession(false, true, true);
- ClientProducer producer0 = session0.createProducer(new SimpleString(testAddress));
+ ClientProducer producer0 = session0.createProducer(new
SimpleString(testAddress));
- ClientConsumer consumer1 = session1.createConsumer(queueName1);
+ ClientConsumer consumer1 = session1.createConsumer(queueName1);
- session1.start();
+ session1.start();
- final int numMessages = 10;
+ final int numMessages = 10;
- final SimpleString propKey = new SimpleString("wibble");
+ final SimpleString propKey = new SimpleString("wibble");
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
- message.putStringProperty(propKey, new SimpleString("bing"));
+ message.putStringProperty(propKey, new SimpleString("bing"));
- message.getBodyBuffer().writeString("doo be doo be doo be doo");
+ message.getBodyBuffer().writeString("doo be doo be doo be doo");
- producer0.send(message);
- }
+ producer0.send(message);
+ }
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = consumer1.receive(200);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = consumer1.receive(200);
- Assert.assertNotNull(message);
+ Assert.assertNotNull(message);
- SimpleString val = (SimpleString)message.getObjectProperty(propKey);
+ SimpleString val = (SimpleString)message.getObjectProperty(propKey);
- Assert.assertEquals(new SimpleString("bong"), val);
+ Assert.assertEquals(new SimpleString("bong"), val);
- String sval = message.getBodyBuffer().readString();
+ String sval = message.getBodyBuffer().readString();
- Assert.assertEquals("dee be dee be dee be dee", sval);
+ Assert.assertEquals("dee be dee be dee be dee", sval);
- message.acknowledge();
+ message.acknowledge();
- }
+ }
- Assert.assertNull(consumer1.receiveImmediate());
+ Assert.assertNull(consumer1.receiveImmediate());
- session0.close();
+ session0.close();
- session1.close();
+ session1.close();
- sf0.close();
+ sf0.close();
- sf1.close();
+ sf1.close();
+ }
+ finally
+ {
+ if (locator != null)
+ {
+ locator.close();
+ }
- locator.close();
+ server0.stop();
- server0.stop();
+ server1.stop();
+ }
- server1.stop();
}
public void testBridgeWithPaging() throws Exception
@@ -596,7 +610,7 @@
final int PAGE_MAX = 100 * 1024;
final int PAGE_SIZE = 10 * 1024;
-
+ ServerLocator locator = null;
try
{
@@ -656,7 +670,7 @@
server1.start();
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
@@ -705,11 +719,13 @@
sf1.close();
- locator.close();
-
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
try
{
server0.stop();
@@ -733,7 +749,7 @@
{
HornetQServer server0 = null;
HornetQServer server1 = null;
-
+ ServerLocator locator = null;
try
{
Map<String, Object> server0Params = new HashMap<String, Object>();
@@ -798,7 +814,7 @@
server1.start();
server0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
@@ -849,11 +865,13 @@
sf1.close();
- locator.close();
-
}
finally
{
+ if(locator != null)
+ {
+ locator.close();
+ }
try
{
server0.stop();
Modified:
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java 2010-11-22
10:53:44 UTC (rev 9918)
+++
branches/2_2_0_HA_Improvements_preMerge/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java 2010-11-22
13:11:45 UTC (rev 9919)
@@ -72,158 +72,168 @@
server1Params.put(org.hornetq.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME,
1);
}
HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, true,
server1Params);
+ ServerLocator locator = null;
+ try
+ {
+ Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
+ TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
+ connectors.put(server1tc.getName(), server1tc);
- Map<String, TransportConfiguration> connectors = new HashMap<String,
TransportConfiguration>();
- TransportConfiguration server0tc = new TransportConfiguration(getConnector(),
server0Params);
- TransportConfiguration server1tc = new TransportConfiguration(getConnector(),
server1Params);
- connectors.put(server1tc.getName(), server1tc);
+ server0.getConfiguration().setConnectorConfigurations(connectors);
- server0.getConfiguration().setConnectorConfigurations(connectors);
+ final String testAddress = "testAddress";
+ final String queueName0 = "queue0";
+ final String forwardAddress = "forwardAddress";
+ final String queueName1 = "queue1";
- final String testAddress = "testAddress";
- final String queueName0 = "queue0";
- final String forwardAddress = "forwardAddress";
- final String queueName1 = "queue1";
+ final String groupAddress = getUDPDiscoveryAddress();
+ final int port = getUDPDiscoveryPort();
- final String groupAddress = getUDPDiscoveryAddress();
- final int port = getUDPDiscoveryPort();
+ ArrayList<String> list = new ArrayList<String>();
+ list.add(server1tc.getName());
+ BroadcastGroupConfiguration bcConfig = new
BroadcastGroupConfiguration("bg1",
+ null,
+ -1,
+
groupAddress,
+ port,
+ 250,
+ list);
- ArrayList<String> list = new ArrayList<String>();
- list.add(server1tc.getName());
- BroadcastGroupConfiguration bcConfig = new
BroadcastGroupConfiguration("bg1",
- null,
- -1,
-
groupAddress,
- port,
- 250,
- list);
+ server0.getConfiguration().getBroadcastGroupConfigurations().add(bcConfig);
- server0.getConfiguration().getBroadcastGroupConfigurations().add(bcConfig);
+ DiscoveryGroupConfiguration dcConfig = new
DiscoveryGroupConfiguration("dg1", null, groupAddress, port, 5000, 5000);
- DiscoveryGroupConfiguration dcConfig = new
DiscoveryGroupConfiguration("dg1", null, groupAddress, port, 5000, 5000);
+
server0.getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig.getName(),
dcConfig);
-
server0.getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig.getName(),
dcConfig);
+ final String bridgeName = "bridge1";
- final String bridgeName = "bridge1";
+ ArrayList<String> staticConnectors = new ArrayList<String>();
+ staticConnectors.add(server1tc.getName());
+ BridgeConfiguration bridgeConfiguration = new BridgeConfiguration(bridgeName,
+ queueName0,
+
forwardAddress,
+ null,
+ null,
+ 1000,
+ 1d,
+ 0,
+ true,
+ 1024,
+
HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
+
staticConnectors,
+ false,
+
ConfigurationImpl.DEFAULT_CLUSTER_USER,
+
ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD);
- ArrayList<String> staticConnectors = new ArrayList<String>();
- staticConnectors.add(server1tc.getName());
- BridgeConfiguration bridgeConfiguration = new BridgeConfiguration(bridgeName,
- queueName0,
- forwardAddress,
- null,
- null,
- 1000,
- 1d,
- 0,
- true,
- 1024,
-
HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
-
staticConnectors,
- false,
-
ConfigurationImpl.DEFAULT_CLUSTER_USER,
-
ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD);
+ List<BridgeConfiguration> bridgeConfigs = new
ArrayList<BridgeConfiguration>();
+ bridgeConfigs.add(bridgeConfiguration);
+ server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
- List<BridgeConfiguration> bridgeConfigs = new
ArrayList<BridgeConfiguration>();
- bridgeConfigs.add(bridgeConfiguration);
- server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
+ CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration(testAddress,
queueName0, null, true);
+ List<CoreQueueConfiguration> queueConfigs0 = new
ArrayList<CoreQueueConfiguration>();
+ queueConfigs0.add(queueConfig0);
+ server0.getConfiguration().setQueueConfigurations(queueConfigs0);
- CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration(testAddress,
queueName0, null, true);
- List<CoreQueueConfiguration> queueConfigs0 = new
ArrayList<CoreQueueConfiguration>();
- queueConfigs0.add(queueConfig0);
- server0.getConfiguration().setQueueConfigurations(queueConfigs0);
+ CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration(forwardAddress,
queueName1, null, true);
+ List<CoreQueueConfiguration> queueConfigs1 = new
ArrayList<CoreQueueConfiguration>();
+ queueConfigs1.add(queueConfig1);
+ server1.getConfiguration().setQueueConfigurations(queueConfigs1);
- CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration(forwardAddress,
queueName1, null, true);
- List<CoreQueueConfiguration> queueConfigs1 = new
ArrayList<CoreQueueConfiguration>();
- queueConfigs1.add(queueConfig1);
- server1.getConfiguration().setQueueConfigurations(queueConfigs1);
+ server1.start();
+ server0.start();
- server1.start();
- server0.start();
+ locator = HornetQClient.createServerLocatorWithoutHA(server0tc, server1tc);
+ ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(server0tc,
server1tc);
- ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
+ ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
- ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
+ ClientSession session0 = sf0.createSession(false, true, true);
- ClientSession session0 = sf0.createSession(false, true, true);
+ ClientSession session1 = sf1.createSession(false, true, true);
- ClientSession session1 = sf1.createSession(false, true, true);
+ ClientProducer producer0 = session0.createProducer(new
SimpleString(testAddress));
- ClientProducer producer0 = session0.createProducer(new SimpleString(testAddress));
+ ClientConsumer consumer1 = session1.createConsumer(queueName1);
- ClientConsumer consumer1 = session1.createConsumer(queueName1);
+ session1.start();
- session1.start();
+ final int numMessages = 10;
- final int numMessages = 10;
+ final SimpleString propKey = new SimpleString("testkey");
- final SimpleString propKey = new SimpleString("testkey");
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
+ message.putIntProperty(propKey, i);
- message.putIntProperty(propKey, i);
+ producer0.send(message);
+ }
- producer0.send(message);
- }
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message =
consumer1.receive(BridgeWithDiscoveryGroupStartTest.TIMEOUT);
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message =
consumer1.receive(BridgeWithDiscoveryGroupStartTest.TIMEOUT);
+ Assert.assertNotNull(message);
- Assert.assertNotNull(message);
+ Assert.assertEquals(i, message.getObjectProperty(propKey));
- Assert.assertEquals(i, message.getObjectProperty(propKey));
+ message.acknowledge();
+ }
- message.acknowledge();
- }
+ Assert.assertNull(consumer1.receiveImmediate());
- Assert.assertNull(consumer1.receiveImmediate());
+ Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
- Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
+ bridge.stop();
- bridge.stop();
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createMessage(false);
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createMessage(false);
+ message.putIntProperty(propKey, i);
- message.putIntProperty(propKey, i);
+ producer0.send(message);
+ }
- producer0.send(message);
- }
+ Assert.assertNull(consumer1.receiveImmediate());
- Assert.assertNull(consumer1.receiveImmediate());
+ bridge.start();
- bridge.start();
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message =
consumer1.receive(BridgeWithDiscoveryGroupStartTest.TIMEOUT);
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message =
consumer1.receive(BridgeWithDiscoveryGroupStartTest.TIMEOUT);
+ Assert.assertNotNull(message);
- Assert.assertNotNull(message);
+ Assert.assertEquals(i, message.getObjectProperty(propKey));
- Assert.assertEquals(i, message.getObjectProperty(propKey));
+ message.acknowledge();
+ }
- message.acknowledge();
- }
+ Assert.assertNull(consumer1.receiveImmediate());
- Assert.assertNull(consumer1.receiveImmediate());
+ session0.close();
- session0.close();
+ session1.close();
- session1.close();
+ sf0.close();
- sf0.close();
+ sf1.close();
+ }
+ finally
+ {
+ if(locator != null)
+ {
+ locator.close();
+ }
+ server0.stop();
- sf1.close();
+ server1.stop();
+ }
- server0.stop();
-
- server1.stop();
}
/**