Author: borges
Date: 2011-12-05 07:43:14 -0500 (Mon, 05 Dec 2011)
New Revision: 11823
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
Log:
Keep track of created locators and session-factories and close them at tear down
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
---
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-05
09:45:18 UTC (rev 11822)
+++
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-05
12:43:14 UTC (rev 11823)
@@ -34,7 +34,6 @@
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.client.impl.Topology;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
@@ -86,11 +85,14 @@
@Override
protected void tearDown() throws Exception
{
- for (ServerLocator locator : locators)
+ synchronized (locators)
{
- closeServerLocator(locator);
+ for (ServerLocator locator : locators)
+ {
+ closeServerLocator(locator);
+ }
+ locators.clear();
}
- locators.clear();
super.tearDown();
// checkFreePort(5445);
// checkFreePort(5446);
@@ -584,15 +586,25 @@
{
ServerLocator locatorWithoutHA = isNetty ?
HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NETTY_CONNECTOR_FACTORY))
:
HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(INVM_CONNECTOR_FACTORY));
- locators.add(locatorWithoutHA);
+ addServerLocator(locatorWithoutHA);
return locatorWithoutHA;
}
+ private void addServerLocator(ServerLocator locator)
+ {
+ synchronized (locators)
+ {
+ locators.add(locator);
+ }
+ }
+
protected ServerLocator createInVMLocator(final int serverID)
{
TransportConfiguration tnspConfig = createInVMTransportConnectorConfig(serverID,
UUIDGenerator.getInstance().generateStringUUID());
- return HornetQClient.createServerLocatorWithHA(tnspConfig);
+ ServerLocator locator = HornetQClient.createServerLocatorWithHA(tnspConfig);
+ addServerLocator(locator);
+ return locator;
}
/**
@@ -612,13 +624,6 @@
return tnspConfig;
}
- // XXX unused
- protected ClientSessionFactoryImpl createFactory(final String connectorClass) throws
Exception
- {
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(connectorClass));
- return (ClientSessionFactoryImpl)locator.createSessionFactory();
-
- }
public String getTextMessage(final ClientMessage m)
{
m.getBodyBuffer().resetReaderIndex();
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-05
09:45:18 UTC (rev 11822)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-05
12:43:14 UTC (rev 11823)
@@ -31,6 +31,7 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.ClusterTopologyListener;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
@@ -83,6 +84,7 @@
protected boolean startBackupServer = true;
private final Collection<ServerLocator> serverLocators = new
ArrayList<ServerLocator>();
+ private final Collection<ClientSessionFactory> sessionFactories = new
ArrayList<ClientSessionFactory>();
// Static --------------------------------------------------------
@@ -236,6 +238,15 @@
stopComponent(backupServer);
stopComponent(liveServer);
+ synchronized (sessionFactories)
+ {
+ for (ClientSessionFactory sf : sessionFactories)
+ {
+ closeSessionFactory(sf);
+ }
+ sessionFactories.clear();
+ }
+
synchronized (serverLocators)
{
for (ServerLocator locator : serverLocators)
@@ -245,6 +256,7 @@
serverLocators.clear();
}
+
Assert.assertEquals(0, InVMRegistry.instance.size());
backupServer = null;
@@ -285,7 +297,10 @@
locator.addClusterTopologyListener(new
LatchClusterTopologyListener(countDownLatch));
sf = (ClientSessionFactoryInternal) locator.createSessionFactory();
-
+ synchronized (sessionFactories)
+ {
+ sessionFactories.add(sf);
+ }
assertTrue("topology members expected " + topologyMembers,
countDownLatch.await(5, TimeUnit.SECONDS));
return sf;
}
Show replies by date