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 ---------------------------------------------