Author: borges
Date: 2011-12-05 10:08:01 -0500 (Mon, 05 Dec 2011)
New Revision: 11836
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReSendMessageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControl2Test.java
Log:
Move closing of resources to super.tearDown()
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReSendMessageTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReSendMessageTest.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReSendMessageTest.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -18,7 +18,6 @@
import java.util.List;
import javax.jms.BytesMessage;
-import javax.jms.Connection;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageConsumer;
@@ -30,7 +29,6 @@
import junit.framework.Assert;
-import org.hornetq.api.core.Pair;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.jms.HornetQJMSConstants;
@@ -62,9 +60,7 @@
public void testResendWithLargeMessage() throws Exception
{
- Connection conn = cf.createConnection();
- try
- {
+ conn = cf.createConnection();
conn.start();
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
@@ -96,21 +92,12 @@
}
internalTestResend(msgs, sess);
-
- }
- finally
- {
- conn.close();
- }
-
}
public void testResendWithMapMessagesOnly() throws Exception
{
- Connection conn = cf.createConnection();
- try
- {
- conn.start();
+ conn = cf.createConnection();
+ conn.start();
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
ArrayList<Message> msgs = new ArrayList<Message>();
@@ -137,13 +124,6 @@
}
internalTestResend(msgs, sess);
-
- }
- finally
- {
- conn.close();
- }
-
}
public void internalTestResend(final ArrayList<Message> msgs, final Session
sess) throws Exception
@@ -227,16 +207,10 @@
public static class SomeSerializable implements Serializable
{
- /**
- *
- */
private static final long serialVersionUID = -8576054940441747312L;
final String txt;
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode()
{
@@ -246,9 +220,6 @@
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(final Object obj)
{
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -22,21 +22,16 @@
import org.hornetq.api.core.TransportConfiguration;
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.api.core.management.AcceptorControl;
import org.hornetq.api.core.management.NotificationType;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.server.management.Notification;
import org.hornetq.tests.integration.SimpleNotificationService;
import org.hornetq.tests.util.RandomUtil;
-import javax.management.MBeanServer;
-
/**
* A AcceptorControlTest
*
@@ -178,9 +173,4 @@
{
return ManagementControlHelper.createAcceptorControl(name, mbeanServer);
}
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -50,8 +50,10 @@
protected AcceptorControl createManagementControl(final String name) throws Exception
{
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sf = locator.createSessionFactory();
+ addServerLocator(locator);
+ ClientSessionFactory sf = createSessionFactory(locator);
session = sf.createSession(false, true, true);
+ addClientSession(session);
session.start();
return new AcceptorControl()
@@ -69,6 +71,7 @@
return (String)proxy.retrieveAttributeValue("name");
}
+ @SuppressWarnings("unchecked")
public Map<String, Object> getParameters()
{
return (Map<String,
Object>)proxy.retrieveAttributeValue("parameters");
@@ -101,23 +104,4 @@
// the acceptor must be started to receive the management messages
}
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void tearDown() throws Exception
- {
- if (session != null)
- {
- session.close();
- }
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -36,7 +36,6 @@
import org.hornetq.core.security.CheckType;
import org.hornetq.core.security.Role;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
@@ -225,10 +224,12 @@
server.getAddressSettingsRepository().addMatch(address.toString(),
addressSettings);
server.start();
- ServerLocator locator2 = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sf2 = locator2.createSessionFactory();
- try
- {
+ ServerLocator locator2 =
+ HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(
+
UnitTestCase.INVM_CONNECTOR_FACTORY));
+ addServerLocator(locator2);
+ ClientSessionFactory sf2 = createSessionFactory(locator2);
+
session = sf2.createSession(false, true, false);
session.start();
session.createQueue(address, address, true);
@@ -266,12 +267,6 @@
session.commit();
Assert.assertEquals("# of pages is 2", 2,
addressControl.getNumberOfPages());
- }
- finally
- {
- closeSessionFactory(sf2);
- closeServerLocator(locator2);
- }
}
public void testGetNumberOfBytesPerPage() throws Exception
@@ -290,19 +285,15 @@
server.getAddressSettingsRepository().addMatch(address.toString(),
addressSettings);
server.start();
- ServerLocator locator2 = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sf2 = locator2.createSessionFactory();
- try
- {
+ ServerLocator locator2 =
+ HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(
+
UnitTestCase.INVM_CONNECTOR_FACTORY));
+ addServerLocator(locator2);
+ ClientSessionFactory sf2 = createSessionFactory(locator2);
+
session = sf2.createSession(false, true, false);
session.createQueue(address, address, true);
Assert.assertEquals(1024, addressControl.getNumberOfBytesPerPage());
- }
- finally
- {
- closeServerLocator(locator2);
- closeSessionFactory(sf2);
- }
}
// Package protected ---------------------------------------------
@@ -321,24 +312,15 @@
server = createServer(false, conf, mbeanServer);
server.start();
- locator = createInVMNonHALocator();
+ locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnNonDurableSend(true);
sf = createSessionFactory(locator);
session = sf.createSession(false, true, false);
session.start();
+ addClientSession(session);
}
- @Override
- protected void tearDown() throws Exception
- {
- if (session != null)
- session.close();
- session = null;
-
- super.tearDown();
- }
-
protected AddressControl createManagementControl(final SimpleString address) throws
Exception
{
return ManagementControlHelper.createAddressControl(address, mbeanServer);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -23,7 +23,6 @@
import junit.framework.Assert;
-import org.hornetq.api.core.Pair;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.HornetQClient;
@@ -47,7 +46,7 @@
* A BridgeControlTest
*
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
+ *
* Created 11 dec. 2008 17:38:58
*
*/
@@ -196,27 +195,14 @@
conf_0.getBridgeConfigurations().add(bridgeConfig);
server_1 = HornetQServers.newHornetQServer(conf_1,
MBeanServerFactory.createMBeanServer(), false);
+ addServer(server_1);
server_1.start();
server_0 = HornetQServers.newHornetQServer(conf_0, mbeanServer, false);
+ addServer(server_0);
server_0.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server_0.stop();
- server_1.stop();
-
- server_0 = null;
-
- bridgeConfig = null;
-
- server_1 = null;
-
- super.tearDown();
- }
-
protected BridgeControl createBridgeControl(final String name, final MBeanServer
mbeanServer) throws Exception
{
return ManagementControlHelper.createBridgeControl(name, mbeanServer);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -22,7 +22,6 @@
import junit.framework.Assert;
-import org.hornetq.api.core.Pair;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.ClientSessionFactory;
@@ -45,7 +44,7 @@
* A BridgeControlTest
*
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
+ *
* Created 11 dec. 2008 17:38:58
*
*/
@@ -173,42 +172,24 @@
conf_0.getQueueConfigurations().add(sourceQueueConfig);
conf_0.getBridgeConfigurations().add(bridgeConfig);
- server_1 = HornetQServers.newHornetQServer(conf_1,
MBeanServerFactory.createMBeanServer(), false);
+ server_1 = addServer(HornetQServers.newHornetQServer(conf_1,
MBeanServerFactory.createMBeanServer(), false));
server_1.start();
- server_0 = HornetQServers.newHornetQServer(conf_0, mbeanServer, false);
+ server_0 = addServer(HornetQServers.newHornetQServer(conf_0, mbeanServer, false));
server_0.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
- ClientSessionFactory sf = locator.createSessionFactory();
- session = sf.createSession(false, true, true);
+ ServerLocator locator =
+ addServerLocator(HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(
+
InVMConnectorFactory.class.getName())));
+ ClientSessionFactory sf = createSessionFactory(locator);
+ session = addClientSession(sf.createSession(false, true, true));
session.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- session.close();
- server_0.stop();
- server_1.stop();
- session = null;
-
- server_0 = null;
-
- server_1 = null;
-
- super.tearDown();
- }
-
protected CoreMessagingProxy createProxy(final String name) throws Exception
{
CoreMessagingProxy proxy = new CoreMessagingProxy(session,
ResourceNames.CORE_BRIDGE + name);
return proxy;
}
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
\ No newline at end of file
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -23,20 +23,18 @@
import org.hornetq.api.core.management.BroadcastGroupControl;
import org.hornetq.core.config.BroadcastGroupConfiguration;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
/**
* A AcceptorControlTest
*
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
+ *
* Created 11 dec. 2008 17:38:58
*
*
@@ -86,7 +84,7 @@
conf.getConnectorConfigurations().put(connectorConfiguration.getName(),
connectorConfiguration);
conf.getBroadcastGroupConfigurations().add(broadcastGroupConfig);
conf.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getName()));
- service = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+ service = addServer(HornetQServers.newHornetQServer(conf, mbeanServer, false));
service.start();
BroadcastGroupControl broadcastGroupControl =
createManagementControl(broadcastGroupConfig.getName());
@@ -99,7 +97,7 @@
Object[] connectorPairs = broadcastGroupControl.getConnectorPairs();
Assert.assertEquals(1, connectorPairs.length);
- System.out.println(connectorPairs);
+
String connectorPairData = (String)connectorPairs[0];
Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0),
connectorPairData);
String jsonString = broadcastGroupControl.getConnectorPairsAsJSON();
@@ -107,7 +105,7 @@
JSONArray array = new JSONArray(jsonString);
Assert.assertEquals(1, array.length());
Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0),
array.getString(0));
-
+
Assert.assertTrue(broadcastGroupControl.isStarted());
}
@@ -125,7 +123,7 @@
conf.getConnectorConfigurations().put(connectorConfiguration.getName(),
connectorConfiguration);
conf.getBroadcastGroupConfigurations().add(broadcastGroupConfig);
conf.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getName()));
- service = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+ service = addServer(HornetQServers.newHornetQServer(conf, mbeanServer, false));
service.start();
BroadcastGroupControl broadcastGroupControl =
createManagementControl(broadcastGroupConfig.getName());
@@ -140,22 +138,6 @@
Assert.assertTrue(broadcastGroupControl.isStarted());
}
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void tearDown() throws Exception
- {
- if (service != null)
- {
- service.stop();
- }
- service = null;
-
- super.tearDown();
- }
-
protected BroadcastGroupControl createManagementControl(final String name) throws
Exception
{
return ManagementControlHelper.createBroadcastGroupControl(name, mbeanServer);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControl2Test.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControl2Test.java 2011-12-05
14:48:36 UTC (rev 11835)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControl2Test.java 2011-12-05
15:08:01 UTC (rev 11836)
@@ -30,7 +30,6 @@
import org.hornetq.core.config.ClusterConnectionConfiguration;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.CoreQueueConfiguration;
-import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.remoting.impl.netty.TransportConstants;
@@ -42,7 +41,7 @@
* A BridgeControlTest
*
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
+ *
* Created 11 dec. 2008 17:38:58
*
*/
@@ -176,9 +175,9 @@
conf_0.getBroadcastGroupConfigurations().add(broadcastGroupConfig);
mbeanServer_1 = MBeanServerFactory.createMBeanServer();
- server_1 = HornetQServers.newHornetQServer(conf_1, mbeanServer_1, false);
+ server_1 = addServer(HornetQServers.newHornetQServer(conf_1, mbeanServer_1,
false));
- server_0 = HornetQServers.newHornetQServer(conf_0, mbeanServer, false);
+ server_0 = addServer(HornetQServers.newHornetQServer(conf_0, mbeanServer, false));
server_0.start();
}