Author: clebert.suconic(a)jboss.com
Date: 2009-11-20 10:03:21 -0500 (Fri, 20 Nov 2009)
New Revision: 8343
Modified:
branches/ClebertTemporary/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
Log:
Stopping a server on finalize
Modified:
branches/ClebertTemporary/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
===================================================================
---
branches/ClebertTemporary/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2009-11-20
15:01:10 UTC (rev 8342)
+++
branches/ClebertTemporary/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2009-11-20
15:03:21 UTC (rev 8343)
@@ -83,133 +83,140 @@
}
HornetQServer server1 = createClusteredServerWithParams(isNetty(), 1, true,
server1Params);
- final String testAddress = "testAddress";
- final String queueName0 = "queue0";
- final String forwardAddress = "forwardAddress";
- final String queueName1 = "queue1";
+ 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);
+ final String testAddress = "testAddress";
+ final String queueName0 = "queue0";
+ final String forwardAddress = "forwardAddress";
+ final String queueName1 = "queue1";
- server0.getConfiguration().setConnectorConfigurations(connectors);
+ 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);
- Pair<String, String> connectorPair = new Pair<String,
String>(server1tc.getName(), null);
+ server0.getConfiguration().setConnectorConfigurations(connectors);
- final String bridgeName = "bridge1";
+ Pair<String, String> connectorPair = new Pair<String,
String>(server1tc.getName(), null);
- BridgeConfiguration bridgeConfiguration = new BridgeConfiguration(bridgeName,
- queueName0,
- forwardAddress,
- null,
- null,
- 1000,
- 1d,
- 0,
- true,
- true,
- 1024,
- connectorPair);
+ final String bridgeName = "bridge1";
- List<BridgeConfiguration> bridgeConfigs = new
ArrayList<BridgeConfiguration>();
- bridgeConfigs.add(bridgeConfiguration);
- server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
+ BridgeConfiguration bridgeConfiguration = new BridgeConfiguration(bridgeName,
+ queueName0,
+
forwardAddress,
+ null,
+ null,
+ 1000,
+ 1d,
+ 0,
+ true,
+ true,
+ 1024,
+
connectorPair);
- QueueConfiguration queueConfig0 = new QueueConfiguration(testAddress, queueName0,
null, true);
- List<QueueConfiguration> queueConfigs0 = new
ArrayList<QueueConfiguration>();
- queueConfigs0.add(queueConfig0);
- server0.getConfiguration().setQueueConfigurations(queueConfigs0);
+ List<BridgeConfiguration> bridgeConfigs = new
ArrayList<BridgeConfiguration>();
+ bridgeConfigs.add(bridgeConfiguration);
+ server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
- QueueConfiguration queueConfig1 = new QueueConfiguration(forwardAddress,
queueName1, null, true);
- List<QueueConfiguration> queueConfigs1 = new
ArrayList<QueueConfiguration>();
- queueConfigs1.add(queueConfig1);
- server1.getConfiguration().setQueueConfigurations(queueConfigs1);
+ QueueConfiguration queueConfig0 = new QueueConfiguration(testAddress,
queueName0, null, true);
+ List<QueueConfiguration> queueConfigs0 = new
ArrayList<QueueConfiguration>();
+ queueConfigs0.add(queueConfig0);
+ server0.getConfiguration().setQueueConfigurations(queueConfigs0);
- server1.start();
- server0.start();
+ QueueConfiguration queueConfig1 = new QueueConfiguration(forwardAddress,
queueName1, null, true);
+ List<QueueConfiguration> queueConfigs1 = new
ArrayList<QueueConfiguration>();
+ queueConfigs1.add(queueConfig1);
+ server1.getConfiguration().setQueueConfigurations(queueConfigs1);
- ClientSessionFactory sf0 = new ClientSessionFactoryImpl(server0tc);
+ server1.start();
+ server0.start();
- ClientSessionFactory sf1 = new ClientSessionFactoryImpl(server1tc);
+ ClientSessionFactory sf0 = new ClientSessionFactoryImpl(server0tc);
- ClientSession session0 = sf0.createSession(false, true, true);
+ ClientSessionFactory sf1 = new ClientSessionFactoryImpl(server1tc);
- ClientSession session1 = sf1.createSession(false, true, true);
+ ClientSession session0 = sf0.createSession(false, true, true);
- ClientProducer producer0 = session0.createProducer(new SimpleString(testAddress));
+ ClientSession session1 = sf1.createSession(false, true, true);
- ClientConsumer consumer1 = session1.createConsumer(queueName1);
+ ClientProducer producer0 = session0.createProducer(new
SimpleString(testAddress));
- session1.start();
+ ClientConsumer consumer1 = session1.createConsumer(queueName1);
- final int numMessages = 10;
+ session1.start();
- final SimpleString propKey = new SimpleString("testkey");
+ final int numMessages = 10;
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createClientMessage(false);
+ final SimpleString propKey = new SimpleString("testkey");
- message.putIntProperty(propKey, i);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createClientMessage(false);
- producer0.send(message);
- }
+ message.putIntProperty(propKey, i);
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = consumer1.receive(200);
+ producer0.send(message);
+ }
- assertNotNull(message);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = consumer1.receive(200);
- assertEquals((Integer)i, (Integer)message.getObjectProperty(propKey));
+ assertNotNull(message);
- message.acknowledge();
- }
+ assertEquals((Integer)i, (Integer)message.getObjectProperty(propKey));
- assertNull(consumer1.receiveImmediate());
+ message.acknowledge();
+ }
- Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
+ assertNull(consumer1.receiveImmediate());
- bridge.stop();
+ Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session0.createClientMessage(false);
+ bridge.stop();
- message.putIntProperty(propKey, i);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session0.createClientMessage(false);
- producer0.send(message);
- }
+ message.putIntProperty(propKey, i);
- assertNull(consumer1.receiveImmediate());
+ producer0.send(message);
+ }
- bridge.start();
+ assertNull(consumer1.receiveImmediate());
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = consumer1.receive(1000);
+ bridge.start();
- assertNotNull(message);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = consumer1.receive(1000);
- assertEquals((Integer)i, (Integer)message.getObjectProperty(propKey));
+ assertNotNull(message);
- message.acknowledge();
- }
+ assertEquals((Integer)i, (Integer)message.getObjectProperty(propKey));
- assertNull(consumer1.receiveImmediate());
+ message.acknowledge();
+ }
- session0.close();
+ assertNull(consumer1.receiveImmediate());
- session1.close();
+ session0.close();
- sf0.close();
+ session1.close();
- sf1.close();
+ sf0.close();
- server0.stop();
+ sf1.close();
+ }
+ finally
+ {
- server1.stop();
+ server0.stop();
+
+ server1.stop();
+ }
}
public void testTargetServerUpAndDown() throws Exception