Author: borges
Date: 2011-12-08 07:41:42 -0500 (Thu, 08 Dec 2011)
New Revision: 11878
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HornetQCrashTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/PredefinedQueueTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/StompWebSocketTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/stomp/StompStressTest.java
Log:
Improve tests' 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-08
12:41:11 UTC (rev 11877)
+++
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-08
12:41:42 UTC (rev 11878)
@@ -683,8 +683,8 @@
finally
{
session.close();
- sf.close();
- locator.close();
+ closeSessionFactory(sf);
+ closeServerLocator(locator);
}
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HornetQCrashTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HornetQCrashTest.java 2011-12-08
12:41:11 UTC (rev 11877)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HornetQCrashTest.java 2011-12-08
12:41:42 UTC (rev 11878)
@@ -25,9 +25,9 @@
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* From
https://jira.jboss.org/jira/browse/HORNETQ-144
- *
+ *
*/
public class HornetQCrashTest extends UnitTestCase
{
@@ -45,7 +45,7 @@
configuration.setSecurityEnabled(false);
configuration.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getName()));
- server = HornetQServers.newHornetQServer(configuration);
+ server = addServer(HornetQServers.newHornetQServer(configuration));
server.start();
@@ -105,6 +105,7 @@
new Thread()
{
+ @Override
public void run()
{
try
@@ -134,18 +135,7 @@
protected void setUp() throws Exception
{
super.setUp();
-
-
locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
+ addServerLocator(locator);
}
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
-
- server = null;
- }
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/PredefinedQueueTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/PredefinedQueueTest.java 2011-12-08
12:41:11 UTC (rev 11877)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/PredefinedQueueTest.java 2011-12-08
12:41:42 UTC (rev 11878)
@@ -21,7 +21,13 @@
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.CoreQueueConfiguration;
import org.hornetq.core.logging.Logger;
@@ -31,11 +37,11 @@
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A PredefinedQueueTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
+ *
* Created 19 Jan 2009 15:44:52
*
*
@@ -216,7 +222,7 @@
final String queueName3 = "queue3";
- HornetQServer server = HornetQServers.newHornetQServer(conf);
+ HornetQServer server = addServer(HornetQServers.newHornetQServer(conf));
server.start();
@@ -333,11 +339,11 @@
conf.setQueueConfigurations(queueConfs);
- HornetQServer server = HornetQServers.newHornetQServer(conf);
+ HornetQServer server = addServer(HornetQServers.newHornetQServer(conf));
server.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
+ ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory sf = locator.createSessionFactory();
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/StompWebSocketTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/StompWebSocketTest.java 2011-12-08
12:41:11 UTC (rev 11877)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/StompWebSocketTest.java 2011-12-08
12:41:42 UTC (rev 11878)
@@ -40,7 +40,7 @@
private static final transient Logger log =
Logger.getLogger(StompWebSocketTest.class);
private JMSServerManager server;
- /**
+ /**
* to test the Stomp over Web Sockets protocol,
* uncomment the sleep call and run the stomp-websockets Javascript test suite
* from
http://github.com/jmesnil/stomp-websocket
@@ -51,14 +51,15 @@
// Implementation methods
//-------------------------------------------------------------------------
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() throws Exception {
server = createServer();
server.start();
}
/**
* @return
- * @throws Exception
+ * @throws Exception
*/
private JMSServerManager createServer() throws Exception
{
@@ -73,14 +74,15 @@
config.getAcceptorConfigurations().add(stompTransport);
config.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getName()));
config.getQueueConfigurations().add(new CoreQueueConfiguration(getQueueName(),
getQueueName(), null, false));
- HornetQServer hornetQServer = HornetQServers.newHornetQServer(config);
-
+ HornetQServer hornetQServer = addServer(HornetQServers.newHornetQServer(config));
+
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
server = new JMSServerManagerImpl(hornetQServer, jmsConfig);
server.setContext(null);
return server;
}
+ @Override
protected void tearDown() throws Exception {
server.stop();
}
Modified:
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/stomp/StompStressTest.java
===================================================================
---
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/stomp/StompStressTest.java 2011-12-08
12:41:11 UTC (rev 11877)
+++
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/stomp/StompStressTest.java 2011-12-08
12:41:42 UTC (rev 11878)
@@ -25,8 +25,6 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.CoreQueueConfiguration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.stomp.Stomp;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
@@ -38,17 +36,15 @@
public class StompStressTest extends UnitTestCase
{
- private static final transient Logger log = Logger.getLogger(StompStressTest.class);
-
private static final int COUNT = 1000;
- private int port = 61613;
+ private final int port = 61613;
private Socket stompSocket;
private ByteArrayOutputStream inputBuffer;
- private String destination = "stomp.stress.queue";
+ private final String destination = "stomp.stress.queue";
private HornetQServer server;
@@ -86,6 +82,7 @@
// Implementation methods
// -------------------------------------------------------------------------
+ @Override
protected void setUp() throws Exception
{
super.setUp();
@@ -110,17 +107,16 @@
config.getAcceptorConfigurations().add(stompTransport);
config.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getName()));
config.getQueueConfigurations().add(new CoreQueueConfiguration(destination,
destination, null, false));
- return HornetQServers.newHornetQServer(config);
+ return addServer(HornetQServers.newHornetQServer(config));
}
+ @Override
protected void tearDown() throws Exception
{
if (stompSocket != null)
{
stompSocket.close();
}
- server.stop();
-
super.tearDown();
}
@@ -133,9 +129,9 @@
{
byte[] bytes = data.getBytes("UTF-8");
OutputStream outputStream = stompSocket.getOutputStream();
- for (int i = 0; i < bytes.length; i++)
+ for (byte b : bytes)
{
- outputStream.write(bytes[i]);
+ outputStream.write(b);
}
outputStream.flush();
}
@@ -143,9 +139,9 @@
public void sendFrame(byte[] data) throws Exception
{
OutputStream outputStream = stompSocket.getOutputStream();
- for (int i = 0; i < data.length; i++)
+ for (byte element : data)
{
- outputStream.write(data[i]);
+ outputStream.write(element);
}
outputStream.flush();
}