JBoss hornetq SVN: r11841 - in branches/Branch_2_2_EAP: docs/user-manual/en and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-12-05 16:17:25 -0500 (Mon, 05 Dec 2011)
New Revision: 11841
Modified:
branches/Branch_2_2_EAP/.classpath
branches/Branch_2_2_EAP/docs/user-manual/en/clusters.xml
branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java
Log:
Adding doc for JBPAPP-7455
Modified: branches/Branch_2_2_EAP/.classpath
===================================================================
--- branches/Branch_2_2_EAP/.classpath 2011-12-05 21:16:57 UTC (rev 11840)
+++ branches/Branch_2_2_EAP/.classpath 2011-12-05 21:17:25 UTC (rev 11841)
@@ -113,7 +113,7 @@
<classpathentry kind="lib" path="thirdparty/org/jboss/integration/lib/jboss-transaction-spi.jar"/>
<classpathentry kind="lib" path="thirdparty/org/jboss/javaee/lib/jboss-jaspi-api.jar"/>
<classpathentry kind="lib" path="thirdparty/org/jboss/javaee/lib/jboss-jca-api.jar"/>
- <classpathentry kind="lib" path="thirdparty/org/jboss/javaee/lib/jboss-jms-api.jar"/>
+ <classpathentry kind="lib" path="thirdparty/org/jboss/javaee/lib/jboss-jms-api.jar" sourcepath="/Users/clebertsuconic/.m2/repository/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA-sources.jar"/>
<classpathentry kind="lib" path="thirdparty/org/jboss/javaee/lib/jboss-transaction-api.jar"/>
<classpathentry kind="lib" path="thirdparty/org/jboss/lib/jboss-common-core.jar"/>
<classpathentry kind="lib" path="thirdparty/org/jboss/lib/jboss-mdr.jar"/>
Modified: branches/Branch_2_2_EAP/docs/user-manual/en/clusters.xml
===================================================================
--- branches/Branch_2_2_EAP/docs/user-manual/en/clusters.xml 2011-12-05 21:16:57 UTC (rev 11840)
+++ branches/Branch_2_2_EAP/docs/user-manual/en/clusters.xml 2011-12-05 21:17:25 UTC (rev 11841)
@@ -511,6 +511,16 @@
>false</literal>.</para>
</listitem>
<listitem>
+ <para><literal>min-large-message-size</literal>. This parameters determines when a
+ message should be splitted with multiple packages when sent over the cluster.</para>
+ <para>This parameter is optional and its default is at 100K.</para>
+ </listitem>
+ <listitem>
+ <para><literal>reconnect-attempts"</literal>.The number of times the system will
+ try to connect a node on the cluster. If the max-retry is achieved this node will be considered permanently down and the system will stop routing messages to this node.</para>
+ <para>This parameter is optional and its default is at -1 (infinite retries).</para>
+ </listitem>
+ <listitem>
<para><literal>max-hops</literal>. When a cluster connection decides the set of
nodes to which it might load balance a message, those nodes do not have to
be directly connected to it via a cluster connection. HornetQ can be
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java 2011-12-05 21:16:57 UTC (rev 11840)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/paging/impl/PageImpl.java 2011-12-05 21:17:25 UTC (rev 11841)
@@ -13,6 +13,7 @@
package org.hornetq.core.paging.impl;
+import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -115,9 +116,9 @@
ArrayList<PagedMessage> messages = new ArrayList<PagedMessage>();
size.set((int)file.size());
- // Using direct buffer, as described on https://jira.jboss.org/browse/HORNETQ-467
- ByteBuffer buffer2 = ByteBuffer.allocateDirect(size.get());
+ ByteBuffer buffer2 = allocateBuffer();
+
file.position(0);
file.read(buffer2);
@@ -175,6 +176,38 @@
return messages;
}
+ /**
+ * @return
+ * @throws InterruptedException
+ */
+ private ByteBuffer allocateBuffer() throws InterruptedException
+ {
+ // Using direct buffer, as described on https://jira.jboss.org/browse/HORNETQ-467
+ ByteBuffer buffer2 = null;
+ try
+ {
+ buffer2 = ByteBuffer.allocateDirect(size.get());
+ }
+ catch (OutOfMemoryError error)
+ {
+ // This is a workaround for the way the JDK will deal with native buffers.
+ // the main portion is outside of the VM heap
+ // and the JDK will not have any reference about it to take GC into account
+ // so we force a GC and try again.
+ WeakReference<Object> obj = new WeakReference<Object>(new Object());
+ long timeout = System.currentTimeMillis() + 5000;
+ while (System.currentTimeMillis() > timeout && obj.get() != null)
+ {
+ System.gc();
+ Thread.sleep(100);
+ }
+
+ buffer2 = ByteBuffer.allocateDirect(size.get());
+
+ }
+ return buffer2;
+ }
+
public void write(final PagedMessage message) throws Exception
{
ByteBuffer buffer = fileFactory.newBuffer(message.getEncodeSize() + PageImpl.SIZE_RECORD);
13 years, 1 month
JBoss hornetq SVN: r11840 - branches/Branch_2_2_AS7/docs/user-manual/en.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-12-05 16:16:57 -0500 (Mon, 05 Dec 2011)
New Revision: 11840
Modified:
branches/Branch_2_2_AS7/docs/user-manual/en/clusters.xml
Log:
Adding doc
Modified: branches/Branch_2_2_AS7/docs/user-manual/en/clusters.xml
===================================================================
--- branches/Branch_2_2_AS7/docs/user-manual/en/clusters.xml 2011-12-05 20:59:22 UTC (rev 11839)
+++ branches/Branch_2_2_AS7/docs/user-manual/en/clusters.xml 2011-12-05 21:16:57 UTC (rev 11840)
@@ -511,6 +511,16 @@
>false</literal>.</para>
</listitem>
<listitem>
+ <para><literal>min-large-message-size</literal>. This parameters determines when a
+ message should be splitted with multiple packages when sent over the cluster.</para>
+ <para>This parameter is optional and its default is at 100K.</para>
+ </listitem>
+ <listitem>
+ <para><literal>reconnect-attempts"</literal>.The number of times the system will
+ try to connect a node on the cluster. If the max-retry is achieved this node will be considered permanently down and the system will stop routing messages to this node.</para>
+ <para>This parameter is optional and its default is at -1 (infinite retries).</para>
+ </listitem>
+ <listitem>
<para><literal>max-hops</literal>. When a cluster connection decides the set of
nodes to which it might load balance a message, those nodes do not have to
be directly connected to it via a cluster connection. HornetQ can be
13 years, 1 month
JBoss hornetq SVN: r11839 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-12-05 15:59:22 -0500 (Mon, 05 Dec 2011)
New Revision: 11839
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java
Log:
avoiding races on test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java 2011-12-05 16:35:33 UTC (rev 11838)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java 2011-12-05 20:59:22 UTC (rev 11839)
@@ -47,6 +47,9 @@
try
{
startServers(2, 0, 1);
+ waitForTopology(servers[0], 2);
+ waitForTopology(servers[1], 2);
+ waitForTopology(servers[2], 2);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -124,6 +127,9 @@
try
{
startServers(2, 0, 1);
+ waitForTopology(servers[0], 2);
+ waitForTopology(servers[1], 2);
+ waitForTopology(servers[2], 2);
setupSessionFactory(0, isNetty());
13 years, 1 month
JBoss hornetq SVN: r11838 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-05 11:35:33 -0500 (Mon, 05 Dec 2011)
New Revision: 11838
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionFactoryTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionSendAcknowledgementHandlerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SimpleSendMultipleQueues.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TemporaryQueueTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionDurabilityTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionalSendTest.java
Log:
Close resources at super.tearDown()
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionFactoryTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionFactoryTest.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionFactoryTest.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -30,7 +30,6 @@
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.BroadcastGroupConfiguration;
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.server.HornetQServer;
@@ -38,7 +37,7 @@
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A ClientSessionFactoryTest
*
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
@@ -48,10 +47,9 @@
*/
public class SessionFactoryTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(SessionFactoryTest.class);
+ private final DiscoveryGroupConfiguration groupConfiguration =
+ new DiscoveryGroupConfiguration(getUDPDiscoveryAddress(), getUDPDiscoveryPort());
- private DiscoveryGroupConfiguration groupConfiguration = new DiscoveryGroupConfiguration(getUDPDiscoveryAddress(), getUDPDiscoveryPort());
-
private HornetQServer liveService;
private TransportConfiguration liveTC;
@@ -64,20 +62,6 @@
startServer();
}
- @Override
- protected void tearDown() throws Exception
- {
- if (liveService != null)
- {
- liveService.stop();
- }
-
- liveService = null;
- liveTC = null;
-
- super.tearDown();
- }
-
public void testSerializable() throws Exception
{
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName()));
@@ -101,7 +85,7 @@
Assert.assertNotNull(csi);
csi.close();
-
+
locator.close();
}
@@ -141,15 +125,15 @@
HornetQClient.DEFAULT_RETRY_INTERVAL,
HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
HornetQClient.DEFAULT_RECONNECT_ATTEMPTS);
-
+
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession session = cf.createSession(false, true, true);
Assert.assertNotNull(session);
session.close();
testSettersThrowException(cf);
-
+
cf.close();
-
+
locator.close();
}
@@ -182,13 +166,13 @@
HornetQClient.DEFAULT_RETRY_INTERVAL,
HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
HornetQClient.DEFAULT_RECONNECT_ATTEMPTS);
-
+
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession session = cf.createSession(false, true, true);
Assert.assertNotNull(session);
session.close();
testSettersThrowException(cf);
-
+
cf.close();
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionSendAcknowledgementHandlerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionSendAcknowledgementHandlerTest.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionSendAcknowledgementHandlerTest.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -20,8 +20,12 @@
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+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.SendAcknowledgementHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -29,15 +33,13 @@
* A SendAcknowledgementsTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
+ *
* Created 9 Feb 2009 13:29:19
*
*
*/
public class SessionSendAcknowledgementHandlerTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(SessionSendAcknowledgementHandlerTest.class);
-
private HornetQServer server;
private final SimpleString address = new SimpleString("address");
@@ -53,26 +55,13 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- if (server != null && server.isStarted())
- {
- server.stop();
- }
-
- server = null;
-
- super.tearDown();
- }
-
public void testSetInvalidSendACK() throws Exception
{
ServerLocator locator = createInVMNonHALocator();
locator.setConfirmationWindowSize(-1);
- ClientSessionFactory csf = locator.createSessionFactory();
+ ClientSessionFactory csf = createSessionFactory(locator);
ClientSession session = csf.createSession(null, null, false, true, true, false, 1);
try
@@ -119,7 +108,7 @@
locator.setConfirmationWindowSize(windowSize);
- ClientSessionFactory csf = locator.createSessionFactory();
+ ClientSessionFactory csf = createSessionFactory(locator);
ClientSession session = csf.createSession(null, null, false, true, true, false, 1);
session.createQueue(address, queueName, false);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -18,7 +18,13 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-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.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -42,27 +48,13 @@
super.setUp();
server = createServer(false);
-
server.start();
-
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
public void testStopStartConsumerSyncReceiveImmediate() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -106,7 +98,7 @@
public void testStopStartConsumerSyncReceive() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -153,7 +145,7 @@
public void testStopStartConsumerAsyncSyncStoppedByHandler() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -243,7 +235,7 @@
public void testStopStartConsumerAsyncSync() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -341,7 +333,7 @@
public void testStopStartConsumerAsyncASyncStoppeeByHandler() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -443,7 +435,7 @@
public void testStopStartConsumerAsyncASync() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -560,7 +552,7 @@
public void testStopStartMultipleConsumers() throws Exception
{
locator.setConsumerWindowSize(getMessageEncodeSize(QUEUE) * 33);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -613,7 +605,7 @@
public void testStopStartAlreadyStartedSession() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -654,7 +646,7 @@
public void testStopAlreadyStoppedSession() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionTest.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionTest.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -58,19 +58,10 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- stopComponent(server);
- closeSessionFactory(cf);
- closeServerLocator(locator);
- super.tearDown();
- }
-
public void testFailureListener() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
final CountDownLatch latch = new CountDownLatch(1);
clientSession.addFailureListener(new SessionFailureListener()
@@ -96,7 +87,7 @@
public void testFailureListenerRemoved() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
class MyFailureListener implements SessionFailureListener
{
@@ -130,7 +121,7 @@
long ttl = 500;
server.getConfiguration().setConnectionTTLOverride(ttl);
server.start();
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
clientSession.createQueue(queueName, queueName, false);
ClientProducer producer = clientSession.createProducer();
@@ -168,7 +159,7 @@
public void testBindingQuery() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
clientSession.createQueue("a1", "q1", false);
clientSession.createQueue("a1", "q2", false);
@@ -194,7 +185,7 @@
public void testQueueQuery() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
clientSession.createQueue("a1", queueName, false);
clientSession.createConsumer(queueName);
@@ -212,7 +203,7 @@
public void testQueueQueryWithFilter() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
clientSession.createQueue("a1", queueName, "foo=bar", false);
clientSession.createConsumer(queueName);
@@ -227,7 +218,7 @@
public void testQueueQueryNoQ() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
Assert.assertFalse(resp.isExists());
@@ -237,7 +228,7 @@
public void testClose() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
clientSession.createQueue(queueName, queueName, false);
ClientProducer p = clientSession.createProducer();
@@ -254,7 +245,7 @@
public void testCreateMessageNonDurable() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
ClientMessage clientMessage = clientSession.createMessage(false);
Assert.assertFalse(clientMessage.isDurable());
@@ -263,7 +254,7 @@
public void testCreateMessageDurable() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
ClientMessage clientMessage = clientSession.createMessage(true);
Assert.assertTrue(clientMessage.isDurable());
@@ -272,7 +263,7 @@
public void testCreateMessageType() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
ClientMessage clientMessage = clientSession.createMessage((byte)99, false);
Assert.assertEquals((byte)99, clientMessage.getType());
@@ -281,7 +272,7 @@
public void testCreateMessageOverrides() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
ClientMessage clientMessage = clientSession.createMessage((byte)88, false, 100l, 300l, (byte)33);
Assert.assertEquals((byte)88, clientMessage.getType());
@@ -293,7 +284,7 @@
public void testGetVersion() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
Assert.assertEquals(server.getVersion().getIncrementingVersion(), clientSession.getVersion());
clientSession.close();
@@ -301,7 +292,7 @@
public void testStart() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
clientSession.createQueue(queueName, queueName, false);
clientSession.start();
@@ -310,7 +301,7 @@
public void testStop() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, true, true);
clientSession.createQueue(queueName, queueName, false);
clientSession.start();
@@ -320,7 +311,7 @@
public void testCommitWithSend() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, false, true);
clientSession.createQueue(queueName, queueName, false);
ClientProducer cp = clientSession.createProducer(queueName);
@@ -343,7 +334,7 @@
public void testRollbackWithSend() throws Exception
{
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession clientSession = cf.createSession(false, false, true);
clientSession.createQueue(queueName, queueName, false);
ClientProducer cp = clientSession.createProducer(queueName);
@@ -371,7 +362,7 @@
{
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
ClientProducer cp = sendSession.createProducer(queueName);
ClientSession clientSession = cf.createSession(false, true, false);
@@ -430,7 +421,7 @@
{
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
- cf = locator.createSessionFactory();
+ cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
ClientProducer cp = sendSession.createProducer(queueName);
ClientSession clientSession = cf.createSession(false, true, false);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SimpleSendMultipleQueues.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SimpleSendMultipleQueues.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SimpleSendMultipleQueues.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -14,14 +14,18 @@
import junit.framework.Assert;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+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.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A SimpleSendMultipleQueues
*
* @author Tim Fox
@@ -30,8 +34,6 @@
*/
public class SimpleSendMultipleQueues extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(SimpleSendMultipleQueues.class);
-
public static final String address = "testaddress";
public static final String queueName = "testqueue";
@@ -89,7 +91,7 @@
locator = createNettyNonHALocator();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
session = cf.createSession();
@@ -124,15 +126,8 @@
session.deleteQueue("queue3");
session.close();
-
- locator.close();
}
- if (server.isStarted())
- {
- server.stop();
- }
-
super.tearDown();
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TemporaryQueueTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TemporaryQueueTest.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TemporaryQueueTest.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -32,7 +32,6 @@
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.MessageHandler;
import org.hornetq.api.core.client.ServerLocator;
-import org.hornetq.core.client.impl.ClientProducerCreditsImpl;
import org.hornetq.core.client.impl.ClientProducerImpl;
import org.hornetq.core.client.impl.ClientSessionInternal;
import org.hornetq.core.config.Configuration;
@@ -105,8 +104,8 @@
session.close();
}
-
+
public void testMemoryLeakOnAddressSettingForTemporaryQueue() throws Exception
{
for (int i = 0 ; i < 1000; i++)
@@ -114,21 +113,21 @@
SimpleString queue = RandomUtil.randomSimpleString();
SimpleString address = RandomUtil.randomSimpleString();
session.createTemporaryQueue(address, queue);
-
+
session.close();
session = sf.createSession();
}
-
-
+
+
session.close();
-
+
sf.close();
-
+
System.out.println("size = " + server.getAddressSettingsRepository().getCacheSize());
-
+
assertTrue(server.getAddressSettingsRepository().getCacheSize() < 10);
}
-
+
public void testPaginStoreIsRemovedWhenQueueIsDeleted() throws Exception
{
SimpleString queue = RandomUtil.randomSimpleString();
@@ -148,7 +147,7 @@
message.acknowledge();
SimpleString[] storeNames = server.getPostOffice().getPagingManager().getStoreNames();
- assertTrue(Arrays.asList(storeNames).contains(address));
+ assertTrue(Arrays.asList(storeNames).contains(address));
consumer.close();
session.deleteQueue(queue);
@@ -158,7 +157,7 @@
session.close();
}
-
+
public void testConsumeFromTemporaryQueueCreatedByOtherSession() throws Exception
{
SimpleString queue = RandomUtil.randomSimpleString();
@@ -204,7 +203,7 @@
// wait for the closing listeners to be fired
Assert.assertTrue("connection close listeners not fired", latch.await(2 * TemporaryQueueTest.CONNECTION_TTL,
TimeUnit.MILLISECONDS));
-
+
sf = locator.createSessionFactory();
session = sf.createSession(false, true, true);
session.start();
@@ -228,37 +227,37 @@
session.createQueue("a.b", "queue1");
session.createTemporaryQueue("a.#", "queue2");
session.createTemporaryQueue("a.#", "queue3");
-
+
ClientProducer producer = session.createProducer("a.b");
producer.send(session.createMessage(false));
-
+
ClientConsumer cons = session.createConsumer("queue2");
session.start();
-
+
ClientMessage msg = cons.receive(5000);
-
+
assertNotNull(msg);
-
+
msg.acknowledge();
-
+
cons.close();
cons = session.createConsumer("queue3");
session.start();
-
+
msg = cons.receive(5000);
-
+
assertNotNull(msg);
-
+
msg.acknowledge();
-
+
cons.close();
session.deleteQueue("queue2");
session.deleteQueue("queue3");
-
+
session.close();
}
@@ -268,37 +267,37 @@
session.createQueue("a.b", "queue1");
session.createTemporaryQueue("a.#", "queue2");
session.createTemporaryQueue("a.#", "queue3");
-
+
ClientProducer producer = session.createProducer("a.b");
producer.send(session.createMessage(false));
-
+
ClientConsumer cons = session.createConsumer("queue2");
session.start();
-
+
ClientMessage msg = cons.receive(5000);
-
+
assertNotNull(msg);
-
+
msg.acknowledge();
-
+
cons.close();
cons = session.createConsumer("queue3");
session.start();
-
+
msg = cons.receive(5000);
-
+
assertNotNull(msg);
-
+
msg.acknowledge();
-
+
cons.close();
session.deleteQueue("queue2");
session.deleteQueue("queue3");
-
+
session.close();
}
@@ -312,7 +311,7 @@
}
/**
- * @see org.hornetq.core.server.impl.ServerSessionImpl#doHandleCreateQueue(org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage)
+ * @see org.hornetq.core.server.impl.ServerSessionImpl#doHandleCreateQueue(org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage)
*/
public void testDeleteTemporaryQueueAfterConnectionIsClosed_2() throws Exception
{
@@ -333,11 +332,11 @@
session2.start();
- ClientConsumer consumer = session2.createConsumer(queue);
+ session2.createConsumer(queue);
session2.close();
}
-
+
public void testRecreateConsumerOverServerFailure() throws Exception
{
ServerLocator serverWithReattach = createLocator();
@@ -345,60 +344,60 @@
serverWithReattach.setRetryInterval(1000);
serverWithReattach.setConfirmationWindowSize(-1);
ClientSessionFactory reattachSF = serverWithReattach.createSessionFactory();
-
+
ClientSession session = reattachSF.createSession(false, false);
session.createTemporaryQueue("tmpAd", "tmpQ");
ClientConsumer consumer = session.createConsumer("tmpQ");
-
+
ClientProducer prod = session.createProducer("tmpAd");
-
+
session.start();
-
+
RemotingConnectionImpl conn = (RemotingConnectionImpl)((ClientSessionInternal)session).getConnection();
conn.fail(new HornetQException(HornetQException.IO_ERROR));
-
+
prod.send(session.createMessage(false));
session.commit();
-
+
assertNotNull(consumer.receive(1000));
-
+
session.close();
-
+
reattachSF.close();
-
+
serverWithReattach.close();
-
-
+
+
}
-
+
public void testTemoraryQueuesWithFilter() throws Exception
{
-
+
int countTmpQueue=0;
-
+
final AtomicInteger errors = new AtomicInteger(0);
-
+
class MyHandler implements MessageHandler
{
final String color;
-
+
final CountDownLatch latch;
-
+
final ClientSession sess;
-
+
public MyHandler(ClientSession sess, String color, int expectedMessages)
{
this.sess = sess;
latch = new CountDownLatch(expectedMessages);
this.color = color;
}
-
+
public boolean waitCompletion() throws Exception
{
return latch.await(10, TimeUnit.SECONDS);
}
-
+
public void onMessage(ClientMessage message)
{
try
@@ -406,7 +405,7 @@
message.acknowledge();
sess.commit();
latch.countDown();
-
+
if (!message.getStringProperty("color").equals(color))
{
log.warn("Unexpected color " + message.getStringProperty("color") + " when we were expecting " + color);
@@ -419,28 +418,28 @@
errors.incrementAndGet();
}
}
-
+
}
-
+
String address = "AD_test";
int iterations = 100;
int msgs = 100;
-
+
// Will be using a single Session as this is how an issue was raised
for (int i = 0 ; i < iterations; i++)
{
ClientSessionFactory clientsConnecton = locator.createSessionFactory();
ClientSession localSession = clientsConnecton.createSession();
-
+
ClientProducer prod = localSession.createProducer(address);
-
+
localSession.start();
-
+
log.info("Iteration " + i);
String queueRed = address + "_red_" + (countTmpQueue++);
String queueBlue = address + "_blue_" + (countTmpQueue++);
-
+
//ClientSession sessConsumerRed = clientsConnecton.createSession();
ClientSession sessConsumerRed = localSession;
sessConsumerRed.createTemporaryQueue(address, queueRed, "color='red'");
@@ -448,7 +447,7 @@
ClientConsumer redClientConsumer = sessConsumerRed.createConsumer(queueRed);
redClientConsumer.setMessageHandler(redHandler);
//sessConsumerRed.start();
-
+
//ClientSession sessConsumerBlue = clientsConnecton.createSession();
ClientSession sessConsumerBlue = localSession;
sessConsumerBlue.createTemporaryQueue(address, queueBlue, "color='blue'");
@@ -456,7 +455,7 @@
ClientConsumer blueClientConsumer = sessConsumerBlue.createConsumer(queueBlue);
blueClientConsumer.setMessageHandler(blueHandler);
//sessConsumerBlue.start();
-
+
try
{
ClientMessage msgBlue = session.createMessage(false);
@@ -468,17 +467,17 @@
for (int nmsg = 0; nmsg < msgs; nmsg++)
{
prod.send(msgBlue);
-
+
prod.send(msgRed);
-
+
session.commit();
}
-
+
blueHandler.waitCompletion();
redHandler.waitCompletion();
-
+
assertEquals(0, errors.get());
-
+
}
finally
{
@@ -488,14 +487,14 @@
clientsConnecton.close();
}
}
-
+
}
public void testDeleteTemporaryQueueWhenClientCrash() throws Exception
{
session.close();
sf.close();
-
+
final SimpleString queue = RandomUtil.randomSimpleString();
SimpleString address = RandomUtil.randomSimpleString();
@@ -568,33 +567,34 @@
locator2.close();
}
-
+
public void testBlockingWithTemporaryQueue() throws Exception
{
-
+
AddressSettings setting = new AddressSettings();
setting.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
setting.setMaxSizeBytes(1024 * 1024);
-
+
server.getAddressSettingsRepository().addMatch("TestAD", setting);
-
+
ClientSessionFactory consumerCF = locator.createSessionFactory();
ClientSession consumerSession = consumerCF.createSession(true, true);
consumerSession.addMetaData("consumer", "consumer");
consumerSession.createTemporaryQueue("TestAD", "Q1");
- ClientConsumer consumer = consumerSession.createConsumer("Q1");
+ consumerSession.createConsumer("Q1");
consumerSession.start();
-
+
final ClientProducerImpl prod = (ClientProducerImpl)session.createProducer("TestAD");
-
+
final AtomicInteger errors = new AtomicInteger(0);
-
+
final AtomicInteger msgs = new AtomicInteger(0);
-
+
final int TOTAL_MSG = 1000;
-
+
Thread t = new Thread()
{
+ @Override
public void run()
{
try
@@ -612,23 +612,23 @@
e.printStackTrace();
errors.incrementAndGet();
}
-
+
System.out.println("done");
}
};
-
+
t.start();
while (msgs.get() == 0)
{
Thread.sleep(100);
}
-
+
while (t.isAlive() && errors.get() == 0 && !prod.getProducerCredits().isBlocked())
{
Thread.sleep(100);
}
-
+
assertEquals(0, errors.get());
ClientSessionFactory newConsumerCF = locator.createSessionFactory();
@@ -636,7 +636,7 @@
newConsumerSession.createTemporaryQueue("TestAD", "Q2");
ClientConsumer newConsumer = newConsumerSession.createConsumer("Q2");
newConsumerSession.start();
-
+
int toReceive = TOTAL_MSG - msgs.get() - 1;
for (ServerSession sessionIterator: server.getSessions())
@@ -648,24 +648,24 @@
impl.getRemotingConnection().fail(new HornetQException(HornetQException.DISCONNECTED, "failure e"));
}
}
-
+
int secondReceive = 0;
-
+
ClientMessage msg = null;
while (secondReceive < toReceive && (msg = newConsumer.receive(5000)) != null)
{
msg.acknowledge();
secondReceive++;
}
-
+
assertNull(newConsumer.receiveImmediate());
-
+
assertEquals(toReceive, secondReceive);
-
+
t.join();
-
-
-
+
+
+
}
// Package protected ---------------------------------------------
@@ -683,41 +683,19 @@
server.start();
locator = createLocator();
- sf = locator.createSessionFactory();
- session = sf.createSession(false, true, true);
+ sf = createSessionFactory(locator);
+ session = addClientSession(sf.createSession(false, true, true));
}
protected ServerLocator createLocator()
{
ServerLocator retlocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
+ addServerLocator(retlocator);
retlocator.setConnectionTTL(TemporaryQueueTest.CONNECTION_TTL);
retlocator.setClientFailureCheckPeriod(TemporaryQueueTest.CONNECTION_TTL / 3);
return retlocator;
}
- @Override
- protected void tearDown() throws Exception
- {
-
- sf.close();
-
- session.close();
-
- locator.close();
-
- locator = null;
-
- server.stop();
-
- session = null;
-
- server = null;
-
- sf = null;
-
- super.tearDown();
- }
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionDurabilityTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionDurabilityTest.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionDurabilityTest.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -16,29 +16,33 @@
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.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A TransactionDurabilityTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
+ *
* Created 16 Jan 2009 11:00:33
*
*
*/
public class TransactionDurabilityTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(TransactionDurabilityTest.class);
/*
* This tests the following situation:
- *
+ *
* (With the old implementation)
* Currently when a new persistent message is routed to persistent queues, the message is first stored, then the message is routed.
* Let's say it has been routed to two different queues A, B.
@@ -46,10 +50,10 @@
* transactionally, but it's not committed yet.
* Ref R2 then gets consumed and acknowledged by non transacted session S2, this causes a delete record to be written to storage.
* R1 then rolls back, and the server is restarted - unfortunatelt since the delete record was written R1 is not ready to be consumed again.
- *
+ *
* It's therefore crucial the messages aren't deleted from storage until AFTER any ack records are committed to storage.
- *
- *
+ *
+ *
*/
public void testRolledBackAcknowledgeWithSameMessageAckedByOtherSession() throws Exception
{
@@ -65,9 +69,11 @@
server.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
+ ServerLocator locator =
+ addServerLocator(HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(
+ ServiceTestBase.INVM_CONNECTOR_FACTORY)));
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session1 = sf.createSession(false, true, true);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionalSendTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionalSendTest.java 2011-12-05 16:07:59 UTC (rev 11837)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/TransactionalSendTest.java 2011-12-05 16:35:33 UTC (rev 11838)
@@ -42,25 +42,14 @@
protected void setUp() throws Exception
{
super.setUp();
-
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
public void testSendWithCommit() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession(false, false, false);
session.createQueue(addressA, queueA, false);
ClientProducer cp = session.createProducer(addressA);
@@ -82,23 +71,13 @@
session.commit();
Assert.assertEquals(q.getMessageCount(), numMessages * 2);
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
public void testSendWithRollback() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession(false, false, false);
session.createQueue(addressA, queueA, false);
ClientProducer cp = session.createProducer(addressA);
@@ -120,14 +99,6 @@
session.commit();
Assert.assertEquals(q.getMessageCount(), numMessages);
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
}
13 years, 1 month
JBoss hornetq SVN: r11837 - in trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration: remoting and 1 other directory.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-05 11:07:59 -0500 (Mon, 05 Dec 2011)
New Revision: 11837
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageDurabilityTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageExpirationTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageRateTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/OrderTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingOrderTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingSyncTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NettyNetworkAddressTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NetworkAddressTestBase.java
Log:
Move closing of resources to super.tearDown()
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -15,8 +15,12 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+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.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -26,8 +30,6 @@
*/
public class MessageCounterTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(MessageCounterTest.class);
-
private HornetQServer server;
private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
@@ -40,31 +42,18 @@
super.setUp();
server = createServer(false);
-
server.start();
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
public void testMessageCounter() throws Exception
{
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, false, false, false, 0);
session.createQueue(QUEUE, QUEUE, null, false);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageDurabilityTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageDurabilityTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageDurabilityTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -17,7 +17,11 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+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.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
@@ -187,28 +191,10 @@
server = createServer(true);
server.start();
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
- session = sf.createSession(false, true, true);
+ sf = createSessionFactory(locator);
+ session = addClientSession(sf.createSession(false, true, true));
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- session.close();
-
- server.stop();
-
- server = null;
-
- session = null;
-
- sf = null;
-
- super.tearDown();
- }
-
// Private -------------------------------------------------------
private void restart() throws Exception
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageExpirationTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageExpirationTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageExpirationTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -17,7 +17,12 @@
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
-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.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressSettings;
@@ -189,30 +194,7 @@
server = createServer(false);
server.start();
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
- session = sf.createSession(false, true, true);
+ sf = createSessionFactory(locator);
+ session = addClientSession(sf.createSession(false, true, true));
}
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- session.close();
-
- server.stop();
-
- session = null;
-
- server = null;
-
- sf = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -21,10 +21,15 @@
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.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.tests.util.ServiceTestBase;
@@ -36,8 +41,6 @@
*/
public class MessageGroupingConnectionFactoryTest extends UnitTestCase
{
- private static final Logger log = Logger.getLogger(MessageGroupingTest.class);
-
private HornetQServer server;
private ClientSession clientSession;
@@ -60,7 +63,7 @@
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
clientSession.start();
-
+
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
@@ -87,7 +90,7 @@
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
clientSession.start();
-
+
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
@@ -157,8 +160,8 @@
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
locator.setGroupID("grp1");
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
- clientSession = sessionFactory.createSession(false, true, true);
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
+ clientSession = addClientSession(sessionFactory.createSession(false, true, true));
clientSession.createQueue(qName, qName, null, false);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -25,9 +25,15 @@
import org.hornetq.api.core.Message;
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.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
@@ -94,7 +100,7 @@
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
clientSession.start();
-
+
SimpleString groupId = new SimpleString("grp1");
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
@@ -122,10 +128,10 @@
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
clientSession.start();
-
+
//need to wait a bit or consumers might be busy
Thread.sleep(200);
-
+
SimpleString groupId = new SimpleString("grp1");
SimpleString groupId2 = new SimpleString("grp2");
int numMessages = 100;
@@ -210,10 +216,10 @@
ClientSession clientSession = sessionFactory.createSession(false, false, false);
ClientProducer clientProducer = this.clientSession.createProducer(qName);
clientSession.start();
-
+
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
-
+
//Wait a bit otherwise consumers might be busy
Thread.sleep(200);
@@ -274,10 +280,10 @@
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
clientSession.start();
-
+
//need to wait a bit or consumers might be busy
Thread.sleep(200);
-
+
SimpleString groupId = new SimpleString("grp1");
SimpleString groupId2 = new SimpleString("grp2");
int numMessages = 100;
@@ -294,7 +300,7 @@
}
clientProducer.send(message);
}
-
+
CountDownLatch latch = new CountDownLatch(numMessages);
DummyMessageHandler dummyMessageHandler = new DummyMessageHandler(latch, true);
consumer.setMessageHandler(dummyMessageHandler);
@@ -349,7 +355,7 @@
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
clientSession.start();
-
+
Xid xid = new XidImpl("bq".getBytes(), 4, "gtid".getBytes());
clientSession.start(xid, XAResource.TMNOFLAGS);
@@ -408,7 +414,7 @@
ClientSession clientSession = sessionFactory.createSession(true, false, false);
ClientProducer clientProducer = this.clientSession.createProducer(qName);
clientSession.start();
-
+
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
Xid xid = new XidImpl("bq".getBytes(), 4, "gtid".getBytes());
@@ -487,7 +493,7 @@
ClientConsumer consumer = clientSession.createConsumer(qName);
ClientConsumer consumer2 = clientSession.createConsumer(qName);
clientSession.start();
-
+
SimpleString groupId = new SimpleString("grp1");
SimpleString groupId2 = new SimpleString("grp2");
int numMessages = 4;
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -18,7 +18,13 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-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.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -36,6 +42,8 @@
private ServerLocator locator;
+ private ClientSessionFactory sf;
+
@Override
protected void setUp() throws Exception
{
@@ -46,24 +54,12 @@
server.start();
locator = createInVMNonHALocator();
- }
+ sf = createSessionFactory(locator);
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
}
public void testSetMessageHandlerWithMessagesPending() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
-
ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
@@ -123,8 +119,6 @@
public void testSetResetMessageHandler() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
-
final ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
@@ -136,7 +130,7 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage message = createTextMessage(session, "m" + i);
-
+
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
@@ -172,19 +166,19 @@
{
failed = true;
}
-
+
messageReceived++;
-
+
log.info("got message " + messageReceived);
-
+
latch.countDown();
if (latch.getCount() == 0)
{
message.acknowledge();
-
+
started = false;
-
+
consumer.setMessageHandler(null);
}
@@ -198,7 +192,7 @@
MyHandler handler = new MyHandler(latch);
consumer.setMessageHandler(handler);
-
+
session.start();
@@ -225,8 +219,6 @@
public void testSetUnsetMessageHandler() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
-
final ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
@@ -313,8 +305,6 @@
public void testSetUnsetResetMessageHandler() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
-
final ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageRateTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageRateTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageRateTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -20,7 +20,13 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-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.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -52,8 +58,6 @@
{
HornetQServer server = createServer(false);
- try
- {
server.start();
locator.setProducerMaxRate(10);
@@ -73,24 +77,13 @@
Assert.assertTrue("TotalTime = " + (end - start), end - start >= 1000);
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
-
}
public void testConsumeRate() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
locator.setConsumerMaxRate(10);
ClientSessionFactory sf = locator.createSessionFactory();
@@ -122,24 +115,13 @@
Assert.assertTrue("TotalTime = " + (end - start), end - start >= 1000);
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
-
}
public void testConsumeRateListener() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
locator.setConsumerMaxRate(10);
ClientSessionFactory sf = locator.createSessionFactory();
@@ -188,30 +170,9 @@
Assert.assertTrue("TotalTime = " + (end - start), end - start >= 1000);
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
@Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
- @Override
protected void setUp() throws Exception
{
super.setUp();
@@ -219,8 +180,4 @@
locator = createInVMNonHALocator();
}
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/OrderTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/OrderTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/OrderTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -21,7 +21,6 @@
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.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.tests.util.ServiceTestBase;
@@ -36,12 +35,6 @@
public class OrderTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(OrderTest.class);
-
- // Attributes ----------------------------------------------------
-
private HornetQServer server;
private ServerLocator locator;
@@ -50,17 +43,9 @@
protected void setUp() throws Exception
{
super.setUp();
-
locator = createNettyNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
- server.stop();
- super.tearDown();
- }
// Static --------------------------------------------------------
@@ -87,12 +72,10 @@
locator.setBlockOnDurableSend(false);
locator.setBlockOnAcknowledge(true);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(true, true, 0);
- try
- {
session.createQueue("queue", "queue", true);
ClientProducer prod = session.createProducer("queue");
@@ -116,7 +99,7 @@
started = true;
server.stop();
server.start();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
}
session = sf.createSession(true, true);
@@ -151,14 +134,6 @@
session.close();
}
-
- }
- finally
- {
- sf.close();
- session.close();
- }
-
}
public void testOrderOverSessionClosePersistent() throws Exception
@@ -181,15 +156,12 @@
locator.setBlockOnDurableSend(false);
locator.setBlockOnAcknowledge(false);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(true, true, 0);
int numberOfMessages = 500;
+ session.createQueue("queue", "queue", true);
- try
- {
- session.createQueue("queue", "queue", true);
-
ClientProducer prod = session.createProducer("queue");
for (int i = 0; i < numberOfMessages; i++)
@@ -232,13 +204,6 @@
session.close();
}
- }
- finally
- {
- sf.close();
- session.close();
- }
-
}
public void testOrderOverSessionClosePersistentWithRedeliveryDelay() throws Exception
@@ -272,9 +237,7 @@
int numberOfMessages = 500;
- try
- {
- session.createQueue("queue", "queue", true);
+ session.createQueue("queue", "queue", true);
ClientProducer prod = session.createProducer("queue");
@@ -288,11 +251,11 @@
session.close();
session = sf.createSession(false, false);;
-
+
session.start();
-
+
ClientConsumer cons = session.createConsumer("queue");
-
+
for (int i = 0 ; i < numberOfMessages; i++)
{
ClientMessage msg = cons.receive(5000);
@@ -301,14 +264,14 @@
}
session.close();
-
+
session = sf.createSession(false, false);;
-
+
session.start();
-
+
cons = session.createConsumer("queue");
-
-
+
+
for (int i = 0 ; i < numberOfMessages; i++)
{
ClientMessage msg = cons.receive(5000);
@@ -316,17 +279,10 @@
msg.acknowledge();
assertEquals(i, msg.getIntProperty("id").intValue());
}
-
+
// receive again
session.commit();
session.close();
- }
- finally
- {
- sf.close();
- session.close();
- }
-
}
// Package protected ---------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingOrderTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingOrderTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingOrderTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -36,17 +36,13 @@
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.api.jms.HornetQJMSClient;
import org.hornetq.api.jms.JMSFactoryType;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.paging.PagingStore;
-import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.Bindings;
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
-import org.hornetq.core.server.ServerSession;
import org.hornetq.core.server.impl.QueueImpl;
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
@@ -57,7 +53,7 @@
/**
* A PagingOrderTest.
- *
+ *
* PagingTest has a lot of tests already. I decided to create a newer one more specialized on Ordering and counters
*
* @author clebertsuconic
@@ -77,8 +73,6 @@
// Public --------------------------------------------------------
- private ServerLocator locator;
-
public PagingOrderTest(final String name)
{
super(name);
@@ -89,11 +83,6 @@
super();
}
- // Constants -----------------------------------------------------
- private static final Logger log = Logger.getLogger(PagingTest.class);
-
- private static final int RECEIVE_TIMEOUT = 30000;
-
private static final int PAGE_MAX = 100 * 1024;
private static final int PAGE_SIZE = 10 * 1024;
@@ -104,25 +93,6 @@
static final SimpleString ADDRESS = new SimpleString("SimpleAddress");
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- locator = createInVMNonHALocator();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
public void testOrder1() throws Throwable
{
boolean persistentMessages = true;
@@ -138,11 +108,8 @@
final int messageSize = 1024;
final int numberOfMessages = 500;
+ ServerLocator locator = createInVMNonHALocator();
- try
- {
- ServerLocator locator = createInVMNonHALocator();
-
locator.setClientFailureCheckPeriod(1000);
locator.setConnectionTTL(2000);
locator.setReconnectAttempts(0);
@@ -152,7 +119,7 @@
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(1024 * 1024);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -210,11 +177,11 @@
}
session.close();
-
+
session = null;
sf.close();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
locator = createInVMNonHALocator();
@@ -231,28 +198,8 @@
assertEquals(i, message.getIntProperty("id").intValue());
message.acknowledge();
}
-
- session.close();
-
- sf.close();
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- throw e;
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
+ session.close();
}
public void testPageCounter() throws Throwable
@@ -284,7 +231,7 @@
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(1024 * 1024);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -307,6 +254,7 @@
Thread t1 = new Thread()
{
+ @Override
public void run()
{
try
@@ -455,7 +403,7 @@
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(1024 * 1024);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -478,6 +426,7 @@
Thread t1 = new Thread()
{
+ @Override
public void run()
{
try
@@ -589,11 +538,11 @@
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(1024 * 1024);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
- QueueImpl queue = (QueueImpl)server.createQueue(ADDRESS, ADDRESS, null, true, false);
+ server.createQueue(ADDRESS, ADDRESS, null, true, false);
ClientProducer producer = session.createProducer(PagingTest.ADDRESS);
@@ -696,8 +645,6 @@
final int numberOfMessages = 200;
- try
- {
ServerLocator locator = createInVMNonHALocator();
locator.setClientFailureCheckPeriod(1000);
@@ -709,7 +656,7 @@
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(0);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -809,7 +756,7 @@
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(0);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, false, 0);
@@ -828,25 +775,6 @@
session.commit();
session.close();
-
- locator.close();
-
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- throw e;
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
}
public void testPagingOverCreatedDestinationTopics() throws Exception
@@ -886,12 +814,12 @@
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic)context.lookup("/topic/TT");
sess.createDurableSubscriber(topic, "t1");
-
+
MessageProducer prod = sess.createProducer(topic);
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
TextMessage txt = sess.createTextMessage("TST");
prod.send(txt);
-
+
PagingStore store = server.getPagingManager().getPageStore(new SimpleString("jms.topic.TT"));
assertEquals(1024 * 1024, store.getMaxSize());
@@ -913,7 +841,7 @@
assertEquals(AddressFullMessagePolicy.PAGE, settings.getAddressFullMessagePolicy());
store = server.getPagingManager().getPageStore(new SimpleString("TT"));
-
+
conn.close();
server.stop();
@@ -956,18 +884,18 @@
conn.setClientID("tst");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
javax.jms.Queue queue = (javax.jms.Queue)context.lookup("/queue/Q1");
-
+
MessageProducer prod = sess.createProducer(queue);
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
BytesMessage bmt = sess.createBytesMessage();
-
+
bmt.writeBytes(new byte[1024]);
-
+
for (int i = 0 ; i < 500; i++)
{
prod.send(bmt);
}
-
+
PagingStore store = server.getPagingManager().getPageStore(new SimpleString("jms.queue.Q1"));
assertEquals(100 * 1024, store.getMaxSize());
@@ -993,18 +921,5 @@
assertEquals(100 * 1024, store.getMaxSize());
assertEquals(10 * 1024, store.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, store.getAddressFullMessagePolicy());
-
-
- server.stop();
-
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingSyncTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingSyncTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingSyncTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -15,49 +15,22 @@
import java.nio.ByteBuffer;
import java.util.HashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
-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.ServerLocator;
-import org.hornetq.api.jms.HornetQJMSClient;
-import org.hornetq.api.jms.JMSFactoryType;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.paging.PagingStore;
-import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
-import org.hornetq.core.postoffice.Binding;
-import org.hornetq.core.postoffice.Bindings;
-import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.Queue;
-import org.hornetq.core.server.ServerSession;
-import org.hornetq.core.server.impl.QueueImpl;
-import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
-import org.hornetq.jms.client.HornetQJMSConnectionFactory;
-import org.hornetq.jms.server.impl.JMSServerManagerImpl;
-import org.hornetq.tests.unit.util.InVMContext;
import org.hornetq.tests.util.ServiceTestBase;
/**
* A PagingOrderTest.
- *
+ *
* PagingTest has a lot of tests already. I decided to create a newer one more specialized on Ordering and counters
*
* @author clebertsuconic
@@ -67,33 +40,6 @@
public class PagingSyncTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- private ServerLocator locator;
-
- public PagingSyncTest(final String name)
- {
- super(name);
- }
-
- public PagingSyncTest()
- {
- super();
- }
-
- // Constants -----------------------------------------------------
- private static final Logger log = Logger.getLogger(PagingTest.class);
-
- private static final int RECEIVE_TIMEOUT = 30000;
-
private static final int PAGE_MAX = 100 * 1024;
private static final int PAGE_SIZE = 10 * 1024;
@@ -104,24 +50,6 @@
static final SimpleString ADDRESS = new SimpleString("SimpleAddress");
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- locator = createInVMNonHALocator();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
public void testOrder1() throws Throwable
{
boolean persistentMessages = true;
@@ -138,8 +66,6 @@
final int numberOfMessages = 500;
- try
- {
ServerLocator locator = createInVMNonHALocator();
locator.setClientFailureCheckPeriod(1000);
@@ -151,11 +77,11 @@
locator.setBlockOnAcknowledge(false);
locator.setConsumerWindowSize(1024 * 1024);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
- Queue queue = server.createQueue(ADDRESS, ADDRESS, null, true, false);
+ server.createQueue(ADDRESS, ADDRESS, null, true, false);
ClientProducer producer = session.createProducer(PagingTest.ADDRESS);
@@ -184,25 +110,8 @@
session.commit();
session.close();
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- throw e;
- }
- finally
- {
- try
- {
- server.stop();
}
- catch (Throwable ignored)
- {
- }
- }
- }
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -156,7 +156,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -208,7 +208,7 @@
server.start();
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
Queue queue = server.locateQueue(ADDRESS);
@@ -268,7 +268,7 @@
queue = server.locateQueue(ADDRESS);
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(true, false, false);
@@ -374,7 +374,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -427,7 +427,7 @@
server.start();
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
Queue queue = server.locateQueue(ADDRESS);
@@ -510,7 +510,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -563,7 +563,7 @@
server.start();
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
Queue queue = server.locateQueue(ADDRESS);
@@ -627,11 +627,11 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
queue = server.locateQueue(ADDRESS);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, false, false);
producer = session.createProducer(PagingTest.ADDRESS);
@@ -665,7 +665,7 @@
server.start();
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
queue = server.locateQueue(ADDRESS);
@@ -731,7 +731,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -850,7 +850,7 @@
server.start();
- ClientSessionFactory csf = locator.createSessionFactory();
+ ClientSessionFactory csf = createSessionFactory(locator);
ClientSession sess = csf.createSession();
@@ -914,7 +914,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -1004,7 +1004,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- ClientSessionFactory csf = locator.createSessionFactory();
+ ClientSessionFactory csf = createSessionFactory(locator);
ClientSession session = csf.createSession();
@@ -1038,10 +1038,6 @@
{
Thread.sleep(100);
}
-
- locator.close();
-
- server.stop();
}
public void testTwoQueuesOneNoRouting() throws Exception
@@ -1066,16 +1062,13 @@
final int numberOfMessages = 1000;
+ ServerLocator locator = createInVMNonHALocator();
- try
- {
- ServerLocator locator = createInVMNonHALocator();
-
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -1144,24 +1137,8 @@
// It's async, so need to wait a bit for it happening
assertFalse(server.getPagingManager().getPageStore(ADDRESS).isPaging());
+ }
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
- }
-
public void testSendReceivePagingPersistent() throws Exception
{
internaltestSendReceivePaging(true);
@@ -1281,7 +1258,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -1355,7 +1332,7 @@
tcount2.start();
ServerLocator locator = createInVMNonHALocator();
- final ClientSessionFactory sf2 = locator.createSessionFactory();
+ final ClientSessionFactory sf2 = createSessionFactory(locator);
final AtomicInteger errors = new AtomicInteger(0);
@@ -1514,16 +1491,14 @@
bb.put(getSamplebyte(j));
}
- try
{
- {
ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -1570,7 +1545,7 @@
server.start();
ServerLocator locator = createInVMNonHALocator();
- final ClientSessionFactory sf2 = locator.createSessionFactory();
+ final ClientSessionFactory sf2 = createSessionFactory(locator);
final AtomicInteger errors = new AtomicInteger(0);
@@ -1651,19 +1626,6 @@
}
assertEquals(0, server.getPostOffice().getPagingManager().getTransactions().size());
-
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
private void internaltestSendReceivePaging(final boolean persistentMessages) throws Exception
@@ -1689,15 +1651,13 @@
final int numberOfMessages = 1000;
- try
- {
- ServerLocator locator = createInVMNonHALocator();
+ ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, true, true, false, 0);
@@ -1746,7 +1706,7 @@
}
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(null, null, false, true, true, false, 0);
@@ -1786,22 +1746,6 @@
consumer.close();
session.close();
-
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
private void assertBodiesEqual(final byte[] body, final HornetQBuffer buffer)
@@ -1835,15 +1779,12 @@
new HashMap<String, AddressSettings>());
server.start();
-
- try
- {
- ServerLocator locator = createInVMNonHALocator();
+ ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, true, true, false, 0);
@@ -1935,22 +1876,6 @@
consumer.close();
session.close();
-
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
/**
@@ -1971,24 +1896,16 @@
Configuration config = createDefaultConfig();
server =
- createServer(true,
- config,
- PagingTest.PAGE_SIZE,
- PagingTest.PAGE_MAX,
- new HashMap<String, AddressSettings>());
+ createServer(true, config, PagingTest.PAGE_SIZE, PagingTest.PAGE_MAX,
+ new HashMap<String, AddressSettings>());
server.start();
-
-
-
- try
- {
- ServerLocator locator = createInVMNonHALocator();
+ ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
byte[] body = new byte[MESSAGE_SIZE];
@@ -2097,22 +2014,6 @@
consumer.close();
session.close();
-
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testDepageDuringTransaction3() throws Exception
@@ -2130,16 +2031,12 @@
server.start();
-
-
- try
- {
- ServerLocator locator = createInVMNonHALocator();
+ ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
byte[] body = new byte[MESSAGE_SIZE];
@@ -2228,22 +2125,6 @@
consumer.close();
sessionNonTX.close();
-
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testDepageDuringTransaction4() throws Exception
@@ -2275,11 +2156,8 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(false);
- try
- {
+ sf = createSessionFactory(locator);
- sf = locator.createSessionFactory();
-
final byte[] body = new byte[MESSAGE_SIZE];
Thread producerThread = new Thread()
@@ -2365,17 +2243,6 @@
sf.close();
assertEquals(0, errors.get());
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
}
public void testOrderingNonTX() throws Exception
@@ -2400,13 +2267,10 @@
final int numberOfMessages = 2000;
-
- try
- {
- locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
final CountDownLatch ready = new CountDownLatch(1);
@@ -2497,18 +2361,6 @@
producerThread.join();
assertEquals(0, errors.get());
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testPageOnSchedulingNoRestart() throws Exception
@@ -2541,15 +2393,11 @@
final int numberOfMessages = 1000;
final int numberOfBytes = 1024;
-
- try
- {
-
- locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, true, true, false, 0);
session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);
@@ -2600,7 +2448,7 @@
new HashMap<String, AddressSettings>());
server.start();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(null, null, false, true, true, false, 0);
}
@@ -2643,18 +2491,6 @@
consumer.close();
session.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testRollbackOnSend() throws Exception
@@ -2676,14 +2512,11 @@
final int numberOfMessages = 10;
- try
- {
-
- locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, false, true, false, 0);
session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);
@@ -2717,20 +2550,8 @@
Assert.assertNull(consumer.receiveImmediate());
session.close();
- }
- finally
- {
- try
- {
- server.stop();
}
- catch (Throwable ignored)
- {
- }
- }
- }
-
public void testCommitOnSend() throws Exception
{
clearData();
@@ -2750,14 +2571,11 @@
final int numberOfMessages = 500;
- try
- {
-
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, false, false, false, 0);
session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);
@@ -2800,7 +2618,7 @@
server.start();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(null, null, false, false, false, false, 0);
@@ -2821,19 +2639,7 @@
session.close();
}
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
- }
-
public void testParialConsume() throws Exception
{
clearData();
@@ -2851,14 +2657,11 @@
final int numberOfMessages = 1000;
- try
- {
-
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, false, false, false, 0);
session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);
@@ -2898,7 +2701,7 @@
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(null, null, false, false, false, false, 0);
@@ -2931,7 +2734,7 @@
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(null, null, false, false, false, false, 0);
@@ -2948,18 +2751,6 @@
}
session.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testPageMultipleDestinations() throws Exception
@@ -2990,15 +2781,11 @@
server.start();
final int numberOfMessages = 1000;
-
- try
- {
-
- locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, true, true, false, 0);
session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);
@@ -3100,17 +2887,6 @@
.getPageStore(PagingTest.ADDRESS)
.getAddressSize());
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
}
@@ -3132,13 +2908,9 @@
server.start();
final int numberOfMessages = 30000;
-
- try
- {
-
locator.setAckBatchSize(0);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession();
session.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true);
@@ -3200,19 +2972,7 @@
session.close();
}
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
- }
-
private void internalTestPageMultipleDestinations(final boolean transacted) throws Exception
{
Configuration config = createDefaultConfig();
@@ -3230,14 +2990,11 @@
server.start();
- try
- {
-
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, !transacted, true, false, 0);
for (int i = 0; i < NUMBER_OF_BINDINGS; i++)
@@ -3275,7 +3032,7 @@
new HashMap<String, AddressSettings>());
server.start();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(null, null, false, true, true, false, 0);
@@ -3310,19 +3067,6 @@
Assert.assertEquals("Queue someQueue" + i + " was supposed to be empty", 0, queue.getMessageCount());
Assert.assertEquals("Queue someQueue" + i + " was supposed to be empty", 0, queue.getDeliveringCount());
}
-
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testSyncPage() throws Exception
@@ -3439,9 +3183,7 @@
server.start();
- try
- {
- server.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true, false);
+ server.createQueue(PagingTest.ADDRESS, PagingTest.ADDRESS, null, true, false);
final CountDownLatch pageUp = new CountDownLatch(0);
final CountDownLatch pageDone = new CountDownLatch(1);
@@ -3509,20 +3251,6 @@
assertTrue(pageDone.await(10, TimeUnit.SECONDS));
- server.stop();
-
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testPagingOneDestinationOnly() throws Exception
@@ -3544,11 +3272,9 @@
server = createServer(true, configuration, -1, -1, addresses);
- try
- {
server.start();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, false);
@@ -3616,14 +3342,6 @@
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testPagingDifferentSizes() throws Exception
@@ -3653,11 +3371,9 @@
server = createServer(true, configuration, -1, -1, addresses);
- try
- {
server.start();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, false);
@@ -3746,15 +3462,6 @@
consumerB.close();
session.close();
-
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testPageAndDepageRapidly() throws Exception
@@ -3776,15 +3483,13 @@
final int numberOfMessages = 200;
- try
- {
ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(true, true);
@@ -3881,22 +3586,6 @@
assertFalse(server.getPagingManager().getPageStore(ADDRESS).isPaging());
assertEquals(1, server.getPagingManager().getPageStore(ADDRESS).getNumberOfPages());
-
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
}
public void testTwoQueuesDifferentFilters() throws Exception
@@ -3922,8 +3611,6 @@
final int numberOfMessages = 200;
- try
- {
ServerLocator locator = createInVMNonHALocator();
locator.setClientFailureCheckPeriod(120000);
@@ -3934,7 +3621,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -4008,21 +3695,6 @@
// It's async, so need to wait a bit for it happening
assertFalse(server.getPagingManager().getPageStore(ADDRESS).isPaging());
-
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
}
public void testTwoQueues() throws Exception
@@ -4048,8 +3720,6 @@
final int numberOfMessages = 1000;
- try
- {
ServerLocator locator = createInVMNonHALocator();
locator.setClientFailureCheckPeriod(120000);
@@ -4060,7 +3730,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -4131,21 +3801,6 @@
// It's async, so need to wait a bit for it happening
assertFalse(server.getPagingManager().getPageStore(ADDRESS).isPaging());
-
- sf.close();
-
- locator.close();
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
}
public void testDLAOnLargeMessageAndPaging() throws Exception
@@ -4180,7 +3835,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, false, false);
@@ -4300,7 +3955,7 @@
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, false);
@@ -4406,14 +4061,11 @@
final int messageSize = 20;
ServerLocator locator = createInVMNonHALocator();
- try
- {
-
- locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false, false);
@@ -4479,7 +4131,7 @@
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, false);
@@ -4526,12 +4178,6 @@
assertFalse(pgStoreAddress.isPaging());
session.close();
- }
- finally
- {
- closeServerLocator(locator);
- stopComponent(server);
- }
}
// Package protected ---------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NettyNetworkAddressTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NettyNetworkAddressTest.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NettyNetworkAddressTest.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -26,20 +26,6 @@
public class NettyNetworkAddressTest extends NetworkAddressTestBase
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
@Override
protected String getAcceptorFactoryClassName()
{
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NetworkAddressTestBase.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NetworkAddressTestBase.java 2011-12-05 15:08:01 UTC (rev 11836)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/NetworkAddressTestBase.java 2011-12-05 16:07:59 UTC (rev 11837)
@@ -21,17 +21,15 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
+import java.util.Set;
import junit.framework.Assert;
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.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -40,7 +38,7 @@
* A NetworkAddressTest
*
* @author jmesnil
- *
+ *
* Created 26 janv. 2009 15:06:58
*
*
@@ -65,7 +63,6 @@
{
s.append(entry.getKey().getDisplayName() + ": " + entry.getValue().getHostAddress() + "\n");
}
- System.out.println(s);
}
catch (Exception e)
{
@@ -201,42 +198,26 @@
params = new HashMap<String, Object>();
params.put(getHostPropertyKey(), connectorHost);
TransportConfiguration connectorConfig = new TransportConfiguration(getConnectorFactoryClassName(), params);
- ServerLocator locator = null;
- try
- {
- locator = HornetQClient.createServerLocatorWithoutHA(connectorConfig);
+ ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(connectorConfig));
-
if (mustConnect)
{
- ClientSessionFactory sf = locator.createSessionFactory();
- sf.close();
+ ClientSessionFactory sf = createSessionFactory(locator);
+ sf.close();
System.out.println("connection OK");
}
else
{
try
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ locator.createSessionFactory();
Assert.fail("session creation must fail because connector must not be able to connect to the server bound to another network interface");
}
catch (Exception e)
{
}
}
- }
- finally
- {
- if(locator != null)
- {
- locator.close();
}
- if (messagingService != null)
- {
- messagingService.stop();
- }
- }
- }
// Package protected ---------------------------------------------
13 years, 1 month
JBoss hornetq SVN: r11836 - in trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration: management and 1 other directory.
by do-not-reply@jboss.org
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();
}
13 years, 1 month
JBoss hornetq SVN: r11835 - in trunk: tests/integration-tests/src/test/java/org/hornetq/tests/integration/client and 1 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-12-05 09:48:36 -0500 (Mon, 05 Dec 2011)
New Revision: 11835
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/AckBatchSizeTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.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/AddressControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java
Log:
test suite refactor
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 14:44:39 UTC (rev 11834)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-05 14:48:36 UTC (rev 11835)
@@ -457,7 +457,16 @@
}
}
+
+
protected HornetQServer createServer(final boolean realFiles,
+ Configuration conf,
+ MBeanServer mbeanServer)
+ {
+ return createServer(realFiles, conf, mbeanServer, new HashMap<String, AddressSettings>());
+ }
+
+ protected HornetQServer createServer(final boolean realFiles,
final Configuration configuration,
final MBeanServer mbeanServer,
final Map<String, AddressSettings> settings)
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AckBatchSizeTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AckBatchSizeTest.java 2011-12-05 14:44:39 UTC (rev 11834)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AckBatchSizeTest.java 2011-12-05 14:48:36 UTC (rev 11835)
@@ -47,7 +47,7 @@
private int getMessageEncodeSize(final SimpleString address) throws Exception
{
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession session = cf.createSession(false, true, true);
ClientMessage message = session.createMessage(false);
// we need to set the destination so we can calculate the encodesize correctly
@@ -66,7 +66,7 @@
int numMessages = 100;
locator.setAckBatchSize(numMessages * getMessageEncodeSize(addressA));
locator.setBlockOnAcknowledge(true);
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
ClientSession session = cf.createSession(false, true, true);
@@ -106,7 +106,7 @@
ServerLocator locator = createInVMNonHALocator();
locator.setAckBatchSize(0);
locator.setBlockOnAcknowledge(true);
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
int numMessages = 100;
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java 2011-12-05 14:44:39 UTC (rev 11834)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java 2011-12-05 14:48:36 UTC (rev 11835)
@@ -53,7 +53,7 @@
ServerLocator locator = createInVMNonHALocator();
locator.setAckBatchSize(0);
locator.setBlockOnAcknowledge(true);
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
ClientSession session = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
@@ -85,7 +85,7 @@
server.start();
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory cf = locator.createSessionFactory();;
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
ClientSession session = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
@@ -125,7 +125,7 @@
ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnAcknowledge(true);
locator.setAckBatchSize(0);
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
final ClientSession session = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
@@ -174,7 +174,7 @@
ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnAcknowledge(true);
locator.setAckBatchSize(0);
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
ClientSession sendSession = cf.createSession(false, true, true);
final ClientSession session = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.java 2011-12-05 14:44:39 UTC (rev 11834)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.java 2011-12-05 14:48:36 UTC (rev 11835)
@@ -60,7 +60,7 @@
ServerLocator locator = createInVMNonHALocator();
locator.setAutoGroup(true);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(groupTestQ, groupTestQ, null, false);
@@ -110,7 +110,7 @@
ServerLocator locator = createInVMNonHALocator();
locator.setAutoGroup(true);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(groupTestQ, groupTestQ, null, false);
@@ -163,7 +163,7 @@
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
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:44:39 UTC (rev 11834)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java 2011-12-05 14:48:36 UTC (rev 11835)
@@ -35,6 +35,8 @@
import org.hornetq.tests.integration.SimpleNotificationService;
import org.hornetq.tests.util.RandomUtil;
+import javax.management.MBeanServer;
+
/**
* A AcceptorControlTest
*
@@ -46,10 +48,6 @@
*/
public class AcceptorControlTest extends ManagementTestBase
{
-
- private HornetQServer service;
- private ServerLocator locator;
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -66,7 +64,7 @@
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
conf.getAcceptorConfigurations().add(acceptorConfig);
- service = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+ HornetQServer service = createServer(false, conf, mbeanServer);
service.start();
AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
@@ -84,17 +82,15 @@
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
conf.getAcceptorConfigurations().add(acceptorConfig);
- service = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+ HornetQServer service = createServer(false, conf, mbeanServer);
service.start();
AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
// started by the server
Assert.assertTrue(acceptorControl.isStarted());
- locator =
- HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(
- InVMConnectorFactory.class.getName()));
- ClientSessionFactory sf = locator.createSessionFactory();
+ ServerLocator locator = createInVMNonHALocator();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
Assert.assertNotNull(session);
session.close();
@@ -116,8 +112,8 @@
Assert.assertTrue(acceptorControl.isStarted());
- locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName()));
- sf = locator.createSessionFactory();
+ locator = createInVMNonHALocator();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true);
Assert.assertNotNull(session);
session.close();
@@ -146,7 +142,7 @@
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
conf.getAcceptorConfigurations().add(acceptorConfig);
- service = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+ HornetQServer service = createServer(false, conf, mbeanServer);
service.start();
AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
@@ -178,14 +174,6 @@
// Protected -----------------------------------------------------
- @Override
- protected void tearDown() throws Exception
- {
- stopComponent(service);
- closeServerLocator(locator);
- super.tearDown();
- }
-
protected AcceptorControl createManagementControl(final String name) throws Exception
{
return ManagementControlHelper.createAcceptorControl(name, mbeanServer);
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:44:39 UTC (rev 11834)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-12-05 14:48:36 UTC (rev 11835)
@@ -318,13 +318,13 @@
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
- server = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+ server = createServer(false, conf, mbeanServer);
server.start();
- locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
+ locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnNonDurableSend(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, false);
session.start();
}
@@ -334,11 +334,6 @@
{
if (session != null)
session.close();
- closeSessionFactory(sf);
- closeServerLocator(locator);
- stopComponent(server);
-
- server = null;
session = null;
super.tearDown();
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java 2011-12-05 14:44:39 UTC (rev 11834)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java 2011-12-05 14:48:36 UTC (rev 11835)
@@ -182,13 +182,13 @@
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
- server = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+ server = createServer(false, conf, mbeanServer);
server.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
+ ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
session = sf.createSession(false, true, false);
session.start();
}
@@ -204,13 +204,7 @@
protected void tearDown() throws Exception
{
session.close();
-
- server.stop();
-
session = null;
-
- server = null;
-
super.tearDown();
}
13 years, 1 month
JBoss hornetq SVN: r11834 - in trunk/tests/integration-tests/src/test/java/org/hornetq/tests: integration/jms/client and 5 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-05 09:44:39 -0500 (Mon, 05 Dec 2011)
New Revision: 11834
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ConnectionTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/CreateQueueTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ExpiryMessageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/PreACKJMSTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReceiveNoWaitTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/TextMessageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/util/JMSTestBase.java
Log:
Move closing of resources to tearDown()
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/JMSMessageCounterTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/JMSMessageCounterTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -30,59 +30,45 @@
public class JMSMessageCounterTest extends JMSTestBase
{
+ @Override
protected boolean usePersistence()
{
return true;
}
-
+
public void testMessageCounter() throws Exception
{
-
- try
- {
Connection conn = cf.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
Queue queue = createQueue(true, "Test");
-
+
MessageProducer producer = sess.createProducer(queue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
+
final int numMessages = 100;
-
+
for (int i = 0; i < numMessages; i++)
{
TextMessage mess = sess.createTextMessage("msg" + i);
producer.send(mess);
}
-
+
conn.close();
-
+
JMSQueueControl control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
assertNotNull(control);
-
+
System.out.println(control.listMessageCounterAsHTML());
-
+
jmsServer.stop();
-
+
restartServer();
-
+
control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
assertNotNull(control);
-
- System.out.println(control.listMessageCounterAsHTML());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw e;
- }
- finally
- {
- jmsServer.stop();
- }
-
+ System.out.println(control.listMessageCounterAsHTML());
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ConnectionTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ConnectionTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ConnectionTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -13,7 +13,6 @@
package org.hornetq.tests.integration.jms.client;
-import javax.jms.Connection;
import javax.jms.Session;
import javax.jms.XAConnection;
import javax.jms.XASession;
@@ -30,47 +29,23 @@
public class ConnectionTest extends JMSTestBase
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
-
public void testGetSetConnectionFactory() throws Exception
{
- Connection conn = cf.createConnection();
-
+ conn = cf.createConnection();
+
conn.getClientID();
-
+
conn.setClientID("somethingElse");
- conn.close();
}
-
+
public void testXAInstanceof() throws Exception
{
- Connection conn = cf.createConnection();
-
+ conn = cf.createConnection();
+
assertFalse(conn instanceof XAConnection);
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
assertFalse(sess instanceof XASession);
-
- conn.close();
}
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/CreateQueueTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/CreateQueueTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/CreateQueueTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -13,7 +13,6 @@
package org.hornetq.tests.integration.jms.client;
-import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
@@ -25,7 +24,7 @@
import org.hornetq.tests.util.JMSTestBase;
/**
- *
+ *
* A CreateQueueTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -48,157 +47,101 @@
public void testCreateQueueTempQueue() throws Exception
{
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
- try
- {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
Queue tempQueue = session.createTemporaryQueue();
-
+
String tempQueueName = tempQueue.getQueueName();
-
+
assertFalse(tempQueueName.startsWith(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX));
-
+
Queue replyQueue = session.createQueue(tempQueueName);
-
+
MessageProducer producer = session.createProducer(replyQueue);
-
+
producer.send(session.createMessage());
-
+
MessageConsumer consumer= session.createConsumer(replyQueue);
-
+
conn.start();
-
+
assertNotNull(consumer.receive(10000));
-
- }
- finally
- {
- try
- {
- conn.close();
- }
- catch (Throwable igonred)
- {
- }
- }
- }
-
+ }
+
public void testCreateQueue() throws Exception
{
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- try
- {
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
Queue queue = createQueue("TestQueue");
-
+
String queueName = queue.getQueueName();
-
+
log.info("queue name is " + queueName);
-
+
assertFalse(queueName.startsWith(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX));
-
+
Queue replyQueue = session.createQueue(queueName);
-
+
MessageProducer producer = session.createProducer(replyQueue);
-
+
producer.send(session.createMessage());
-
+
MessageConsumer consumer= session.createConsumer(replyQueue);
-
+
conn.start();
-
+
assertNotNull(consumer.receive(10000));
-
- }
- finally
- {
- try
- {
- conn.close();
}
- catch (Throwable igonred)
- {
- }
- }
- }
-
+
public void testCreateTopic() throws Exception
{
- Connection conn = cf.createConnection();
-
- try
- {
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+ conn = cf.createConnection();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
Topic topic = createTopic("TestTopic");
-
+
String topicName = topic.getTopicName();
-
+
assertFalse(topicName.startsWith(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX));
-
+
Topic replyTopic = session.createTopic(topicName);
-
+
MessageConsumer consumer= session.createConsumer(replyTopic);
-
+
conn.start();
-
+
MessageProducer producer = session.createProducer(replyTopic);
-
+
producer.send(session.createMessage());
-
- assertNotNull(consumer.receive(10000));
- }
- finally
- {
- try
- {
- conn.close();
+
+ assertNotNull(consumer.receive(10000));
}
- catch (Throwable igonred)
- {
- }
- }
- }
-
+
public void testCreateTopicTempTopic() throws Exception
{
- Connection conn = cf.createConnection();
-
- try
- {
+ conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
Topic tempTopic = session.createTemporaryTopic();
-
+
String tempTopicName = tempTopic.getTopicName();
-
+
assertFalse(tempTopicName.startsWith(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX));
-
+
Topic replyTopic = session.createTopic(tempTopicName);
-
+
MessageConsumer consumer= session.createConsumer(replyTopic);
-
+
conn.start();
-
+
MessageProducer producer = session.createProducer(replyTopic);
-
+
producer.send(session.createMessage());
-
- assertNotNull(consumer.receive(10000));
- }
- finally
- {
- try
- {
- conn.close();
+
+ assertNotNull(consumer.receive(10000));
}
- catch (Throwable igonred)
- {
- }
- }
- }
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ExpiryMessageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ExpiryMessageTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ExpiryMessageTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -25,7 +25,7 @@
import org.hornetq.tests.util.JMSTestBase;
/**
- *
+ *
* A MessageTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -48,60 +48,60 @@
protected Configuration createDefaultConfig(boolean netty)
{
Configuration conf = super.createDefaultConfig(netty);
-
+
conf.setMessageExpiryScanPeriod(1000);
-
+
return conf;
}
-
+
public void testSendTopicNoSubscription() throws Exception
{
-
+
Topic topic = createTopic("test-topic");
TopicControl control = ManagementControlHelper.createTopicControl(topic, mbeanServer);
-
+
System.out.println("size = " + control.getMessageCount());
-
+
Connection conn2 = cf.createConnection();
-
+
conn2.setClientID("client1");
-
+
Session sess2 = conn2.createSession(true, Session.SESSION_TRANSACTED);
-
+
sess2.createDurableSubscriber(topic, "client-sub1");
sess2.createDurableSubscriber(topic, "client-sub2");
-
+
conn2.close();
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer prod = sess.createProducer(topic);
prod.setTimeToLive(1000);
-
+
for (int i = 0 ; i < 100; i++)
{
TextMessage txt = sess.createTextMessage("txt");
prod.send(txt);
}
-
+
sess.commit();
-
+
conn.close();
// minimal time needed
Thread.sleep(2000);
-
+
long timeout = System.currentTimeMillis() + 10000;
-
+
// We will wait some time, but we will wait as minimal as possible
while (control.getMessageCount() != 0 && System.currentTimeMillis() > timeout)
{
Thread.sleep(100);
}
-
+
assertEquals(0, control.getMessageCount());
-
-
+
+
}
// Package protected ---------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -28,7 +28,7 @@
import org.hornetq.tests.util.JMSTestBase;
/**
- *
+ *
* A MessageTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -64,8 +64,6 @@
Queue queue = createQueue("testQueue");
- try
- {
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(queue);
@@ -75,7 +73,7 @@
conn.start();
StreamMessage msg = sess.createStreamMessage();
-
+
msg.writeInt(1);
msg.writeInt(2);
msg.writeInt(3);
@@ -88,137 +86,124 @@
assertEquals(1, received.readObject());
assertEquals(2, received.readObject());
assertEquals(3, received.readObject());
-
+
try
{
received.readObject();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readBoolean();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readByte();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readChar();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readDouble();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readFloat();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readInt();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readLong();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readShort();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
}
-
+
try
{
received.readString();
-
+
fail("Should throw exception");
}
catch (MessageEOFException e)
{
//Ok
- }
- }
- finally
- {
- try
- {
- conn.close();
}
- catch (Throwable igonred)
- {
- }
- }
}
-
+
public void testNullProperties() throws Exception
{
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Queue queue = createQueue("testQueue");
- try
- {
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(queue);
@@ -228,21 +213,21 @@
conn.start();
Message msg = sess.createMessage();
-
+
msg.setStringProperty("Test", "SomeValue");
-
+
assertEquals("SomeValue", msg.getStringProperty("Test"));
-
+
msg.setStringProperty("Test", null);
-
+
assertEquals(null, msg.getStringProperty("Test"));
msg.setObjectProperty(MessageTest.propName1, null);
-
+
msg.setStringProperty(MessageTest.propName2, null);
-
+
msg.getStringProperty(MessageTest.propName1);
-
+
msg.setStringProperty("Test", null);
Message received = sendAndConsumeMessage(msg, prod, cons);
@@ -250,18 +235,7 @@
Assert.assertNotNull(received);
checkProperties(received);
- }
- finally
- {
- try
- {
- conn.close();
}
- catch (Throwable igonred)
- {
- }
- }
- }
// Package protected ---------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/PreACKJMSTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/PreACKJMSTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/PreACKJMSTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -15,9 +15,7 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Random;
-import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
@@ -26,13 +24,10 @@
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.JMSFactoryType;
-import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.JMSTestBase;
-import org.hornetq.tests.util.RandomUtil;
/**
* A PreACKJMSTest
@@ -73,9 +68,7 @@
public void internalTestPreACK(final int sessionType) throws Exception
{
- Connection conn = cf.createConnection();
- try
- {
+ conn = cf.createConnection();
Session sess = conn.createSession(false, sessionType);
MessageProducer prod = sess.createProducer(queue);
@@ -107,25 +100,11 @@
msg2 = (TextMessage)cons.receiveNoWait();
Assert.assertNull("ConnectionFactory is on PreACK mode, the message shouldn't be received", msg2);
- }
- finally
- {
- try
- {
- conn.close();
- }
- catch (Throwable igonred)
- {
- }
- }
-
}
public void disabled_testPreACKTransactional() throws Exception
{
- Connection conn = cf.createConnection();
- try
- {
+ conn = cf.createConnection();
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer prod = sess.createProducer(queue);
@@ -161,18 +140,6 @@
msg2 = (TextMessage)cons.receive(10);
Assert.assertNotNull("ConnectionFactory is on PreACK mode but it is transacted", msg2);
- }
- finally
- {
- try
- {
- conn.close();
- }
- catch (Throwable igonred)
- {
- }
- }
-
}
// Package protected ---------------------------------------------
@@ -201,7 +168,7 @@
double retryIntervalMultiplier = 1.0;
int reconnectAttempts = -1;
int callTimeout = 30000;
-
+
ArrayList<String> connectors = registerConnectors(server, connectorConfigs);
jmsServer.createConnectionFactory("ManualReconnectionToSingleServerTest",
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReceiveNoWaitTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReceiveNoWaitTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/ReceiveNoWaitTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -21,7 +21,6 @@
import javax.jms.Session;
import javax.jms.TextMessage;
-import org.hornetq.core.logging.Logger;
import org.hornetq.tests.util.JMSTestBase;
/**
@@ -34,10 +33,9 @@
*/
public class ReceiveNoWaitTest extends JMSTestBase
{
- private static final Logger log = Logger.getLogger(ReceiveNoWaitTest.class);
-
private Queue queue;
+ @Override
protected void setUp() throws Exception
{
super.setUp();
@@ -45,6 +43,7 @@
queue = createQueue("TestQueue");
}
+ @Override
protected void tearDown() throws Exception
{
jmsServer.destroyQueue("TestQueue");
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/TextMessageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/TextMessageTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/TextMessageTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -15,7 +15,6 @@
import java.util.List;
-import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
@@ -31,7 +30,7 @@
import org.hornetq.tests.util.RandomUtil;
/**
- *
+ *
* A TextMessageTest
*
* @author Tim Fox
@@ -55,10 +54,8 @@
public void testSendReceiveNullBody() throws Exception
{
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
- try
- {
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(queue);
@@ -85,18 +82,6 @@
TextMessage received3 = (TextMessage)cons.receive(1000);
Assert.assertNotNull(received3);
Assert.assertNull(received3.getText());
- }
- finally
- {
- try
- {
- conn.close();
- }
- catch (Throwable igonred)
- {
- }
- }
-
}
public void testSendReceiveWithBody0() throws Exception
@@ -141,10 +126,7 @@
private void testSendReceiveWithBody(final int bodyLength) throws Exception
{
- Connection conn = cf.createConnection();
-
- try
- {
+ conn = cf.createConnection();
char[] chrs = new char[bodyLength];
for (int i = 0; i < bodyLength; i++)
@@ -173,7 +155,7 @@
TextMessage received2 = (TextMessage)cons.receive(1000);
Assert.assertNotNull(received2);
Assert.assertEquals(str, received2.getText());
-
+
assertEquals(str, msg2.getText());
// Now resend it
@@ -190,19 +172,6 @@
TextMessage received4 = (TextMessage)cons.receive(1000);
Assert.assertNotNull(received4);
assertEquals(str, received4.getText());
-
- }
- finally
- {
- try
- {
- conn.close();
- }
- catch (Throwable igonred)
- {
- }
- }
-
}
// Package protected ---------------------------------------------
@@ -267,9 +236,4 @@
null,
jndiBindings);
}
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -12,28 +12,19 @@
*/
package org.hornetq.tests.integration.jms.connection;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.StringReader;
import java.util.concurrent.atomic.AtomicInteger;
import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.jms.HornetQJMSClient;
import org.hornetq.api.jms.JMSFactoryType;
import org.hornetq.core.client.impl.ServerLocatorImpl;
-import org.hornetq.core.logging.Logger;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.tests.util.JMSTestBase;
/**
- *
+ *
* A CloseConnectionOnGCTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -42,20 +33,7 @@
*/
public class CloseConnectionFactoryOnGCest extends JMSTestBase
{
- private static final Logger log = Logger.getLogger(CloseConnectionFactoryOnGCest.class);
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
public void testCloseCFOnGC() throws Exception
{
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -23,17 +23,16 @@
import junit.framework.Assert;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.api.jms.HornetQJMSClient;
import org.hornetq.api.jms.JMSFactoryType;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.CloseListener;
+import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.tests.util.JMSTestBase;
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* A CloseConnectionOnGCTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -42,8 +41,6 @@
*/
public class CloseConnectionOnGCTest extends JMSTestBase
{
- private static final Logger log = Logger.getLogger(CloseConnectionOnGCTest.class);
-
private HornetQConnectionFactory cf;
@Override
@@ -51,15 +48,17 @@
{
super.setUp();
- cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
+ cf = HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
cf.setBlockOnDurableSend(true);
cf.setPreAcknowledge(true);
+
}
@Override
protected void tearDown() throws Exception
{
- cf = null;
+ if (cf != null)
+ cf.close();
super.tearDown();
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -12,7 +12,6 @@
*/
package org.hornetq.tests.integration.jms.consumer;
-import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -65,7 +64,7 @@
public void testPreCommitAcks() throws Exception
{
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Session session = conn.createSession(false, HornetQJMSConstants.PRE_ACKNOWLEDGE);
jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageProducer producer = session.createProducer(jBossQueue);
@@ -86,13 +85,12 @@
SimpleString queueName = new SimpleString(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + ConsumerTest.Q_NAME);
Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getDeliveringCount());
Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getMessageCount());
- conn.close();
}
public void testPreCommitAcksSetOnConnectionFactory() throws Exception
{
((HornetQConnectionFactory)cf).setPreAcknowledge(true);
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
@@ -115,14 +113,13 @@
SimpleString queueName = new SimpleString(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + ConsumerTest.Q_NAME);
Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getDeliveringCount());
Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getMessageCount());
- conn.close();
}
public void testPreCommitAcksWithMessageExpiry() throws Exception
{
ConsumerTest.log.info("starting test");
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Session session = conn.createSession(false, HornetQJMSConstants.PRE_ACKNOWLEDGE);
jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageProducer producer = session.createProducer(jBossQueue);
@@ -146,13 +143,12 @@
// point
// which can cause delivering count to flip to 1
- conn.close();
}
public void testPreCommitAcksWithMessageExpirySetOnConnectionFactory() throws Exception
{
((HornetQConnectionFactory)cf).setPreAcknowledge(true);
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageProducer producer = session.createProducer(jBossQueue);
@@ -174,13 +170,11 @@
// Asserting delivering count is zero is bogus since messages might still be being delivered and expired at this
// point
// which can cause delivering count to flip to 1
-
- conn.close();
}
public void testClearExceptionListener() throws Exception
{
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageConsumer consumer = session.createConsumer(jBossQueue);
@@ -193,13 +187,11 @@
consumer.setMessageListener(null);
consumer.receiveNoWait();
-
- conn.close();
}
public void testCantReceiveWhenListenerIsSet() throws Exception
{
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageConsumer consumer = session.createConsumer(jBossQueue);
@@ -219,7 +211,5 @@
{
// Ok
}
-
- conn.close();
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -16,7 +16,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
@@ -25,7 +24,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.JMSFactoryType;
@@ -35,7 +33,7 @@
/**
* A DivertAndACKClientTest
- *
+ *
* https://jira.jboss.org/jira/browse/HORNETQ-165
*
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
@@ -60,22 +58,20 @@
Queue queueSource = createQueue("Source");
Queue queueTarget = createQueue("Dest");
- Connection connection = cf.createConnection();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn = cf.createConnection();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
final MessageProducer producer = session.createProducer(queueSource);
final TextMessage message = session.createTextMessage("message text");
producer.send(message);
- connection.start();
+ conn.start();
final MessageConsumer consumer = session.createConsumer(queueTarget);
TextMessage receivedMessage = (TextMessage)consumer.receive(1000);
Assert.assertNotNull(receivedMessage);
-
- connection.close();
}
public void testClientACK() throws Exception
@@ -83,22 +79,20 @@
Queue queueSource = createQueue("Source");
Queue queueTarget = createQueue("Dest");
- Connection connection = cf.createConnection();
- Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ conn = cf.createConnection();
+ Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
final MessageProducer producer = session.createProducer(queueSource);
final TextMessage message = session.createTextMessage("message text");
producer.send(message);
- connection.start();
+ conn.start();
final MessageConsumer consumer = session.createConsumer(queueTarget);
TextMessage receivedMessage = (TextMessage)consumer.receive(1000);
Assert.assertNotNull(receivedMessage);
receivedMessage.acknowledge();
-
- connection.close();
}
// Package protected ---------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -20,7 +20,6 @@
import java.util.concurrent.atomic.AtomicLong;
import javax.jms.BytesMessage;
-import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageNotWriteableException;
@@ -33,7 +32,6 @@
import org.hornetq.tests.util.JMSTestBase;
import org.hornetq.tests.util.UnitTestCase;
-import org.hornetq.utils.UUID;
import org.hornetq.utils.UUIDGenerator;
/**
@@ -79,10 +77,7 @@
public void testSimpleLargeMessage() throws Exception
{
- Connection conn = null;
- try
- {
conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -122,24 +117,10 @@
}
Assert.assertNotNull(rm);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
}
public void testSimpleLargeMessage2() throws Exception
{
- Connection conn = null;
-
- try
- {
conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -176,26 +157,12 @@
}
Assert.assertNotNull(rm);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
}
public void testExceptionsOnSettingNonStreaming() throws Exception
{
- Connection conn = null;
+ conn = cf.createConnection();
- try
- {
- conn = cf.createConnection();
-
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage();
@@ -249,26 +216,13 @@
Assert.assertNotNull(rm);
}
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
public void testWaitOnOutputStream() throws Exception
{
int msgSize = 1024 * 1024;
- Connection conn = null;
+ conn = cf.createConnection();
- try
- {
- conn = cf.createConnection();
-
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session.createProducer(queue1);
@@ -330,49 +284,36 @@
Assert.assertEquals(0, numberOfErrors.get());
}
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
public void testHugeString() throws Exception
{
int msgSize = 1024 * 1024;
- Connection conn = null;
+ conn = cf.createConnection();
- try
- {
- conn = cf.createConnection();
-
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session.createProducer(queue1);
TextMessage m = session.createTextMessage();
-
+
StringBuffer buffer = new StringBuffer();
while(buffer.length() < msgSize)
{
buffer.append(UUIDGenerator.getInstance().generateStringUUID());
}
-
+
final String originalString = buffer.toString();
-
+
m.setText(originalString);
-
+
buffer = null;
prod.send(m);
conn.close();
-
+
validateNoFilesOnLargeDir(1);
conn = cf.createConnection();
@@ -388,16 +329,7 @@
String str = rm.getText();
assertEquals(originalString, str);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
+ conn.close();
validateNoFilesOnLargeDir(0);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/util/JMSTestBase.java 2011-12-05 14:25:39 UTC (rev 11833)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/util/JMSTestBase.java 2011-12-05 14:44:39 UTC (rev 11834)
@@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;
+import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.jms.Topic;
@@ -49,6 +50,7 @@
protected MBeanServer mbeanServer;
protected ConnectionFactory cf;
+ protected Connection conn;
protected InVMContext context;
@@ -127,7 +129,7 @@
conf.getConnectorConfigurations().put("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
server = HornetQServers.newHornetQServer(conf, mbeanServer, usePersistence());
-
+ addServer(server);
jmsServer = new JMSServerManagerImpl(server);
context = new InVMContext();
jmsServer.setContext(context);
@@ -164,13 +166,17 @@
@Override
protected void tearDown() throws Exception
{
-
+ try
+ {
+ if (conn != null)
+ conn.close();
+ }
+ catch (Exception e)
+ {
+ // no-op
+ }
+ context.close();
jmsServer.stop();
-
- server.stop();
-
- context.close();
-
server = null;
jmsServer = null;
13 years, 1 month
JBoss hornetq SVN: r11833 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11.
by do-not-reply@jboss.org
Author: gaohoward
Date: 2011-12-05 09:25:39 -0500 (Mon, 05 Dec 2011)
New Revision: 11833
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java
Log:
more tests
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java 2011-12-05 14:19:44 UTC (rev 11832)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java 2011-12-05 14:25:39 UTC (rev 11833)
@@ -293,4 +293,128 @@
}
}
+ public void testNoGarbageAfterPersistentMessageV11() throws Exception
+ {
+ StompClientConnection connV11 = StompClientConnectionFactory
+ .createClientConnection("1.1", hostname, port);
+ try
+ {
+ connV11.connect(defUser, defPass);
+
+ ClientStompFrame subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "auto");
+
+ connV11.sendFrame(subFrame);
+
+ ClientStompFrame frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ frame = connV11.receiveFrame(10000);
+
+ System.out.println("received: " + frame);
+
+ assertEquals("Hello World", frame.getBody());
+
+ //if hornetq sends trailing garbage bytes, the second message
+ //will not be normal
+ frame = connV11.receiveFrame(10000);
+
+ System.out.println("received: " + frame);
+
+ assertEquals("Hello World", frame.getBody());
+
+ //unsub
+ ClientStompFrame unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+ }
+ finally
+ {
+ connV11.disconnect();
+ }
+ }
+
+ public void testNoGarbageOnPersistentRedeliveryV11() throws Exception
+ {
+ StompClientConnection connV11 = StompClientConnectionFactory
+ .createClientConnection("1.1", hostname, port);
+ try
+ {
+ connV11.connect(defUser, defPass);
+
+ ClientStompFrame frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ ClientStompFrame subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "client");
+
+ connV11.sendFrame(subFrame);
+
+ // receive but don't ack
+ frame = connV11.receiveFrame(10000);
+ frame = connV11.receiveFrame(10000);
+
+ System.out.println("received: " + frame);
+
+ //unsub
+ ClientStompFrame unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+
+ subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "auto");
+
+ connV11.sendFrame(subFrame);
+
+ frame = connV11.receiveFrame(10000);
+ frame = connV11.receiveFrame(10000);
+
+ //second receive will get problem if trailing bytes
+ assertEquals("Hello World", frame.getBody());
+
+ System.out.println("received again: " + frame);
+
+ //unsub
+ unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+ }
+ finally
+ {
+ connV11.disconnect();
+ }
+ }
+
}
13 years, 1 month
JBoss hornetq SVN: r11832 - in trunk: tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11 and 1 other directory.
by do-not-reply@jboss.org
Author: gaohoward
Date: 2011-12-05 09:19:44 -0500 (Mon, 05 Dec 2011)
New Revision: 11832
Added:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/VersionedStompFrameHandler.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestBase2.java
Log:
HORNETQ-726, HORNETQ-742
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/VersionedStompFrameHandler.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/VersionedStompFrameHandler.java 2011-12-05 14:19:17 UTC (rev 11831)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/VersionedStompFrameHandler.java 2011-12-05 14:19:44 UTC (rev 11832)
@@ -316,9 +316,12 @@
int bodyPos = serverMessage.getEndOfBodyPosition() == -1 ? buffer
.writerIndex() : serverMessage.getEndOfBodyPosition();
+
+ buffer.readerIndex(MessageImpl.BUFFER_HEADER_SPACE
+ + DataConstants.SIZE_INT);
+
int size = bodyPos - buffer.readerIndex();
- buffer.readerIndex(MessageImpl.BUFFER_HEADER_SPACE
- + DataConstants.SIZE_INT);
+
byte[] data = new byte[size];
if (serverMessage.containsProperty(Stomp.Headers.CONTENT_LENGTH)
@@ -341,7 +344,10 @@
}
frame.setByteBody(data);
- serverMessage.getBodyBuffer().resetReaderIndex();
+ // Reset indexes so they are in order when
+ // StompSession.sendMessage is called again with the same
+ // ServerMessage instance
+ buffer.setIndex(MessageImpl.BUFFER_HEADER_SPACE + DataConstants.SIZE_INT, bodyPos);
StompUtils.copyStandardHeadersFromMessageToFrame(serverMessage, frame,
deliveryCount);
Added: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java (rev 0)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/ExtraStompTest.java 2011-12-05 14:19:44 UTC (rev 11832)
@@ -0,0 +1,296 @@
+package org.hornetq.tests.integration.stomp.v11;
+
+import org.hornetq.tests.integration.stomp.util.ClientStompFrame;
+import org.hornetq.tests.integration.stomp.util.StompClientConnection;
+import org.hornetq.tests.integration.stomp.util.StompClientConnectionFactory;
+
+/*
+ * Some Stomp tests against server with persistence enabled are put here.
+ */
+public class ExtraStompTest extends StompTestBase2
+{
+
+ protected void setUp() throws Exception
+ {
+ persistenceEnabled = true;
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testSendAndReceive10() throws Exception
+ {
+ StompClientConnection connV11 = StompClientConnectionFactory.createClientConnection("1.0", hostname, port);
+
+ try
+ {
+ String msg1 = "Hello World 1!";
+ String msg2 = "Hello World 2!";
+
+ connV11.connect(defUser, defPass);
+
+ ClientStompFrame frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", String.valueOf(msg1.getBytes("UTF-8").length));
+ frame.addHeader("persistent", "true");
+ frame.setBody(msg1);
+
+ connV11.sendFrame(frame);
+
+ ClientStompFrame frame2 = connV11.createFrame("SEND");
+ frame2.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame2.addHeader("content-length", String.valueOf(msg2.getBytes("UTF-8").length));
+ frame2.addHeader("persistent", "true");
+ frame2.setBody(msg2);
+
+ connV11.sendFrame(frame2);
+
+ ClientStompFrame subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "auto");
+
+ connV11.sendFrame(subFrame);
+
+ frame = connV11.receiveFrame();
+
+ System.out.println("received " + frame);
+
+ assertEquals("MESSAGE", frame.getCommand());
+
+ assertEquals("a-sub", frame.getHeader("subscription"));
+
+ assertNotNull(frame.getHeader("message-id"));
+
+ assertEquals(getQueuePrefix() + getQueueName(), frame.getHeader("destination"));
+
+ assertEquals(msg1, frame.getBody());
+
+ frame = connV11.receiveFrame();
+
+ System.out.println("received " + frame);
+
+ assertEquals("MESSAGE", frame.getCommand());
+
+ assertEquals("a-sub", frame.getHeader("subscription"));
+
+ assertNotNull(frame.getHeader("message-id"));
+
+ assertEquals(getQueuePrefix() + getQueueName(), frame.getHeader("destination"));
+
+ assertEquals(msg2, frame.getBody());
+
+ //unsub
+ ClientStompFrame unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+
+ }
+ finally
+ {
+ connV11.disconnect();
+ }
+ }
+
+ public void testSendAndReceive11() throws Exception
+ {
+ StompClientConnection connV11 = StompClientConnectionFactory.createClientConnection("1.1", hostname, port);
+
+ try
+ {
+ String msg1 = "Hello World 1!";
+ String msg2 = "Hello World 2!";
+
+ connV11.connect(defUser, defPass);
+
+ ClientStompFrame frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", String.valueOf(msg1.getBytes("UTF-8").length));
+ frame.addHeader("persistent", "true");
+ frame.setBody(msg1);
+
+ connV11.sendFrame(frame);
+
+ ClientStompFrame frame2 = connV11.createFrame("SEND");
+ frame2.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame2.addHeader("content-length", String.valueOf(msg2.getBytes("UTF-8").length));
+ frame2.addHeader("persistent", "true");
+ frame2.setBody(msg2);
+
+ connV11.sendFrame(frame2);
+
+ ClientStompFrame subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "auto");
+
+ connV11.sendFrame(subFrame);
+
+ frame = connV11.receiveFrame();
+
+ System.out.println("received " + frame);
+
+ assertEquals("MESSAGE", frame.getCommand());
+
+ assertEquals("a-sub", frame.getHeader("subscription"));
+
+ assertNotNull(frame.getHeader("message-id"));
+
+ assertEquals(getQueuePrefix() + getQueueName(), frame.getHeader("destination"));
+
+ assertEquals(msg1, frame.getBody());
+
+ frame = connV11.receiveFrame();
+
+ System.out.println("received " + frame);
+
+ assertEquals("MESSAGE", frame.getCommand());
+
+ assertEquals("a-sub", frame.getHeader("subscription"));
+
+ assertNotNull(frame.getHeader("message-id"));
+
+ assertEquals(getQueuePrefix() + getQueueName(), frame.getHeader("destination"));
+
+ assertEquals(msg2, frame.getBody());
+
+ //unsub
+ ClientStompFrame unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+
+ }
+ finally
+ {
+ connV11.disconnect();
+ }
+ }
+
+ public void testNoGarbageAfterPersistentMessageV10() throws Exception
+ {
+ StompClientConnection connV11 = StompClientConnectionFactory
+ .createClientConnection("1.0", hostname, port);
+ try
+ {
+ connV11.connect(defUser, defPass);
+
+ ClientStompFrame subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "auto");
+
+ connV11.sendFrame(subFrame);
+
+ ClientStompFrame frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ frame = connV11.receiveFrame(10000);
+
+ System.out.println("received: " + frame);
+
+ assertEquals("Hello World", frame.getBody());
+
+ //if hornetq sends trailing garbage bytes, the second message
+ //will not be normal
+ frame = connV11.receiveFrame(10000);
+
+ System.out.println("received: " + frame);
+
+ assertEquals("Hello World", frame.getBody());
+
+ //unsub
+ ClientStompFrame unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+ }
+ finally
+ {
+ connV11.disconnect();
+ }
+ }
+
+ public void testNoGarbageOnPersistentRedeliveryV10() throws Exception
+ {
+ StompClientConnection connV11 = StompClientConnectionFactory
+ .createClientConnection("1.0", hostname, port);
+ try
+ {
+ connV11.connect(defUser, defPass);
+
+ ClientStompFrame frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ frame = connV11.createFrame("SEND");
+ frame.addHeader("destination", getQueuePrefix() + getQueueName());
+ frame.addHeader("content-length", "11");
+ frame.addHeader("persistent", "true");
+ frame.setBody("Hello World");
+
+ connV11.sendFrame(frame);
+
+ ClientStompFrame subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "client");
+
+ connV11.sendFrame(subFrame);
+
+ // receive but don't ack
+ frame = connV11.receiveFrame(10000);
+ frame = connV11.receiveFrame(10000);
+
+ System.out.println("received: " + frame);
+
+ //unsub
+ ClientStompFrame unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+
+ subFrame = connV11.createFrame("SUBSCRIBE");
+ subFrame.addHeader("id", "a-sub");
+ subFrame.addHeader("destination", getQueuePrefix() + getQueueName());
+ subFrame.addHeader("ack", "auto");
+
+ connV11.sendFrame(subFrame);
+
+ frame = connV11.receiveFrame(10000);
+ frame = connV11.receiveFrame(10000);
+
+ //second receive will get problem if trailing bytes
+ assertEquals("Hello World", frame.getBody());
+
+ System.out.println("received again: " + frame);
+
+ //unsub
+ unsubFrame = connV11.createFrame("UNSUBSCRIBE");
+ unsubFrame.addHeader("id", "a-sub");
+ connV11.sendFrame(unsubFrame);
+ }
+ finally
+ {
+ connV11.disconnect();
+ }
+ }
+
+}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestBase2.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestBase2.java 2011-12-05 14:19:17 UTC (rev 11831)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestBase2.java 2011-12-05 14:19:44 UTC (rev 11832)
@@ -74,7 +74,7 @@
protected String defPass = "wombats";
-
+ protected boolean persistenceEnabled = false;
// Implementation methods
// -------------------------------------------------------------------------
@@ -101,7 +101,9 @@
{
Configuration config = createBasicConfig();
config.setSecurityEnabled(false);
- config.setPersistenceEnabled(false);
+ config.setPersistenceEnabled(persistenceEnabled);
+
+ System.out.println("-----------------server persist: " + persistenceEnabled);
Map<String, Object> params = new HashMap<String, Object>();
params.put(TransportConstants.PROTOCOL_PROP_NAME, ProtocolType.STOMP.toString());
@@ -113,7 +115,7 @@
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
jmsConfig.getQueueConfigurations()
- .add(new JMSQueueConfigurationImpl(getQueueName(), null, false, getQueueName()));
+ .add(new JMSQueueConfigurationImpl(getQueueName(), null, true, getQueueName()));
jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl(getTopicName(), getTopicName()));
server = new JMSServerManagerImpl(hornetQServer, jmsConfig);
server.setContext(new InVMContext());
13 years, 1 month