Author: borges
Date: 2011-12-06 06:42:23 -0500 (Tue, 06 Dec 2011)
New Revision: 11854
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java
trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java
Log:
Another massive deletion of unnecessary tearDown code.
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-06
11:41:24 UTC (rev 11853)
+++
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -516,6 +516,12 @@
return createServer(realFiles, configuration, -1, -1, new HashMap<String,
AddressSettings>());
}
+ protected HornetQServer createServer(final Configuration configuration)
+ {
+ return createServer(configuration.isPersistenceEnabled(), configuration, -1, -1,
+ new HashMap<String, AddressSettings>());
+ }
+
protected HornetQServer createInVMFailoverServer(final boolean realFiles,
final Configuration configuration,
final NodeManager nodeManager,
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -23,11 +23,16 @@
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.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.transaction.impl.XidImpl;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.UUIDGenerator;
@@ -36,7 +41,7 @@
* A DuplicateDetectionTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
+ *
* Created 9 Dec 2008 12:31:48
*
*
@@ -528,7 +533,7 @@
session.start();
final SimpleString queueName = new
SimpleString("DuplicateDetectionTestQueue");
-
+
final SimpleString queue2 = new SimpleString("queue2");
session.createQueue(queueName, queueName, null, false);
@@ -541,7 +546,7 @@
SimpleString dupID = new SimpleString("abcdefg");
message.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, dupID.getData());
producer.send(message);
-
+
ClientMessage message2 = createMessage(session,0);
ClientProducer producer2 = session.createProducer(queue2);
producer2.send(message2);
@@ -553,7 +558,7 @@
session = sf.createSession(false, false, false);
session.start();
-
+
ClientConsumer consumer2 = session.createConsumer(queue2);
producer = session.createProducer(queueName);
@@ -570,12 +575,12 @@
message = createMessage(session, 4);
producer.send(message);
-
+
message = consumer2.receive(5000);
assertNotNull(message);
message.acknowledge();
-
+
try
{
session.commit();
@@ -593,13 +598,13 @@
message = consumer.receiveImmediate();
Assert.assertNull(message);
-
-
+
+
message = consumer2.receive(5000);
assertNotNull(message);
-
+
message.acknowledge();
-
+
session.commit();
session.close();
@@ -903,7 +908,7 @@
session.close();
session = sf.createSession(false, false, false);
-
+
session.start();
ClientConsumer consumer = session.createConsumer(queueName);
@@ -1113,7 +1118,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1153,7 +1158,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1200,7 +1205,7 @@
conf.setIDCacheSize(theCacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1236,7 +1241,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1282,7 +1287,7 @@
conf.setIDCacheSize(initialCacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1320,7 +1325,7 @@
conf.setIDCacheSize(subsequentCacheSize);
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1375,7 +1380,7 @@
conf.setIDCacheSize(initialCacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1413,7 +1418,7 @@
conf.setIDCacheSize(subsequentCacheSize);
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1423,7 +1428,7 @@
conf.setIDCacheSize(initialCacheSize);
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1477,7 +1482,7 @@
conf.setPersistIDCache(false);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1517,7 +1522,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1564,7 +1569,7 @@
conf.setPersistIDCache(false);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1606,7 +1611,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1653,7 +1658,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1699,7 +1704,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1735,7 +1740,7 @@
message = createMessage(session, 2);
message.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, dupID2.getData());
producer.send(message);
-
+
try
{
session.commit();
@@ -1768,7 +1773,7 @@
conf.setPersistIDCache(false);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1812,7 +1817,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1871,7 +1876,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1913,7 +1918,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1972,7 +1977,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -2016,7 +2021,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -2053,7 +2058,7 @@
catch (XAException expected)
{
}
-
+
session.rollback(xid2);
@@ -2087,21 +2092,8 @@
conf.setIDCacheSize(cacheSize);
- messagingService = HornetQServers.newHornetQServer(conf, true);
+ messagingService = createServer(true, conf);
messagingService.start();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- if (messagingService.isStarted())
- {
- messagingService.stop();
- }
-
- messagingService = null;
-
- super.tearDown();
- }
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -18,8 +18,12 @@
import org.hornetq.api.core.Interceptor;
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.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.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.PacketImpl;
import org.hornetq.core.protocol.core.impl.wireformat.SessionReceiveMessage;
@@ -30,7 +34,7 @@
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A InterceptorTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a> fox
@@ -39,8 +43,6 @@
*/
public class InterceptorTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(InterceptorTest.class);
-
private HornetQServer server;
private final SimpleString QUEUE = new
SimpleString("InterceptorTestQueue");
@@ -59,18 +61,6 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
private static final String key = "fruit";
private class MyInterceptor1 implements Interceptor
@@ -249,7 +239,7 @@
server.getRemotingService().addInterceptor(interceptor);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -309,7 +299,7 @@
locator.setBlockOnNonDurableSend(false);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -339,7 +329,7 @@
public void testClientInterceptorChangeProperty() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
MyInterceptor3 interceptor = new MyInterceptor3();
@@ -396,7 +386,7 @@
public void testClientInterceptorRejectPacket() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
MyInterceptor4 interceptor = new MyInterceptor4();
@@ -440,7 +430,7 @@
server.getRemotingService().addInterceptor(interceptor3);
server.getRemotingService().addInterceptor(interceptor4);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -524,7 +514,7 @@
MyInterceptor6 interceptor3 = new MyInterceptor6("c", 3);
MyInterceptor6 interceptor4 = new MyInterceptor6("d", 4);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
sf.getServerLocator().addInterceptor(interceptor1);
sf.getServerLocator().addInterceptor(interceptor2);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -16,8 +16,12 @@
import junit.framework.Assert;
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.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
@@ -66,8 +70,6 @@
consumer.close();
session.deleteQueue(queue);
-
- session.close();
}
public void testConsumeFromDurableQueueAfterServerRestart() throws Exception
@@ -96,8 +98,6 @@
consumer.close();
session.deleteQueue(queue);
-
- session.close();
}
public void testProduceAndConsumeFromDurableQueueAfterServerRestart() throws
Exception
@@ -127,8 +127,6 @@
consumer.close();
session.deleteQueue(queue);
-
- session.close();
}
// Package protected ---------------------------------------------
@@ -146,33 +144,8 @@
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
- session = sf.createSession(false, true, true);
+ session = addClientSession(sf.createSession(false, true, true));
}
-
- @Override
- protected void tearDown() throws Exception
- {
- session.close();
-
- locator.close();
-
- server.stop();
-
- sf.close();
-
- session = null;
-
- server = null;
-
- sf = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -14,16 +14,19 @@
import junit.framework.Assert;
-import org.hornetq.api.core.HornetQException;
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.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.core.settings.impl.AddressSettings;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
@@ -310,49 +313,16 @@
configuration.setSecurityEnabled(false);
TransportConfiguration transportConfig = new
TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY);
configuration.getAcceptorConfigurations().add(transportConfig);
- server = HornetQServers.newHornetQServer(configuration, false);
+ server = createServer(false, configuration);
// start the server
server.start();
// then we create a client as normal
- locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
-
- locator.setBlockOnAcknowledge(true);
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
-// There are assertions over sizes that needs to be done after the ACK
+ locator = createInVMNonHALocator();
+ locator.setBlockOnAcknowledge(true);
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
+ // There are assertions over sizes that needs to be done after the ACK
// was received on server
- clientSession = sessionFactory.createSession(null, null, false, true, true, false,
0);
+ clientSession = addClientSession(sessionFactory.createSession(null, null, false,
true, true, false, 0));
}
- @Override
- protected void tearDown() throws Exception
- {
- if (clientSession != null)
- {
- try
- {
- clientSession.close();
- }
- catch (HornetQException e1)
- {
- //
- }
- }
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e1)
- {
- //
- }
- }
- locator.close();
- server = null;
- clientSession = null;
-
- super.tearDown();
- }
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -23,20 +23,18 @@
import org.hornetq.api.jms.JMSFactoryType;
import org.hornetq.core.client.impl.ClientSessionInternal;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQSession;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.tests.integration.jms.server.management.NullInitialContext;
import org.hornetq.tests.util.ServiceTestBase;
-import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* A FailureDeadlockTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -62,9 +60,8 @@
Configuration conf = createDefaultConfig();
conf.setSecurityEnabled(false);
- conf.getAcceptorConfigurations()
- .add(new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
- server = HornetQServers.newHornetQServer(conf, false);
+ conf.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName()));
+ server = createServer(false, conf);
jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(new NullInitialContext());
jmsServer.start();
@@ -77,36 +74,16 @@
@Override
protected void tearDown() throws Exception
{
- if (jmsServer != null && jmsServer.isStarted())
- {
- jmsServer.stop();
- }
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
cf1.close();
cf2.close();
-
- server = null;
- jmsServer = null;
+ if (jmsServer != null && jmsServer.isStarted())
+ {
+ jmsServer.stop();
+ }
- cf1 = null;
-
- cf2 = null;
-
super.tearDown();
}
@@ -196,7 +173,7 @@
try
{
- Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
fail("should throw exception");
}
catch (JMSException e)
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -23,10 +23,14 @@
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.ServerLocator;
import org.hornetq.api.core.management.HornetQServerControl;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressSettings;
@@ -36,17 +40,11 @@
/**
* A HeuristicXATest
- *
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
- *
- *
*/
public class HeuristicXATest extends ServiceTestBase
{
// Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(HeuristicXATest.class);
-
final SimpleString ADDRESS = new SimpleString("ADDRESS");
final String body = "this is the body";
@@ -69,23 +67,11 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(false, configuration, mbeanServer, new
HashMap<String, AddressSettings>());
+ server.start();
- try
- {
- server.start();
+ HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
- HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
-
-
Assert.assertFalse(jmxServer.commitPreparedTransaction("Nananananana"));
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
-
+ Assert.assertFalse(jmxServer.commitPreparedTransaction("Nananananana"));
}
public void testHeuristicCommit() throws Exception
@@ -104,93 +90,81 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(false, configuration, mbeanServer, new
HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeString(body);
+ msg.getBodyBuffer().writeString(body);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- session.close();
+ session.close();
- HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
+ Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ System.out.println(preparedTransactions[0]);
- Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
- Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
- if (isCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (isCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- Assert.assertEquals(0, jmxServer.listPreparedTransactions().length);
- if (isCommit)
- {
- Assert.assertEquals(1,
jmxServer.listHeuristicCommittedTransactions().length);
- Assert.assertEquals(0,
jmxServer.listHeuristicRolledBackTransactions().length);
- }
- else
- {
- Assert.assertEquals(0,
jmxServer.listHeuristicCommittedTransactions().length);
- Assert.assertEquals(1,
jmxServer.listHeuristicRolledBackTransactions().length);
- }
+ Assert.assertEquals(0, jmxServer.listPreparedTransactions().length);
+ if (isCommit)
+ {
+ Assert.assertEquals(1, jmxServer.listHeuristicCommittedTransactions().length);
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
+ }
+ else
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
+ Assert.assertEquals(1, jmxServer.listHeuristicRolledBackTransactions().length);
+ }
- if (isCommit)
- {
- Assert.assertEquals(1,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ if (isCommit)
+ {
+ Assert.assertEquals(1,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- session = sf.createSession(false, false, false);
+ session = sf.createSession(false, false, false);
- session.start();
- ClientConsumer consumer = session.createConsumer(ADDRESS);
- msg = consumer.receive(1000);
- Assert.assertNotNull(msg);
- msg.acknowledge();
- Assert.assertEquals(body, msg.getBodyBuffer().readString());
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ msg = consumer.receive(1000);
+ Assert.assertNotNull(msg);
+ msg.acknowledge();
+ Assert.assertEquals(body, msg.getBodyBuffer().readString());
- session.commit();
- session.close();
- }
-
- Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
-
+ session.commit();
+ session.close();
}
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
}
public void testHeuristicCommitWithRestart() throws Exception
@@ -209,95 +183,85 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(true, configuration, mbeanServer, new
HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeString(body);
+ msg.getBodyBuffer().writeString(body);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- session.close();
+ session.close();
- HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ Assert.assertEquals(1, preparedTransactions.length);
+ System.out.println(preparedTransactions[0]);
- if (isCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (isCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- preparedTransactions = jmxServer.listPreparedTransactions();
- Assert.assertEquals(0, preparedTransactions.length);
+ preparedTransactions = jmxServer.listPreparedTransactions();
+ Assert.assertEquals(0, preparedTransactions.length);
- if (isCommit)
- {
- Assert.assertEquals(1,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ if (isCommit)
+ {
+ Assert.assertEquals(1,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- session = sf.createSession(false, false, false);
+ session = sf.createSession(false, false, false);
- session.start();
- ClientConsumer consumer = session.createConsumer(ADDRESS);
- msg = consumer.receive(1000);
- Assert.assertNotNull(msg);
- msg.acknowledge();
- Assert.assertEquals(body, msg.getBodyBuffer().readString());
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ msg = consumer.receive(1000);
+ Assert.assertNotNull(msg);
+ msg.acknowledge();
+ Assert.assertEquals(body, msg.getBodyBuffer().readString());
- session.commit();
- session.close();
- }
+ session.commit();
+ session.close();
+ }
- Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- server.stop();
+ server.stop();
- server.start();
+ server.start();
- jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- if (isCommit)
- {
- String[] listHeuristicCommittedTransactions =
jmxServer.listHeuristicCommittedTransactions();
- Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
- System.out.println(listHeuristicCommittedTransactions[0]);
- }
- else
- {
- String[] listHeuristicRolledBackTransactions =
jmxServer.listHeuristicRolledBackTransactions();
- Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
- System.out.println(listHeuristicRolledBackTransactions[0]);
- }
+ jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ if (isCommit)
+ {
+ String[] listHeuristicCommittedTransactions =
jmxServer.listHeuristicCommittedTransactions();
+ Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
+ System.out.println(listHeuristicCommittedTransactions[0]);
}
- finally
+ else
{
- if (server.isStarted())
- {
- server.stop();
- }
+ String[] listHeuristicRolledBackTransactions =
jmxServer.listHeuristicRolledBackTransactions();
+ Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
+ System.out.println(listHeuristicRolledBackTransactions[0]);
}
}
@@ -317,105 +281,95 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(true, configuration, mbeanServer, new
HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeString(body);
+ msg.getBodyBuffer().writeString(body);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- session.close();
+ session.close();
- HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ Assert.assertEquals(1, preparedTransactions.length);
+ System.out.println(preparedTransactions[0]);
- if (heuristicCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (heuristicCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- preparedTransactions = jmxServer.listPreparedTransactions();
- Assert.assertEquals(0, preparedTransactions.length);
+ preparedTransactions = jmxServer.listPreparedTransactions();
+ Assert.assertEquals(0, preparedTransactions.length);
- if (heuristicCommit)
- {
- Assert.assertEquals(1,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ if (heuristicCommit)
+ {
+ Assert.assertEquals(1,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- session = sf.createSession(false, false, false);
+ session = sf.createSession(false, false, false);
- session.start();
- ClientConsumer consumer = session.createConsumer(ADDRESS);
- msg = consumer.receive(1000);
- Assert.assertNotNull(msg);
- msg.acknowledge();
- Assert.assertEquals(body, msg.getBodyBuffer().readString());
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ msg = consumer.receive(1000);
+ Assert.assertNotNull(msg);
+ msg.acknowledge();
+ Assert.assertEquals(body, msg.getBodyBuffer().readString());
- session.commit();
- session.close();
- }
+ session.commit();
+ session.close();
+ }
- Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- server.stop();
+ server.stop();
- server.start();
- //we need to recreate the locator and session factory
- sf = locator.createSessionFactory();
- jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- if (heuristicCommit)
- {
- String[] listHeuristicCommittedTransactions =
jmxServer.listHeuristicCommittedTransactions();
- Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
- System.out.println(listHeuristicCommittedTransactions[0]);
- }
- else
- {
- String[] listHeuristicRolledBackTransactions =
jmxServer.listHeuristicRolledBackTransactions();
- Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
- System.out.println(listHeuristicRolledBackTransactions[0]);
- }
-
- session = sf.createSession(true, false, false);
- Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
- Assert.assertEquals(1, recoveredXids.length);
- Assert.assertEquals(xid, recoveredXids[0]);
- Assert.assertEquals(0, session.recover(XAResource.TMENDRSCAN).length);
-
- session.close();
+ server.start();
+ // we need to recreate the locator and session factory
+ sf = createSessionFactory(locator);
+ jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ if (heuristicCommit)
+ {
+ String[] listHeuristicCommittedTransactions =
jmxServer.listHeuristicCommittedTransactions();
+ Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
+ System.out.println(listHeuristicCommittedTransactions[0]);
}
- finally
+ else
{
- if (server.isStarted())
- {
- server.stop();
- }
+ String[] listHeuristicRolledBackTransactions =
jmxServer.listHeuristicRolledBackTransactions();
+ Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
+ System.out.println(listHeuristicRolledBackTransactions[0]);
}
+
+ session = sf.createSession(true, false, false);
+ Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
+ Assert.assertEquals(1, recoveredXids.length);
+ Assert.assertEquals(xid, recoveredXids[0]);
+ Assert.assertEquals(0, session.recover(XAResource.TMENDRSCAN).length);
+
+ session.close();
}
public void testForgetHeuristicCommitAndRestart() throws Exception
@@ -434,90 +388,80 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(true, configuration, mbeanServer, new
HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeBytes(new byte[123]);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer =
ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ Assert.assertEquals(1, preparedTransactions.length);
+ System.out.println(preparedTransactions[0]);
- if (heuristicCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (heuristicCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- preparedTransactions = jmxServer.listPreparedTransactions();
- Assert.assertEquals(0, preparedTransactions.length);
+ preparedTransactions = jmxServer.listPreparedTransactions();
+ Assert.assertEquals(0, preparedTransactions.length);
- session.forget(xid);
+ session.forget(xid);
- session.close();
+ session.close();
- if (heuristicCommit)
- {
- Assert.assertEquals(0,
jmxServer.listHeuristicCommittedTransactions().length);
- }
- else
- {
- Assert.assertEquals(0,
jmxServer.listHeuristicRolledBackTransactions().length);
- }
+ if (heuristicCommit)
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
+ }
+ else
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
+ }
- server.stop();
+ server.stop();
- server.start();
- //we need to recreate the sf
- sf = locator.createSessionFactory();
- session = sf.createSession(true, false, false);
- Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
- Assert.assertEquals(0, recoveredXids.length);
- jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- if (heuristicCommit)
- {
- Assert.assertEquals(0,
jmxServer.listHeuristicCommittedTransactions().length);
- }
- else
- {
- Assert.assertEquals(0,
jmxServer.listHeuristicRolledBackTransactions().length);
- }
-
- session.close();
+ server.start();
+ // we need to recreate the sf
+ sf = createSessionFactory(locator);
+ session = sf.createSession(true, false, false);
+ Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
+ Assert.assertEquals(0, recoveredXids.length);
+ jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ if (heuristicCommit)
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
}
- finally
+ else
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
}
+
+ session.close();
}
// Package protected ---------------------------------------------
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -14,8 +14,12 @@
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.protocol.core.impl.PacketImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
@@ -24,8 +28,6 @@
public class InVMNonPersistentMessageBufferTest extends ServiceTestBase
{
- private static final Logger log =
Logger.getLogger(InVMNonPersistentMessageBufferTest.class);
-
public static final String address = "testaddress";
public static final String queueName = "testqueue";
@@ -232,7 +234,7 @@
ServerLocator locator = createFactory();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
session = cf.createSession();
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -14,14 +14,10 @@
package org.hornetq.tests.integration.client;
import static org.hornetq.tests.util.RandomUtil.randomString;
-import org.hornetq.tests.util.SpawnedVMSupport;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.TransportConfiguration;
@@ -37,12 +33,12 @@
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.wireformat.CreateSessionMessage;
import org.hornetq.core.protocol.core.impl.wireformat.CreateSessionResponseMessage;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.server.impl.RemotingServiceImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.version.impl.VersionImpl;
import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.tests.util.SpawnedVMSupport;
import org.hornetq.utils.VersionLoader;
/**
@@ -77,8 +73,8 @@
server.getConfiguration().setConnectionTTLOverride(500);
server.start();
- locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory csf = locator.createSessionFactory();
+ locator = createInVMNonHALocator();
+ ClientSessionFactory csf = createSessionFactory(locator);
connection = csf.getConnection();
}
@@ -87,10 +83,7 @@
protected void tearDown() throws Exception
{
connection.destroy();
-
- locator.close();
-
- server.stop();
+ super.tearDown();
}
public void testCompatibleClientVersion() throws Exception
@@ -116,7 +109,7 @@
assertFalse(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10",4));
assertFalse(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10",100));
}
-
+
private void doTestClientVersionCompatibility(boolean compatible) throws Exception
{
Channel channel1 = connection.getChannel(1, -1);
@@ -175,14 +168,14 @@
{
String propFileName = "compatibility-test-hornetq-version.properties";
String serverStartedString =
"IncompatibleVersionTest---server---started";
-
+
Properties prop = new Properties();
InputStream in =
VersionImpl.class.getClassLoader().getResourceAsStream("hornetq-version.properties");
prop.load(in);
prop.setProperty("hornetq.version.compatibleVersionList", verList);
prop.setProperty("hornetq.version.incrementingVersion",
Integer.toString(ver));
prop.store(new FileOutputStream("target/test-classes/" + propFileName),
null);
-
+
Process server = null;
boolean result = false;
try
@@ -192,11 +185,11 @@
"server",
serverStartedString);
Thread.sleep(2000);
-
+
Process client =
SpawnedVMSupport.spawnVM("org.hornetq.tests.integration.client.IncompatibleVersionTest",
new String[]{"-D" +
VersionLoader.VERSION_PROP_FILE_KEY + "=" + propFileName},
"client");
-
+
if(client.waitFor() == 0)
{
result = true;
@@ -213,10 +206,10 @@
catch(Throwable t) {/* ignore */}
}
}
-
+
return result;
}
-
+
private static class ServerStarter
{
public void perform(String startedString) throws Exception
@@ -226,7 +219,7 @@
conf.getAcceptorConfigurations().add(new
TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory"));
HornetQServer server = HornetQServers.newHornetQServer(conf, false);
server.start();
-
+
log.info("### server: " + startedString);
}
}
@@ -243,7 +236,7 @@
locator.close();
}
}
-
+
public static void main(String[] args) throws Exception
{
if(args[0].equals("server"))
@@ -261,7 +254,7 @@
throw new Exception("args[0] must be \"server\" or
\"client\"");
}
}
-
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -20,13 +20,12 @@
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* A SessionCloseOnGCTest
*
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
@@ -36,10 +35,7 @@
*/
public class SessionCloseOnGCTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(SessionCloseOnGCTest.class);
-
private HornetQServer server;
-
private ServerLocator locator;
@Override
@@ -53,24 +49,10 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- //locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
/** Make sure Sessions are not leaking after closed..
* Also... we want to make sure the SessionFactory will close itself when there are
not references into it */
public void testValidateFactoryGC1() throws Exception
{
- try
- {
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
@@ -97,27 +79,12 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
-
- }
- }
}
public void testValidateFactoryGC2() throws Exception
{
- try
- {
+ locator.setUseGlobalPools(false);
- locator.setUseGlobalPools(false);
-
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
@@ -144,24 +111,10 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
}
- catch (Throwable ignored)
- {
- }
- }
- }
-
public void testValidateFactoryGC3() throws Exception
{
- try
- {
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
@@ -186,25 +139,11 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
-
- }
- }
}
public void testValidateFactoryGC4() throws Exception
{
- try
- {
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
ClientSession s2 = factory.createSession();
@@ -225,25 +164,11 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
-
- }
- }
}
public void testValidateFactoryGC5() throws Exception
{
- try
- {
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = locator.createSessionFactory();
WeakReference<ClientSessionFactory> fref = new
WeakReference<ClientSessionFactory>(factory);
@@ -253,20 +178,8 @@
locator = null;
UnitTestCase.checkWeakReferences(fref);
- }
- finally
- {
- try
- {
- server.stop();
}
- catch (Throwable ignored)
- {
- }
- }
- }
-
public void testCloseOneSessionOnGC() throws Exception
{
ClientSessionFactoryImpl sf = (ClientSessionFactoryImpl)
locator.createSessionFactory();
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -41,7 +41,7 @@
public void testDurableFalse() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
session.createQueue(address, queueName, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -52,7 +52,7 @@
public void testDurableTrue() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
session.createQueue(address, queueName, true);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -63,7 +63,7 @@
public void testTemporaryFalse() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
session.createQueue(address, queueName, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -74,7 +74,7 @@
public void testTemporaryTrue() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
session.createTemporaryQueue(address, queueName);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -85,7 +85,7 @@
public void testcreateWithFilter() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
SimpleString filterString = new SimpleString("x=y");
session.createQueue(address, queueName, filterString, false);
Binding binding = server.getPostOffice().getBinding(queueName);
@@ -100,7 +100,7 @@
AddressSettings addressSettings = new AddressSettings();
addressSettings.setLastValueQueue(true);
server.getAddressSettingsRepository().addMatch(address.toString(),
addressSettings);
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
SimpleString filterString = new SimpleString("x=y");
session.createQueue(address, queueName, filterString, false);
Binding binding = server.getPostOffice().getBinding(queueName);
@@ -111,7 +111,7 @@
public void testDeleteQueue() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
session.createQueue(address, queueName, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Assert.assertNotNull(binding);
@@ -123,7 +123,7 @@
public void testDeleteQueueNotExist() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true,
true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true,
true);
try
{
session.deleteQueue(queueName);
@@ -144,20 +144,4 @@
server.start();
locator = createInVMNonHALocator();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- if (server != null && server.isStarted())
- {
- server.stop();
- }
-
- server = null;
-
- super.tearDown();
-
- }
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -45,28 +45,10 @@
locator.setProducerMaxRate(99);
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnNonDurableSend(true);
- cf = locator.createSessionFactory();
- clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
+ cf = createSessionFactory(locator);
+ clientSession = (ClientSessionInternal)addClientSession(cf.createSession(false,
true, true));
}
- @Override
- protected void tearDown() throws Exception
- {
- stopComponent(service);
- try
- {
- if (clientSession != null)
- clientSession.close();
- if (cf != null)
- cf.close();
- }
- finally
- {
- closeServerLocator(locator);
- super.tearDown();
- }
- }
-
public void testCreateConsumer() throws Exception
{
clientSession.createQueue(queueName, queueName, false);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -28,98 +28,54 @@
public class SessionCreateProducerTest extends ServiceTestBase
{
private ServerLocator locator;
+ private ClientSessionInternal clientSession;
+ private ClientSessionFactory cf;
@Override
protected void setUp() throws Exception
{
+ super.setUp();
locator = createInVMNonHALocator();
-
- super.setUp();
+ HornetQServer service = createServer(false);
+ service.start();
+ locator.setProducerMaxRate(99);
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
+ cf = createSessionFactory(locator);
+ clientSession = (ClientSessionInternal)addClientSession(cf.createSession(false,
true, true));
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
public void testCreateAnonProducer() throws Exception
{
- HornetQServer service = createServer(false);
- try
- {
- service.start();
- locator.setProducerMaxRate(99);
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSessionInternal clientSession =
(ClientSessionInternal)cf.createSession(false, true, true);
- ClientProducer producer = clientSession.createProducer();
- Assert.assertNull(producer.getAddress());
- Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(),
producer.getMaxRate());
- Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(),
producer.isBlockOnNonDurableSend());
- Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(),
producer.isBlockOnDurableSend());
- Assert.assertFalse(producer.isClosed());
- clientSession.close();
- }
- finally
- {
- service.stop();
- }
+ ClientProducer producer = clientSession.createProducer();
+ Assert.assertNull(producer.getAddress());
+ Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(),
producer.getMaxRate());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(),
producer.isBlockOnNonDurableSend());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(),
producer.isBlockOnDurableSend());
+ Assert.assertFalse(producer.isClosed());
}
public void testCreateProducer1() throws Exception
{
- HornetQServer service = createServer(false);
- try
- {
- service.start();
- locator.setProducerMaxRate(99);
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSessionInternal clientSession =
(ClientSessionInternal)cf.createSession(false, true, true);
- ClientProducer producer =
clientSession.createProducer("testAddress");
- Assert.assertNotNull(producer.getAddress());
- Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(),
producer.getMaxRate());
- Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(),
producer.isBlockOnNonDurableSend());
- Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(),
producer.isBlockOnDurableSend());
- Assert.assertFalse(producer.isClosed());
- clientSession.close();
- }
- finally
- {
- service.stop();
- }
+ ClientProducer producer = clientSession.createProducer("testAddress");
+ Assert.assertNotNull(producer.getAddress());
+ Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(),
producer.getMaxRate());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(),
producer.isBlockOnNonDurableSend());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(),
producer.isBlockOnDurableSend());
+ Assert.assertFalse(producer.isClosed());
}
public void testProducerOnClosedSession() throws Exception
{
- HornetQServer service = createServer(false);
+ clientSession.close();
try
{
- service.start();
- locator.setProducerMaxRate(99);
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSessionInternal clientSession =
(ClientSessionInternal)cf.createSession(false, true, true);
- clientSession.close();
- try
- {
- clientSession.createProducer();
- Assert.fail("should throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
- }
+ clientSession.createProducer();
+ Assert.fail("should throw exception");
}
- finally
+ catch (HornetQException e)
{
- service.stop();
+ Assert.assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
}
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -244,7 +244,7 @@
ClusterConnectionConfiguration cccLive = new
ClusterConnectionConfiguration("cluster1", "jms",
backupConnector.getName(), -1, false, false, 1, 1,
staticConnectors, false);
backupConfig.getClusterConfigurations().add(cccLive);
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultConfig();
liveConfig.getAcceptorConfigurations().clear();
@@ -260,7 +260,7 @@
liveConfig.getClusterConfigurations().add(ccc0);
liveConfig.getConnectorConfigurations().put(liveConnector.getName(),
liveConnector);
liveConfig.getConnectorConfigurations().put(backupConnector.getName(),
backupConnector);
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
}
@Override
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -15,12 +15,10 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
-import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientConsumer;
@@ -28,13 +26,13 @@
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.SessionFailureListener;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
import org.hornetq.core.client.impl.ServerLocatorInternal;
import org.hornetq.core.config.ClusterConnectionConfiguration;
import org.hornetq.core.server.impl.InVMNodeManager;
import org.hornetq.jms.client.HornetQTextMessage;
import org.hornetq.tests.integration.cluster.util.TestableServer;
+import org.hornetq.tests.util.CountDownSessionFailureListener;
import org.hornetq.tests.util.TransportConfigurationUtils;
/**
@@ -53,24 +51,6 @@
locator = getServerLocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- if (locator != null)
- {
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- //
- }
- }
- super.tearDown();
- }
-
-
public void testNoAutoFailback() throws Exception
{
locator.setBlockOnNonDurableSend(true);
@@ -78,11 +58,10 @@
locator.setFailoverOnInitialConnection(true);
locator.setReconnectAttempts(-1);
ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator,
2);
- final CountDownLatch latch = new CountDownLatch(1);
ClientSession session = sendAndConsume(sf, true);
- MyListener listener = new MyListener(latch);
+ CountDownSessionFailureListener listener = new CountDownSessionFailureListener(1);
session.addFailureListener(listener);
@@ -92,7 +71,7 @@
backupServer.start();
- assertTrue(latch.await(5, TimeUnit.SECONDS));
+ assertTrue(listener.getLatch().await(5, TimeUnit.SECONDS));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@@ -104,10 +83,8 @@
session.removeFailureListener(listener);
- final CountDownLatch latch2 = new CountDownLatch(1);
+ listener = new CountDownSessionFailureListener(1);
- listener = new MyListener(latch2);
-
session.addFailureListener(listener);
liveConfig.setAllowAutoFailBack(false);
@@ -122,7 +99,7 @@
backupServer.stop();
- assertTrue(latch2.await(15, TimeUnit.SECONDS));
+ assertTrue(listener.getLatch().await(15, TimeUnit.SECONDS));
message = session.createMessage(true);
@@ -162,7 +139,7 @@
staticConnectors, false);
backupConfig.getClusterConfigurations().add(cccLive);
backupConfig.setAllowAutoFailBack(false);
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultConfig();
liveConfig.getAcceptorConfigurations().clear();
@@ -178,7 +155,7 @@
liveConfig.getConnectorConfigurations().put(liveConnector.getName(),
liveConnector);
liveConfig.getConnectorConfigurations().put(backupConnector.getName(),
backupConnector);
liveConfig.setAllowAutoFailBack(false);
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
}
@Override
@@ -252,26 +229,6 @@
message.getBodyBuffer().writeString("message" + i);
}
- class MyListener implements SessionFailureListener
- {
- private final CountDownLatch latch;
-
- public MyListener(CountDownLatch latch)
- {
- this.latch = latch;
- }
-
- public void connectionFailed(final HornetQException me, boolean failedOver)
- {
- latch.countDown();
- }
-
- public void beforeReconnect(HornetQException exception)
- {
- System.out.println("MyListener.beforeReconnect");
- }
- }
-
class ServerStarter implements Runnable
{
private final TestableServer server;
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -129,7 +129,6 @@
}
- @Override
protected TestableServer createTestableServer(Configuration config)
{
return new SameProcessHornetQServer(
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -26,7 +26,7 @@
{
@Override
- protected TestableServer createServer(Configuration config)
+ protected TestableServer createTestableServer(Configuration config)
{
return new SameProcessHornetQServer(createServer(true, config));
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -74,12 +74,9 @@
{
if (session != null)
session.close();
- if (sf != null)
- sf.close();
}
finally
{
- closeServerLocator(locator);
super.tearDown();
}
}
@@ -219,7 +216,7 @@
}
@Override
- protected TestableServer createServer(Configuration config)
+ protected TestableServer createTestableServer(Configuration config)
{
return new SameProcessHornetQServer(createServer(true, config));
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -135,7 +135,7 @@
staticConnectors,
false);
backupConfig.getClusterConfigurations().add(cccLive);
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
HornetQSecurityManager securityManager = installSecurity(backupServer);
@@ -160,7 +160,7 @@
false);
liveConfig.getClusterConfigurations().add(ccc0);
liveConfig.getConnectorConfigurations().put(liveConnector.getName(),
liveConnector);
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
installSecurity(liveServer);
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -28,7 +28,6 @@
import org.hornetq.core.remoting.impl.netty.TransportConstants;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
-import org.hornetq.tests.util.UnitTestCase;
/**
* A IsolatedTopologyTest
@@ -40,18 +39,6 @@
public class IsolatedTopologyTest extends ServiceTestBase
{
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- @Override
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
public void testIsolatedClusters() throws Exception
{
@@ -59,9 +46,7 @@
HornetQServer server2 = createServer2();
- try
- {
- server1.start();
+ server1.start();
server2.start();
waitForTopology(server1, "cc1", 2, 5000);
@@ -102,26 +87,7 @@
node2,
createInVMTransportConnectorConfig(2, "srv1"),
createInVMTransportConnectorConfig(4, "srv1"));
- }
- finally
- {
Thread.sleep(500);
- try
- {
- server1.stop();
- }
- catch (Throwable ignored)
- {
- }
-
- try
- {
- server2.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
}
private void checkTopology(final HornetQServer serverParameter,
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -72,30 +72,14 @@
"operation@Update,id@16,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n"
+
"#File,JournalFileImpl: (hornetq-data-2.hq id = 2, recordID = 2)";
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- protected void tearDown() throws Exception
- {
-
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
public void _testCreateFormat() throws Exception
{
HornetQServer server = createServer(true);
server.start();
-
+
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = factory.createSession(false, false, false);
session.createQueue("A1", "A1");
@@ -147,7 +131,7 @@
server.start();
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = factory.createSession();
session.start();
@@ -161,10 +145,6 @@
}
session.commit();
-
- locator.close();
-
- server.stop();
}
// Package protected ---------------------------------------------
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -172,23 +172,4 @@
assertEquals(config.getCallTimeout(), cfs.get(0).getConfig().getCallTimeout());
}
-
- /**
- * @param journal
- * @throws Exception
- */
- private void checkSettings() throws Exception
- {
- List<PersistedConnectionFactory> listSetting =
jmsJournal.recoverConnectionFactories();
-
- assertEquals(mapExpectedCFs.size(), listSetting.size());
-
- for (PersistedConnectionFactory el : listSetting)
- {
- PersistedConnectionFactory el2 = mapExpectedCFs.get(el.getName());
-
- assertEquals(el, el2);
- }
- }
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -40,14 +40,6 @@
mapExpectedSets = new HashMap<SimpleString, PersistedRoles>();
}
- @Override
- protected void tearDown() throws Exception
- {
- mapExpectedSets = null;
-
- super.tearDown();
- }
-
protected void addSetting(PersistedRoles setting) throws Exception
{
mapExpectedSets.put(setting.getAddressMatch(), setting);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -21,14 +21,11 @@
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.remoting.impl.invm.InVMConnectorFactory;
-import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A SynchronousCloseTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -38,12 +35,6 @@
public class SynchronousCloseTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(SynchronousCloseTest.class);
-
- // Attributes ----------------------------------------------------
-
private HornetQServer server;
// Static --------------------------------------------------------
@@ -67,16 +58,6 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
protected boolean isNetty()
{
return false;
@@ -94,7 +75,7 @@
locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
}
- return locator.createSessionFactory();
+ return createSessionFactory(locator);
}
/*
@@ -118,9 +99,4 @@
sf.getServerLocator().close();
}
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java
===================================================================
---
trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java 2011-12-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -71,32 +71,22 @@
server.start();
ServerLocator locator = createFactory(IS_NETTY);
-
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
+
ClientSession session = sf.createSession();
session.createQueue(SimpleSendReceiveSoakTest.ADDRESS,
SimpleSendReceiveSoakTest.ADDRESS, true);
session.close();
-
- sf.close();
-
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
- server = null;
- }
-
public void testSoakClientTransactions() throws Exception
{
final ServerLocator locator = createFactory(IS_NETTY);
-
- final ClientSessionFactory sf = locator.createSessionFactory();
+ final ClientSessionFactory sf = createSessionFactory(locator);
+
ClientSession session = sf.createSession(true, true);
ClientProducer producer = session.createProducer(ADDRESS);
@@ -127,7 +117,7 @@
msg.getBodyBuffer().writeBytes(new byte[10 * 1024]);
producer.send(msg);
}
-
+
for (int i = 0; i < MIN_MESSAGES_ON_QUEUE; i++)
{
ClientMessage msg = consumer.receive(5000);
@@ -139,18 +129,5 @@
sessionConsumer.close();
session.close();
- sf.close();
- locator.close();
-
}
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // 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-06
11:41:24 UTC (rev 11853)
+++
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java 2011-12-06
11:42:23 UTC (rev 11854)
@@ -408,18 +408,6 @@
}
}
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- clearData();
- }
-
- /**
- * @throws Exception
- * @throws HornetQException
- */
private void setupServer(final JournalType journalType) throws Exception,
HornetQException
{
Configuration config = createDefaultConfig();
@@ -440,8 +428,8 @@
locator.setBlockOnDurableSend(false);
locator.setBlockOnAcknowledge(false);
- sf = locator.createSessionFactory();
- ClientSession sess = sf.createSession();
+ sf = createSessionFactory(locator);
+ ClientSession sess = addClientSession(sf.createSession());
try
{
@@ -469,40 +457,4 @@
sess.close();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- try
- {
- if (sf != null)
- {
- sf.close();
- }
-
- if (server != null)
- {
- server.stop();
- }
- }
- catch (Exception e)
- {
- e.printStackTrace(); // system.out -> junit reports
- }
-
- server = null;
-
- sf = null;
-
- super.tearDown();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}