Author: borges
Date: 2011-12-05 09:19:17 -0500 (Mon, 05 Dec 2011)
New Revision: 11831
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/CommitRollbackTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientExitTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQRATestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/OutgoingConnectionTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/DirectDeliverTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java
Log:
Move closing of resources to super.tearDown()
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/CommitRollbackTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/CommitRollbackTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/CommitRollbackTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -19,7 +19,13 @@
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.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.core.server.Queue;
import org.hornetq.tests.util.ServiceTestBase;
@@ -42,12 +48,10 @@
public void testReceiveWithCommit() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ 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, false, false);
sendSession.createQueue(addressA, queueA, false);
@@ -71,24 +75,15 @@
Assert.assertEquals(0, q.getDeliveringCount());
session.close();
sendSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
public void testReceiveWithRollback() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
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, false, false);
sendSession.createQueue(addressA, queueA, false);
@@ -118,25 +113,15 @@
Assert.assertEquals(numMessages, q.getDeliveringCount());
session.close();
sendSession.close();
- cf.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testReceiveWithRollbackMultipleConsumersDifferentQueues() throws
Exception
{
HornetQServer server = createServer(false);
- try
- {
+
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, false, false);
sendSession.createQueue(addressA, queueA, false);
@@ -173,26 +158,16 @@
Assert.assertEquals(numMessages, q.getMessageCount());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testAsyncConsumerCommit() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
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, false);
sendSession.createQueue(addressA, queueA, false);
@@ -236,27 +211,17 @@
Assert.assertEquals(0, q.getMessageCount());
sendSession.close();
session.close();
- cf.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
public void testAsyncConsumerRollback() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
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, false);
sendSession.createQueue(addressA, queueA, false);
@@ -285,14 +250,7 @@
sendSession.close();
session.close();
cf.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
private static class ackHandler implements MessageHandler
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -18,9 +18,14 @@
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.ServerLocator;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.jms.client.HornetQTextMessage;
import org.hornetq.tests.util.SpawnedVMSupport;
@@ -113,18 +118,18 @@
// FIXME
https://jira.jboss.org/jira/browse/JBMESSAGING-1421
assertActiveSession(0);
}
-
+
public void testCrashClient2() throws Exception
- {
+ {
assertActiveConnections(1);
ClientSession session = sf.createSession(false, true, true);
-
+
session.createQueue(ClientCrashTest.QUEUE, ClientCrashTest.QUEUE, null, false);
-
+
// spawn a JVM that creates a Core client, which sends a message
Process p = SpawnedVMSupport.spawnVM(CrashClient2.class.getName());
-
+
ClientCrashTest.log.debug("waiting for the client VM to crash ...");
p.waitFor();
@@ -133,9 +138,9 @@
System.out.println("VM Exited");
Thread.sleep(3 * ClientCrashTest.CONNECTION_TTL);
-
+
ClientConsumer consumer = session.createConsumer(ClientCrashTest.QUEUE);
-
+
session.start();
// receive a message from the queue
@@ -144,7 +149,7 @@
Assert.assertEquals(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT,
messageFromClient.getBodyBuffer().readString());
assertEquals(2, messageFromClient.getDeliveryCount());
-
+
session.close();
}
@@ -157,26 +162,9 @@
super.setUp();
locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
-
+ addServerLocator(locator);
locator.setClientFailureCheckPeriod(ClientCrashTest.PING_PERIOD);
locator.setConnectionTTL(ClientCrashTest.CONNECTION_TTL);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
}
-
- @Override
- protected void tearDown() throws Exception
- {
- // sf.close();
-
- sf = null;
- locator.close();
- super.tearDown();
- }
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientExitTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientExitTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientExitTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -18,7 +18,11 @@
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.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.logging.Logger;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.tests.util.RandomUtil;
@@ -81,7 +85,7 @@
// FIXME
https://jira.jboss.org/jira/browse/JBMESSAGING-1421
// Thread.sleep(1000);
- //
+ //
// // the local session
// assertActiveConnections(1);
// // assertActiveSession(1);
@@ -102,17 +106,11 @@
super.setUp();
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
- ClientSessionFactory sf = locator.createSessionFactory();
+ addServerLocator(locator);
+ ClientSessionFactory sf = createSessionFactory(locator);
session = sf.createSession(false, true, true);
session.createQueue(ClientExitTest.QUEUE, ClientExitTest.QUEUE, null, false);
consumer = session.createConsumer(ClientExitTest.QUEUE);
session.start();
}
-
- // Protected
------------------------------------------------------------------------------------
-
- // Private
--------------------------------------------------------------------------------------
-
- // Inner classes
--------------------------------------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientTestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientTestBase.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/clientcrash/ClientTestBase.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -29,22 +29,8 @@
public abstract class ClientTestBase extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
private HornetQServer server;
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
@Override
protected void setUp() throws Exception
{
@@ -56,16 +42,6 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
protected void assertActiveConnections(final int expectedActiveConnections) throws
Exception
{
Assert.assertEquals(expectedActiveConnections,
server.getHornetQServerControl().getConnectionCount());
@@ -76,8 +52,4 @@
Assert.assertEquals(expectedActiveSession, server.getSessions().size());
}
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -12,23 +12,16 @@
*/
package org.hornetq.tests.integration.ra;
-import org.hornetq.api.core.HornetQException;
-import org.hornetq.api.core.client.ClientMessage;
-import org.hornetq.api.core.client.ClientProducer;
-import org.hornetq.api.core.client.ClientSession;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.security.Role;
-import org.hornetq.core.server.impl.QueueImpl;
import org.hornetq.ra.HornetQResourceAdapter;
import org.hornetq.ra.inflow.HornetQActivationSpec;
-import javax.resource.ResourceException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
* Created Jul 6, 2010
@@ -70,9 +63,9 @@
server.getSecurityManager().addUser("testuser",
"testpassword");
server.getSecurityManager().addRole("testuser", "arole");
Role role = new Role("arole", false, true, false, false, false, false,
false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -12,26 +12,26 @@
*/
package org.hornetq.tests.integration.ra;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Message;
+
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.ServerLocator;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.ra.HornetQResourceAdapter;
import org.hornetq.ra.inflow.HornetQActivationSpec;
-import javax.jms.Message;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
* Created May 20, 2010
*/
public class HornetQMessageHandlerTest extends HornetQRATestBase
{
-
+
@Override
public boolean isSecure()
{
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -12,6 +12,15 @@
*/
package org.hornetq.tests.integration.ra;
+import java.lang.reflect.Method;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.resource.ResourceException;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ClientProducer;
import org.hornetq.api.core.client.ClientSession;
@@ -20,14 +29,6 @@
import org.hornetq.ra.inflow.HornetQActivationSpec;
import org.hornetq.utils.UUIDGenerator;
-import javax.resource.ResourceException;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import java.lang.reflect.Method;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
* Created Jul 6, 2010
@@ -55,7 +56,7 @@
XADummyEndpoint endpoint = new XADummyEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new
DummyMessageEndpointFactory(endpoint, true);
qResourceAdapter.endpointActivation(endpointFactory, spec);
- ClientSession session = locator.createSessionFactory().createSession();
+ ClientSession session = createSessionFactory(locator).createSession();
ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("teststring");
@@ -87,7 +88,7 @@
XADummyEndpoint endpoint = new XADummyEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new
DummyMessageEndpointFactory(endpoint, true);
qResourceAdapter.endpointActivation(endpointFactory, spec);
- ClientSession session = locator.createSessionFactory().createSession();
+ ClientSession session = createSessionFactory(locator).createSession();
ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("teststring");
@@ -110,7 +111,7 @@
class XADummyEndpoint extends DummyMessageEndpoint
{
- private Xid xid;
+ private final Xid xid;
public XADummyEndpoint(CountDownLatch latch)
{
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQRATestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQRATestBase.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/HornetQRATestBase.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -12,12 +12,9 @@
*/
package org.hornetq.tests.integration.ra;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.ServerLocator;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.server.HornetQServer;
-import org.hornetq.jms.client.HornetQMessage;
-import org.hornetq.tests.util.ServiceTestBase;
+import java.lang.reflect.Method;
+import java.util.Timer;
+import java.util.concurrent.CountDownLatch;
import javax.jms.Message;
import javax.jms.MessageListener;
@@ -27,12 +24,20 @@
import javax.resource.spi.XATerminator;
import javax.resource.spi.endpoint.MessageEndpoint;
import javax.resource.spi.endpoint.MessageEndpointFactory;
-import javax.resource.spi.work.*;
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.XAResource;
-import java.lang.reflect.Method;
-import java.util.Timer;
-import java.util.concurrent.CountDownLatch;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.jms.client.HornetQMessage;
+import org.hornetq.tests.util.ServiceTestBase;
+
/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
* Created Jul 6, 2010
@@ -62,31 +67,11 @@
server.createQueue(MDBQUEUEPREFIXEDSIMPLE, MDBQUEUEPREFIXEDSIMPLE, null, true,
false);
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- locator = null;
- if (server != null)
- {
- try
- {
- server.stop();
- server = null;
- }
- catch (Exception e)
- {
- // ignore
- }
- }
- super.tearDown();
- }
public abstract boolean isSecure();
class DummyMessageEndpointFactory implements MessageEndpointFactory
{
- private DummyMessageEndpoint endpoint;
+ private final DummyMessageEndpoint endpoint;
private final boolean isDeliveryTransacted;
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/OutgoingConnectionTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/OutgoingConnectionTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ra/OutgoingConnectionTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -50,7 +50,7 @@
public class OutgoingConnectionTest extends HornetQRATestBase
{
private HornetQResourceAdapter resourceAdapter;
-
+
@Override
public boolean isSecure()
{
@@ -71,7 +71,7 @@
roles.add(role);
server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
}
-
+
@Override
protected void tearDown() throws Exception
{
@@ -103,7 +103,7 @@
TextMessage textMessage = (TextMessage) consumer.receive(1000);
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
-
+
ManagedConnection mc = ((HornetQRASession)s).getManagedConnection();
s.close();
mc.destroy();
@@ -175,7 +175,7 @@
assertNotNull(textMessage);
assertEquals(textMessage.getText(), "test");
s.commit();
-
+
ManagedConnection mc = ((HornetQRASession)s).getManagedConnection();
s.close();
mc.destroy();
@@ -195,14 +195,14 @@
Session s = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
try
{
- Session s2 = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
fail("should throw javax,jms.IllegalStateException: Only allowed one
session per connection. See the J2EE spec, e.g. J2EE1.4 Section 6.6");
}
catch (JMSException e)
{
assertTrue(e.getLinkedException() instanceof IllegalStateException);
}
-
+
ManagedConnection mc = ((HornetQRASession)s).getManagedConnection();
s.close();
mc.destroy();
@@ -227,7 +227,7 @@
queueConnection = qraConnectionFactory.createQueueConnection("testuser",
"testpassword");
session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
mc = ((HornetQRASession)session).getManagedConnection();
queueConnection.close();
mc.destroy();
@@ -246,7 +246,7 @@
HornetQRAConnectionFactory qraConnectionFactory = new
HornetQRAConnectionFactoryImpl(mcf, qraConnectionManager);
QueueConnection queueConnection = qraConnectionFactory.createQueueConnection();
QueueSession session = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
-
+
ManagedConnection mc = ((HornetQRASession)session).getManagedConnection();
queueConnection.close();
mc.destroy();
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/DirectDeliverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/DirectDeliverTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/DirectDeliverTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -26,8 +26,6 @@
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
@@ -38,7 +36,7 @@
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A DirectDeliverTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -48,26 +46,10 @@
public class DirectDeliverTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(DirectDeliverTest.class);
-
- // Attributes ----------------------------------------------------
-
private HornetQServer server;
-
+
private ServerLocator locator;
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
@Override
protected void setUp() throws Exception
{
@@ -84,43 +66,27 @@
config.setSecurityEnabled(false);
server = createServer(false, config);
server.start();
-
+
locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ addServerLocator(locator);
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
- protected ClientSessionFactory createSessionFactory() throws Exception
- {
- return locator.createSessionFactory();
- }
-
public void testDirectDeliver() throws Exception
{
final String foo = "foo";
-
- ClientSessionFactory sf = createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
+
ClientSession session = sf.createSession();
session.createQueue(foo, foo);
Binding binding = server.getPostOffice().getBinding(new SimpleString(foo));
-
+
Queue queue = (Queue)binding.getBindable();
-
+
assertTrue(queue.isDirectDeliver());
-
+
ClientProducer prod = session.createProducer(foo);
ClientConsumer cons = session.createConsumer(foo);
@@ -133,12 +99,12 @@
prod.send(msg);
}
-
+
queue.flushExecutor();
-
+
//Consumer is not started so should go queued
assertFalse(queue.isDirectDeliver());
-
+
session.start();
for (int i = 0; i < numMessages; i++)
@@ -149,18 +115,18 @@
msg.acknowledge();
}
-
+
Thread.sleep((long)(QueueImpl.CHECK_QUEUE_SIZE_PERIOD * 1.5));
-
+
//Add another message, should go direct
ClientMessage msg = session.createMessage(true);
prod.send(msg);
-
+
queue.flushExecutor();
-
+
assertTrue(queue.isDirectDeliver());
-
+
//Send some more
for (int i = 0; i < numMessages; i++)
{
@@ -168,7 +134,7 @@
prod.send(msg);
}
-
+
for (int i = 0; i < numMessages + 1; i++)
{
msg = cons.receive(10000);
@@ -177,26 +143,19 @@
msg.acknowledge();
}
-
+
assertTrue(queue.isDirectDeliver());
-
+
session.stop();
-
+
for (int i = 0; i < numMessages; i++)
{
msg = session.createMessage(true);
prod.send(msg);
}
-
- assertFalse(queue.isDirectDeliver());
-
- sf.close();
+ assertFalse(queue.isDirectDeliver());
}
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java
===================================================================
---
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java 2011-12-05
14:18:54 UTC (rev 11830)
+++
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java 2011-12-05
14:19:17 UTC (rev 11831)
@@ -20,7 +20,12 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Message;
-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.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.impl.ConfigurationImpl;
@@ -135,7 +140,7 @@
session.close();
server.stop();
-
+
setupServer(journalType);
server.start();
@@ -183,8 +188,6 @@
{
ClientProducer producer = session.createProducer(CompactingStressTest.AD3);
- byte[] buffer = new byte[10 * 1024];
-
ClientMessage msg = session.createMessage(true);
for (int i = 0; i < CompactingStressTest.TOT_AD3; i++)