Author: borges
Date: 2011-12-02 10:45:51 -0500 (Fri, 02 Dec 2011)
New Revision: 11815
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
Log:
Close session factory on tearDown().
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-02
15:45:15 UTC (rev 11814)
+++
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-02
15:45:51 UTC (rev 11815)
@@ -101,34 +101,6 @@
}
}
- public static final void closeServerLocator(ServerLocator locator)
- {
- if (locator == null)
- return;
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public static final void closeSessionFactory(final ClientSessionFactory sf)
- {
- if (sf == null)
- return;
- try
- {
- sf.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
protected void waitForTopology(final HornetQServer server, final int nodes) throws
Exception
{
waitForTopology(server, nodes, WAIT_TIMEOUT);
@@ -228,21 +200,6 @@
}
}
- protected static final void stopComponent(HornetQComponent component)
- {
- if (component == null)
- return;
- if (component.isStarted())
- try
- {
- component.stop();
- }
- catch (Exception e)
- {
- // no-op
- }
- }
-
protected static Map<String, Object> generateParams(final int node, final
boolean netty)
{
Map<String, Object> params = new HashMap<String, Object>();
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-02
15:45:15 UTC (rev 11814)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-02
15:45:51 UTC (rev 11815)
@@ -56,6 +56,8 @@
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.ServerLocator;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.client.impl.ServerLocatorImpl;
@@ -81,6 +83,7 @@
import org.hornetq.core.remoting.impl.invm.InVMRegistry;
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
+import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.MessageReference;
@@ -1423,6 +1426,49 @@
}
+ protected static final void stopComponent(HornetQComponent component)
+ {
+ if (component == null)
+ return;
+ if (component.isStarted())
+ try
+ {
+ component.stop();
+ }
+ catch (Exception e)
+ {
+ // no-op
+ }
+ }
+
+ public static final void closeServerLocator(ServerLocator locator)
+ {
+ if (locator == null)
+ return;
+ try
+ {
+ locator.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static final void closeSessionFactory(final ClientSessionFactory sf)
+ {
+ if (sf == null)
+ return;
+ try
+ {
+ sf.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-12-02
15:45:15 UTC (rev 11814)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-12-02
15:45:51 UTC (rev 11815)
@@ -17,9 +17,14 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+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.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.tests.util.UnitTestCase;
@@ -30,9 +35,9 @@
public class WildCardRoutingTest extends UnitTestCase
{
private HornetQServer server;
-
- private ClientSession clientSession;
private ServerLocator locator;
+ private ClientSession clientSession;
+ private ClientSessionFactory sessionFactory;
public void testBasicWildcardRouting() throws Exception
{
@@ -766,7 +771,7 @@
server.getManagementService().enableNotifications(false);
// then we create a client as normal
locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ sessionFactory = locator.createSessionFactory();
clientSession = sessionFactory.createSession(false, true, true);
}
@@ -784,20 +789,12 @@
//
}
}
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e1)
- {
- //
- }
- }
+ closeSessionFactory(sessionFactory);
+ stopComponent(server);
+ closeServerLocator(locator);
+ locator = null;
server = null;
clientSession = null;
- locator.close();
super.tearDown();
}
}
Show replies by date