Author: borges
Date: 2011-12-07 06:23:31 -0500 (Wed, 07 Dec 2011)
New Revision: 11865
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/restart/ClusterRestartTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/HAClientTopologyTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/TopologyClusterTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
Log:
More tearDown improvements, and some reverts from previous refactorings
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2011-12-07
11:02:18 UTC (rev 11864)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2011-12-07
11:23:31 UTC (rev 11865)
@@ -1119,6 +1119,9 @@
{
InVMConnector.resetFailures();
+ closeServerLocator(locator);
+ stopComponent(service);
+
Assert.assertEquals(0, InVMRegistry.instance.size());
super.tearDown();
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/restart/ClusterRestartTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/restart/ClusterRestartTest.java 2011-12-07
11:02:18 UTC (rev 11864)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/restart/ClusterRestartTest.java 2011-12-07
11:23:31 UTC (rev 11865)
@@ -26,7 +26,7 @@
public class ClusterRestartTest extends ClusterTestBase
{
Logger log = Logger.getLogger(ClusterRestartTest.class);
-
+
public void testRestartWithQueuesCreateInDiffOrder() throws Exception
{
setupServer(0, isFileStorage(), isNetty());
@@ -41,9 +41,6 @@
System.out.println("server 0 = " + getServer(0).getNodeID());
System.out.println("server 1 = " + getServer(1).getNodeID());
- try
- {
-
setupSessionFactory(0, isNetty(), -1);
setupSessionFactory(1, isNetty());
@@ -79,30 +76,19 @@
// Waiting some time after stopped
Thread.sleep(2000);
startServers(0);
-
+
waitForBindings(0, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 0, true);
waitForBindings(0, "queues.testaddress", 1, 0, false);
waitForBindings(1, "queues.testaddress", 1, 1, false);
-
+
printBindings(2);
sendInRange(1, "queues.testaddress", 10, 20, false, null);
verifyReceiveAllInRange(0, 20, 0);
System.out.println("*****************************************************************************");
- }
- finally
- {
- closeAllConsumers();
-
- closeAllSessionFactories();
-
- closeAllServerLocatorsFactories();
-
- stopServers(0, 1);
- }
}
public void testRestartWithQueuesCreateInDiffOrder2() throws Exception
@@ -118,11 +104,7 @@
System.out.println("server 0 = " + getServer(0).getNodeID());
System.out.println("server 1 = " + getServer(1).getNodeID());
-
- try
- {
-
- setupSessionFactory(0, isNetty(), -1);
+ setupSessionFactory(0, isNetty(), -1);
setupSessionFactory(1, isNetty());
// create some dummy queues to ensure that the test queue has a high numbered
binding
@@ -160,24 +142,13 @@
waitForBindings(1, "queues.testaddress", 1, 0, true);
waitForBindings(0, "queues.testaddress", 1, 0, false);
waitForBindings(1, "queues.testaddress", 1, 0, false);
-
+
printBindings(2);
addConsumer(0, 1, "queue10", null);
addConsumer(1, 0, "queue10", null);
verifyReceiveRoundRobin(0, 20, 0, 1);
System.out.println("*****************************************************************************");
- }
- finally
- {
- closeAllConsumers();
-
- closeAllSessionFactories();
-
- closeAllServerLocatorsFactories();
-
- stopServers(0, 1);
- }
}
private void printBindings(final int num) throws Exception
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/HAClientTopologyTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/HAClientTopologyTest.java 2011-12-07
11:02:18 UTC (rev 11864)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/HAClientTopologyTest.java 2011-12-07
11:23:31 UTC (rev 11865)
@@ -57,7 +57,7 @@
protected ServerLocator createHAServerLocator()
{
TransportConfiguration tc = createTransportConfiguration(isNetty(), false,
generateParams(0, isNetty()));
- ServerLocator locator = HornetQClient.createServerLocatorWithHA(tc);
+ ServerLocator locator =
addServerLocator(HornetQClient.createServerLocatorWithHA(tc));
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
return locator;
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/TopologyClusterTestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/TopologyClusterTestBase.java 2011-12-07
11:02:18 UTC (rev 11864)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/TopologyClusterTestBase.java 2011-12-07
11:23:31 UTC (rev 11865)
@@ -66,14 +66,6 @@
setupCluster();
}
- @Override
- protected void tearDown() throws Exception
- {
- stopServers(0, 1, 2, 3, 4);
-
- super.tearDown();
- }
-
/**
* Check that the actual list of received nodeIDs correspond to the expected order of
nodes
*/
@@ -100,7 +92,7 @@
{
ok = (ok && actual.contains(nodeIDs[element]));
}
- if (ok)
+ if (ok)
{
return;
}
@@ -131,7 +123,7 @@
{
if (e.getCode() == HornetQException.OBJECT_CLOSED || e.getCode() ==
HornetQException.UNBLOCKED)
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
return sf.createSession();
}
else
@@ -171,17 +163,17 @@
Thread.sleep(10);
}
while (System.currentTimeMillis() - start < WAIT_TIMEOUT);
-
+
log.error(clusterDescription(servers[node]));
throw new IllegalStateException("Timed out waiting for cluster connections
");
}
-
+
public void testReceiveNotificationsWhenOtherNodesAreStartedAndStopped() throws
Throwable
{
startServers(0);
ServerLocator locator = createHAServerLocator();
-
+
((ServerLocatorImpl)locator).getTopology().setOwner("testReceive");
final List<String> nodes = new ArrayList<String>();
@@ -190,7 +182,7 @@
locator.addClusterTopologyListener(new ClusterTopologyListener()
{
- public void nodeUP(final long uniqueEventID,
+ public void nodeUP(final long uniqueEventID,
String nodeID,
Pair<TransportConfiguration, TransportConfiguration>
connectorPair,
boolean last)
@@ -226,7 +218,7 @@
}
});
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
startServers(1, 4, 3, 2);
String[] nodeIDs = getNodeIDs(0, 1, 2, 3, 4);
@@ -246,9 +238,9 @@
checkContains(new int[] { 0 }, nodeIDs, nodes);
sf.close();
-
+
locator.close();
-
+
stopServers(0);
}
@@ -265,7 +257,7 @@
locator.addClusterTopologyListener(new ClusterTopologyListener()
{
- public void nodeUP(final long uniqueEventID,
+ public void nodeUP(final long uniqueEventID,
String nodeID,
Pair<TransportConfiguration, TransportConfiguration>
connectorPair,
boolean last)
@@ -287,13 +279,13 @@
}
});
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
assertTrue("Was not notified that all servers are UP", upLatch.await(10,
SECONDS));
checkContains(new int[] { 0, 1, 2, 3, 4 }, nodeIDs, nodes);
ClientSession session = sf.createSession();
-
+
waitForClusterConnections(0, 4);
waitForClusterConnections(1, 4);
waitForClusterConnections(2, 4);
@@ -317,12 +309,12 @@
checkContains(new int[] { 1 }, nodeIDs, nodes);
stopServers(1);
-
+
assertTrue("Was not notified that all servers are DOWN",
downLatch.await(10, SECONDS));
checkContains(new int[] {}, nodeIDs, nodes);
sf.close();
-
+
locator.close();
}
@@ -358,7 +350,7 @@
}
});
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
assertTrue("Was not notified that all servers are UP", upLatch.await(10,
SECONDS));
checkContains(new int[] { 0, 1, 2, 3, 4 }, nodeIDs, nodes);
@@ -370,7 +362,7 @@
waitForClusterConnections(4, 4);
ClientSession session = sf.createSession();
-
+
stopServers(0);
assertFalse(servers[0].isStarted());
session = checkSessionOrReconnect(session, locator);
@@ -403,10 +395,10 @@
{
}
-
+
locator.close();
}
-
+
public void testMultipleClientSessionFactories() throws Throwable
{
startServers(0, 1, 2, 3, 4);
@@ -420,7 +412,7 @@
locator.addClusterTopologyListener(new ClusterTopologyListener()
{
- public void nodeUP(final long uniqueEventID, String nodeID,
+ public void nodeUP(final long uniqueEventID, String nodeID,
Pair<TransportConfiguration, TransportConfiguration>
connectorPair,
boolean last)
{
@@ -465,12 +457,12 @@
}
assertTrue("Was not notified that all servers are Down", ok);
checkContains(new int[] { 0 }, nodeIDs, nodes);
-
+
for (ClientSessionFactory sf : sfs)
{
sf.close();
}
-
+
locator.close();
stopServers(0);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java 2011-12-07
11:02:18 UTC (rev 11864)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java 2011-12-07
11:23:31 UTC (rev 11865)
@@ -45,6 +45,7 @@
import org.hornetq.api.jms.management.TopicControl;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.impl.invm.TransportConstants;
import org.hornetq.core.server.HornetQServer;
@@ -63,7 +64,7 @@
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* A BridgeTestBase
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -114,8 +115,7 @@
conf0.setJournalDirectory(getJournalDir(0, false));
conf0.setBindingsDirectory(getBindingsDir(0, false));
conf0.setSecurityEnabled(false);
- conf0.getAcceptorConfigurations()
- .add(new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
+ conf0.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName()));
server0 = HornetQServers.newHornetQServer(conf0, false);
context0 = new InVMContext();
@@ -129,8 +129,8 @@
conf1.setBindingsDirectory(getBindingsDir(1, false));
params1 = new HashMap<String, Object>();
params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
- conf1.getAcceptorConfigurations()
- .add(new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory",
params1));
+ conf1.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName(),
+ params1));
server1 = HornetQServers.newHornetQServer(conf1, false);
@@ -177,14 +177,11 @@
checkNoSubscriptions(sourceTopic, 0);
- jmsServer0.stop();
+ stopComponent(jmsServer0);
+ stopComponent(jmsServer1);
+ stopComponent(server1);
+ stopComponent(server0);
- jmsServer1.stop();
-
- server1.stop();
-
- server0.stop();
-
cff0 = cff1 = null;
cff0xa = cff1xa = null;
@@ -210,10 +207,10 @@
context0 = null;
context1 = null;
-
+
// Shutting down Arjuna threads
TxControl.disable(true);
-
+
TransactionReaper.terminate(false);
super.tearDown();
@@ -225,7 +222,7 @@
{
public ConnectionFactory createConnectionFactory() throws Exception
{
- HornetQConnectionFactory cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
+ HornetQConnectionFactory cf =
HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
new
TransportConfiguration(InVMConnectorFactory.class.getName()));
// Note! We disable automatic reconnection on the session factory. The bridge
needs to do the reconnection
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java 2011-12-07
11:02:18 UTC (rev 11864)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java 2011-12-07
11:23:31 UTC (rev 11865)
@@ -21,10 +21,6 @@
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
*/
public class JMSBridgeReconnectionTest extends BridgeTestBase
{