Author: borges
Date: 2011-12-05 08:49:22 -0500 (Mon, 05 Dec 2011)
New Revision: 11827
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AckBatchSizeTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AddressSettingsTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/AlmostLargeAsynchronousFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.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/FailoverOnFlowControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTest.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/LargeMessageFailoverTest.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/ReplicatedFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedNettyAsynchronousFailoverTest.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/remoting/BatchDelayTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java
Log:
Keep track of servers created at ServiceTestBase, and close them at tearDown
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
---
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -16,8 +16,8 @@
import java.io.File;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -80,11 +80,42 @@
protected static final String NETTY_CONNECTOR_FACTORY =
NettyConnectorFactory.class.getCanonicalName();
- private final List<ServerLocator> locators = new
ArrayList<ServerLocator>();
+ private final Collection<ServerLocator> locators = new
ArrayList<ServerLocator>();
+ private final Collection<HornetQServer> servers = new
ArrayList<HornetQServer>();
+ private final Collection<ClientSessionFactory> sessionFactories = new
ArrayList<ClientSessionFactory>();
+ private final Collection<ClientSession> clientSessions = new
ArrayList<ClientSession>();
@Override
protected void tearDown() throws Exception
{
+ synchronized (clientSessions)
+ {
+ for (ClientSession cs : clientSessions)
+ {
+ try
+ {
+ if (cs != null)
+ {
+ cs.close();
+ }
+ }
+ catch (Exception e)
+ {
+ // no-op
+ }
+ }
+ clientSessions.clear();
+ }
+
+ synchronized (sessionFactories)
+ {
+ for (ClientSessionFactory sf : sessionFactories)
+ {
+ closeSessionFactory(sf);
+ }
+ sessionFactories.clear();
+ }
+
synchronized (locators)
{
for (ServerLocator locator : locators)
@@ -93,6 +124,16 @@
}
locators.clear();
}
+
+ synchronized (servers)
+ {
+ for (HornetQServer server : servers)
+ {
+ stopComponent(server);
+ }
+ servers.clear();
+ }
+
super.tearDown();
// checkFreePort(5445);
// checkFreePort(5446);
@@ -319,7 +360,8 @@
{
server = HornetQServers.newHornetQServer(configuration, mbeanServer, false);
}
-
+ try
+ {
for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
{
server.getAddressSettingsRepository().addMatch(setting.getKey(),
setting.getValue());
@@ -331,9 +373,39 @@
server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+ return server;
+ }
+ finally
+ {
+ addServer(server);
+ }
+ }
+
+ protected HornetQServer addServer(HornetQServer server)
+ {
+ synchronized (servers)
+ {
+ servers.add(server);
+ }
return server;
}
+ protected ClientSession addClientSession(ClientSession session)
+ {
+ synchronized (clientSessions)
+ {
+ clientSessions.add(session);
+ }
+ return session;
+ }
+
+ protected void addSessionFactory(ClientSessionFactory sf)
+ {
+ synchronized (sessionFactories)
+ {
+ sessionFactories.add(sf);
+ }
+ }
protected HornetQServer createServer(final boolean realFiles,
final Configuration configuration,
final int pageSize,
@@ -360,7 +432,8 @@
{
server = HornetQServers.newHornetQServer(configuration, false);
}
-
+ try
+ {
if (settings != null)
{
for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
@@ -377,6 +450,11 @@
server.getAddressSettingsRepository().addMatch("#", defaultSetting);
return server;
+ }
+ finally
+ {
+ addServer(server);
+ }
}
protected HornetQServer createServer(final boolean realFiles,
@@ -394,7 +472,8 @@
{
server = HornetQServers.newHornetQServer(configuration, mbeanServer, false);
}
-
+ try
+ {
for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
{
server.getAddressSettingsRepository().addMatch(setting.getKey(),
setting.getValue());
@@ -403,7 +482,14 @@
AddressSettings defaultSetting = new AddressSettings();
server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+
+
return server;
+ }
+ finally
+ {
+ addServer(server);
+ }
}
protected HornetQServer createServer(final boolean realFiles)
@@ -451,7 +537,9 @@
securityManager,
nodeManager);
- server.setIdentity("Server " + id);
+ try
+ {
+ server.setIdentity("Server " + id);
for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
{
@@ -465,6 +553,11 @@
server.getAddressSettingsRepository().addMatch("#", defaultSetting);
return server;
+ }
+ finally
+ {
+ addServer(server);
+ }
}
protected HornetQServer createServer(final boolean realFiles,
@@ -486,7 +579,8 @@
securityManager,
false);
}
-
+ try
+ {
Map<String, AddressSettings> settings = new HashMap<String,
AddressSettings>();
for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
@@ -498,7 +592,12 @@
server.getAddressSettingsRepository().addMatch("#", defaultSetting);
- return server;
+ return server;
+ }
+ finally
+ {
+ addServer(server);
+ }
}
protected HornetQServer createClusteredServerWithParams(final boolean isNetty,
@@ -561,6 +660,12 @@
}
}
+ protected final ClientSessionFactory createSessionFactory(ServerLocator locator)
throws Exception
+ {
+ ClientSessionFactory sf = locator.createSessionFactory();
+ addSessionFactory(sf);
+ return sf;
+ }
protected void createQueue(final String address, final String queue) throws Exception
{
ServerLocator locator = createInVMNonHALocator();
@@ -586,16 +691,17 @@
{
ServerLocator locatorWithoutHA = isNetty ?
HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NETTY_CONNECTOR_FACTORY))
:
HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(INVM_CONNECTOR_FACTORY));
- addServerLocator(locatorWithoutHA);
- return locatorWithoutHA;
+ return addServerLocator(locatorWithoutHA);
+
}
- private void addServerLocator(ServerLocator locator)
+ protected ServerLocator addServerLocator(ServerLocator locator)
{
synchronized (locators)
{
locators.add(locator);
}
+ return locator;
}
protected ServerLocator createInVMLocator(final int serverID)
@@ -603,8 +709,7 @@
TransportConfiguration tnspConfig = createInVMTransportConnectorConfig(serverID,
UUIDGenerator.getInstance().generateStringUUID());
ServerLocator locator = HornetQClient.createServerLocatorWithHA(tnspConfig);
- addServerLocator(locator);
- return locator;
+ return addServerLocator(locator);
}
/**
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AckBatchSizeTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AckBatchSizeTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AckBatchSizeTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -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.core.server.Queue;
import org.hornetq.tests.util.ServiceTestBase;
@@ -26,8 +30,6 @@
*/
public class AckBatchSizeTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(AckBatchSizeTest.class);
-
public final SimpleString addressA = new SimpleString("addressA");
public final SimpleString queueA = new SimpleString("queueA");
@@ -59,9 +61,6 @@
public void testAckBatchSize() throws Exception
{
HornetQServer server = createServer(false);
-
- try
- {
server.start();
ServerLocator locator = createInVMNonHALocator();
int numMessages = 100;
@@ -94,14 +93,6 @@
Assert.assertEquals(0, q.getDeliveringCount());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
/*
@@ -111,8 +102,6 @@
{
HornetQServer server = createServer(false);
- try
- {
server.start();
ServerLocator locator = createInVMNonHALocator();
locator.setAckBatchSize(0);
@@ -145,13 +134,5 @@
}
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AcknowledgeTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -19,7 +19,13 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
@@ -43,9 +49,7 @@
public void testReceiveAckLastMessageOnly() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
ServerLocator locator = createInVMNonHALocator();
locator.setAckBatchSize(0);
locator.setBlockOnAcknowledge(true);
@@ -73,21 +77,12 @@
Assert.assertEquals(0, q.getDeliveringCount());
session.close();
sendSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testAsyncConsumerNoAck() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory cf = locator.createSessionFactory();;
@@ -101,10 +96,10 @@
{
cp.send(sendSession.createMessage(false));
}
-
+
Thread.sleep(500);
log.info("woke up");
-
+
final CountDownLatch latch = new CountDownLatch(numMessages);
session.start();
cc.setMessageHandler(new MessageHandler()
@@ -121,22 +116,12 @@
Assert.assertEquals(numMessages, q.getDeliveringCount());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
public void testAsyncConsumerAck() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnAcknowledge(true);
locator.setAckBatchSize(0);
@@ -180,22 +165,12 @@
Assert.assertEquals(0, q.getDeliveringCount());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testAsyncConsumerAckLastMessageOnly() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
ServerLocator locator = createInVMNonHALocator();
locator.setBlockOnAcknowledge(true);
locator.setAckBatchSize(0);
@@ -242,14 +217,6 @@
Assert.assertEquals(0, q.getDeliveringCount());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AddressSettingsTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AddressSettingsTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AddressSettingsTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -15,7 +15,12 @@
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.core.server.HornetQServer;
import org.hornetq.core.settings.HierarchicalRepository;
import org.hornetq.core.settings.impl.AddressSettings;
@@ -57,8 +62,7 @@
public void testSimpleHierarchyWithDLA() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
AddressSettings addressSettings = new AddressSettings();
addressSettings.setDeadLetterAddress(dlaA);
@@ -108,21 +112,13 @@
Assert.assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
public void test2LevelHierarchyWithDLA() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
AddressSettings addressSettings = new AddressSettings();
addressSettings.setDeadLetterAddress(dlaA);
@@ -172,22 +168,13 @@
Assert.assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
public void test2LevelWordHierarchyWithDLA() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
- server.start();
+ server.start();
AddressSettings addressSettings = new AddressSettings();
addressSettings.setDeadLetterAddress(dlaA);
addressSettings.setMaxDeliveryAttempts(1);
@@ -236,21 +223,12 @@
Assert.assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
public void test3LevelHierarchyWithDLA() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
AddressSettings addressSettings = new AddressSettings();
addressSettings.setDeadLetterAddress(dlaA);
@@ -319,21 +297,13 @@
Assert.assertEquals("C", message.getBodyBuffer().readString());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
public void testOverrideHierarchyWithDLA() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
AddressSettings addressSettings = new AddressSettings();
addressSettings.setMaxDeliveryAttempts(1);
@@ -392,13 +362,6 @@
Assert.assertNotNull(message);
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/AutogroupIdTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -18,7 +18,13 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -49,8 +55,7 @@
public void testGroupIdAutomaticallySet() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
ServerLocator locator = createInVMNonHALocator();
@@ -73,7 +78,7 @@
consumer2.setMessageHandler(myMessageHandler2);
log.info("starting session");
-
+
session.start();
final int numMessages = 100;
@@ -85,19 +90,11 @@
latch.await();
session.close();
-
+
log.info(myMessageHandler2.messagesReceived);
Assert.assertEquals(100, myMessageHandler.messagesReceived);
Assert.assertEquals(0, myMessageHandler2.messagesReceived);
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
@@ -107,8 +104,7 @@
public void testGroupIdAutomaticallySetMultipleProducers() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
@@ -154,15 +150,6 @@
Assert.assertEquals(myMessageHandler.messagesReceived, 100);
Assert.assertEquals(myMessageHandler2.messagesReceived, 100);
Assert.assertEquals(myMessageHandler3.messagesReceived, 0);
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
-
}
/*
@@ -171,8 +158,7 @@
public void testGroupIdAutomaticallyNotSet() throws Exception
{
HornetQServer server = createServer(false);
- try
- {
+
server.start();
@@ -209,14 +195,6 @@
Assert.assertEquals(50, myMessageHandler.messagesReceived);
Assert.assertEquals(50, myMessageHandler2.messagesReceived);
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/AlmostLargeAsynchronousFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/AlmostLargeAsynchronousFailoverTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/AlmostLargeAsynchronousFailoverTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -26,20 +26,7 @@
public class AlmostLargeAsynchronousFailoverTest extends AsynchronousFailoverTest
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
+ @Override
protected void createConfigs() throws Exception
{
super.createConfigs();
@@ -47,6 +34,7 @@
backupServer.getServer().getConfiguration().setJournalFileSize(1024 * 1024);
}
+ @Override
protected ServerLocatorInternal getServerLocator() throws Exception
{
ServerLocatorInternal locator = super.getServerLocator();
@@ -55,13 +43,10 @@
return locator;
}
+ @Override
protected void addPayload(ClientMessage message)
{
message.putBytesProperty("payload", new byte[20 * 1024]);
}
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -227,14 +227,10 @@
@Override
protected void tearDown() throws Exception
{
- if (sessionFactory != null)
- sessionFactory.close();
if (session != null)
session.close();
if (producer != null)
producer.close();
- closeServerLocator(locator);
-
super.tearDown();
}
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-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -55,13 +55,6 @@
locator = getServerLocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- closeServerLocator(locator);
- super.tearDown();
- }
-
public void testAutoFailback() throws Exception
{
locator.setBlockOnNonDurableSend(true);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverOnFlowControlTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverOnFlowControlTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverOnFlowControlTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -41,21 +41,9 @@
*/
public class FailoverOnFlowControlTest extends FailoverTestBase
{
-
private static Logger log = Logger.getLogger(FailoverOnFlowControlTest.class);
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
-
public void testOverflowSend() throws Exception
{
ServerLocator locator = getServerLocator();
@@ -129,8 +117,6 @@
}
session.close();
-
- locator.close();
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -90,30 +90,22 @@
locator = getServerLocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- closeSessionFactory();
- closeServerLocator(locator);
- super.tearDown();
- }
-
protected ClientSession createSession(ClientSessionFactory sf,
boolean autoCommitSends,
boolean autoCommitAcks,
int ackBatchSize) throws Exception
{
- return sf.createSession(autoCommitSends, autoCommitAcks, ackBatchSize);
+ return addClientSession(sf.createSession(autoCommitSends, autoCommitAcks,
ackBatchSize));
}
protected ClientSession createSession(ClientSessionFactory sf, boolean
autoCommitSends, boolean autoCommitAcks) throws Exception
{
- return sf.createSession(autoCommitSends, autoCommitAcks);
+ return addClientSession(sf.createSession(autoCommitSends, autoCommitAcks));
}
protected ClientSession createSession(ClientSessionFactory sf) throws Exception
{
- return sf.createSession();
+ return addClientSession(sf.createSession());
}
protected ClientSession createSession(ClientSessionFactory sf,
@@ -121,7 +113,7 @@
boolean autoCommitSends,
boolean autoCommitAcks) throws Exception
{
- return sf.createSession(xa, autoCommitSends, autoCommitAcks);
+ return addClientSession(sf.createSession(xa, autoCommitSends, autoCommitAcks));
}
@Override
@@ -143,7 +135,7 @@
locator.setAckBatchSize(0);
locator.setReconnectAttempts(-1);
- sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ createClientSessionFactory();
ClientSession session = createSession(sf, true, true);
@@ -206,6 +198,15 @@
Assert.assertTrue(retry <= 5);
}
+ /**
+ * @throws Exception
+ */
+ private void createClientSessionFactory() throws Exception
+ {
+ sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ addSessionFactory(sf);
+ }
+
public void testNonTransacted() throws Exception
{
@@ -962,7 +963,7 @@
Thread.sleep(5000);
- sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ createClientSessionFactory();
session = sendAndConsume(sf, true);
@@ -1239,7 +1240,7 @@
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
locator.setReconnectAttempts(-1);
- sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ createClientSessionFactory();
// Add an interceptor to delay the send method so we can get time to cause failover
before it returns
@@ -1433,15 +1434,6 @@
session2.close();
}
- private void closeSessionFactory()
- {
- if (sf == null)
- return;
- closeSessionFactory(sf);
- Assert.assertEquals(0, sf.numSessions());
- Assert.assertEquals(0, sf.numConnections());
- }
-
public void testCommitDidNotOccurUnblockedAndResend() throws Exception
{
locator.setBlockOnNonDurableSend(true);
@@ -1661,7 +1653,7 @@
sf.close();
- sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ createClientSessionFactory();
session = createSession(sf);
@@ -1722,7 +1714,7 @@
sf.close();
- sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ createClientSessionFactory();
session = createSession(sf);
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-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -16,7 +16,6 @@
import java.io.IOException;
import java.net.ServerSocket;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,7 +30,6 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ClientSession;
-import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.ClusterTopologyListener;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
@@ -83,8 +81,6 @@
protected NodeManager nodeManager;
protected boolean startBackupServer = true;
- private final Collection<ServerLocator> serverLocators = new
ArrayList<ServerLocator>();
- private final Collection<ClientSessionFactory> sessionFactories = new
ArrayList<ClientSessionFactory>();
// Static --------------------------------------------------------
@@ -130,6 +126,7 @@
waitForServer(backupServer.getServer());
}
}
+
}
protected TestableServer createServer(Configuration config)
@@ -235,28 +232,10 @@
protected void tearDown() throws Exception
{
logAndSystemOut("#test tearDown");
- stopComponent(backupServer);
- stopComponent(liveServer);
- synchronized (sessionFactories)
- {
- for (ClientSessionFactory sf : sessionFactories)
- {
- closeSessionFactory(sf);
- }
- sessionFactories.clear();
- }
+ InVMConnector.failOnCreateConnection = false;
- synchronized (serverLocators)
- {
- for (ServerLocator locator : serverLocators)
- {
- closeServerLocator(locator);
- }
- serverLocators.clear();
- }
-
-
+ super.tearDown();
Assert.assertEquals(0, InVMRegistry.instance.size());
backupServer = null;
@@ -265,9 +244,6 @@
nodeManager = null;
- InVMConnector.failOnCreateConnection = false;
-
- super.tearDown();
try
{
ServerSocket serverSocket = new ServerSocket(5445);
@@ -297,10 +273,7 @@
locator.addClusterTopologyListener(new
LatchClusterTopologyListener(countDownLatch));
sf = (ClientSessionFactoryInternal) locator.createSessionFactory();
- synchronized (sessionFactories)
- {
- sessionFactories.add(sf);
- }
+ addSessionFactory(sf);
assertTrue("topology members expected " + topologyMembers,
countDownLatch.await(5, TimeUnit.SECONDS));
return sf;
}
@@ -397,10 +370,7 @@
protected ServerLocatorInternal getServerLocator() throws Exception
{
ServerLocator locator =
HornetQClient.createServerLocatorWithHA(getConnectorTransportConfiguration(true),
getConnectorTransportConfiguration(false));
- synchronized (serverLocators)
- {
- serverLocators.add(locator);
- }
+ addServerLocator(locator);
return (ServerLocatorInternal) locator;
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -16,7 +16,6 @@
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.client.impl.ServerLocatorInternal;
-import org.hornetq.core.logging.Logger;
/**
* A LargeMessageFailoverTest
@@ -28,22 +27,6 @@
public class LargeMessageFailoverTest extends FailoverTest
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(LargeMessageFailoverTest.class);
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
public LargeMessageFailoverTest(final String name)
{
super(name);
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-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -214,9 +214,8 @@
@Override
protected HornetQServer createServer(final boolean realFiles, final Configuration
configuration)
{
- return createInVMFailoverServer(true, configuration, PAGE_SIZE, PAGE_MAX, new
HashMap<String, AddressSettings>(),
- nodeManager,
- 2);
+ return addServer(createInVMFailoverServer(true, configuration, PAGE_SIZE,
PAGE_MAX,
+ new HashMap<String,
AddressSettings>(), nodeManager, 2));
}
@Override
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedFailoverTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedFailoverTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -23,28 +23,9 @@
public class ReplicatedFailoverTest extends FailoverTest
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
@Override
protected void createConfigs() throws Exception
{
createReplicatedConfigs();
}
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedNettyAsynchronousFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedNettyAsynchronousFailoverTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedNettyAsynchronousFailoverTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -13,10 +13,6 @@
package org.hornetq.tests.integration.cluster.failover;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.tests.integration.cluster.util.SameProcessHornetQServer;
-import org.hornetq.tests.integration.cluster.util.TestableServer;
-
/**
* A ReplicatedNettyAsynchronousFailoverTest
*
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-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -57,13 +57,16 @@
boolean autoCommitAcks,
int ackBatchSize) throws Exception
{
- return sf.createSession("a",
+ ClientSession session =
+ sf.createSession("a",
"b",
isXA,
autoCommitSends,
autoCommitAcks,
sf.getServerLocator().isPreAcknowledge(),
ackBatchSize);
+ addClientSession(session);
+ return session;
}
@Override
@@ -72,8 +75,11 @@
boolean autoCommitAcks,
int ackBatchSize) throws Exception
{
- return sf.createSession("a", "b", false, autoCommitSends,
autoCommitAcks, sf.getServerLocator()
+ ClientSession session =
+ sf.createSession("a", "b", false, autoCommitSends,
autoCommitAcks, sf.getServerLocator()
.isPreAcknowledge(), ackBatchSize);
+ addClientSession(session);
+ return session;
}
@Override
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/BatchDelayTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/BatchDelayTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/BatchDelayTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -17,18 +17,21 @@
import java.util.Map;
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.remoting.impl.netty.NettyAcceptorFactory;
-import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.remoting.impl.netty.TransportConstants;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A BatchDelayTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -38,12 +41,8 @@
public class BatchDelayTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(BatchDelayTest.class);
-
private static final long DELAY = 500;
-
+
// Attributes ----------------------------------------------------
private HornetQServer server;
@@ -76,16 +75,6 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
protected ClientSessionFactory createSessionFactory() throws Exception
{
Map<String, Object> params = new HashMap<String, Object>();
@@ -93,7 +82,7 @@
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY, params));
ClientSessionFactory sf = locator.createSessionFactory();
-
+ addSessionFactory(sf);
return sf;
}
@@ -130,8 +119,6 @@
msg.acknowledge();
}
-
- sf.close();
}
public void testSendReceiveOne() throws Exception
@@ -157,10 +144,8 @@
msg = cons.receive(10000);
assertNotNull(msg);
-
- msg.acknowledge();
- sf.close();
+ msg.acknowledge();
}
// Private -------------------------------------------------------
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java 2011-12-05
12:43:53 UTC (rev 11826)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java 2011-12-05
13:49:22 UTC (rev 11827)
@@ -25,7 +25,13 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
@@ -133,103 +139,103 @@
super.tearDown();
}
-
-
+
+
public void testSendWithoutXID() throws Exception
{
// Since both resources have same RM, TM will probably use 1PC optimization
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory factory = locator.createSessionFactory();
-
+
ClientSession session = null;
-
+
try
{
-
+
session = factory.createSession(true, false, false);
session.createQueue("Test", "Test");
-
+
ClientProducer prod = session.createProducer("Test");
prod.send(session.createMessage(true));
-
+
session.start();
-
+
ClientConsumer cons = session.createConsumer("Test");
-
+
assertNotNull("Send went through an invalid XA Session",
cons.receiveImmediate());
}
finally
{
factory.close();
-
+
session.close();
}
}
-
+
public void testACKWithoutXID() throws Exception
{
// Since both resources have same RM, TM will probably use 1PC optimization
ClientSessionFactory factory = locator.createSessionFactory();
-
+
ClientSession session = null;
-
+
try
{
-
+
session = factory.createSession(false, true, true);
session.createQueue("Test", "Test");
-
+
ClientProducer prod = session.createProducer("Test");
prod.send(session.createMessage(true));
-
+
session.close();
-
+
session = factory.createSession(true, false, false);
-
+
session.start();
-
+
ClientConsumer cons = session.createConsumer("Test");
-
+
ClientMessage msg = cons.receive(5000);
-
+
assertNotNull(msg);
-
+
msg.acknowledge();
-
+
session.close();
-
+
session = factory.createSession(false, false, false);
-
+
session.start();
-
+
cons = session.createConsumer("Test");
-
+
msg = cons.receiveImmediate();
-
+
assertNull("Acknowledge went through invalid XA Session", msg);
-
-
+
+
}
finally
{
factory.close();
-
+
session.close();
}
}
-
+
public void testIsSameRM() throws Exception
{
ServerLocator locator = createNettyNonHALocator();
@@ -258,8 +264,8 @@
session2.close();
}
-
+
public void testXAInterleaveResourceSuspendWorkCommit() throws Exception
{
Xid xid = newXID();
@@ -315,7 +321,7 @@
clientSession.prepare(xid3);
clientSession.commit(xid3, false);
}
-
+
public void testSendPrepareDoesntRollbackOnClose() throws Exception
{
Xid xid = newXID();
@@ -338,7 +344,7 @@
clientSession = sessionFactory.createSession(true, false, false);
log.info("committing");
-
+
clientSession.commit(xid, false);
clientSession.start();
ClientConsumer clientConsumer = clientSession.createConsumer(atestq);
@@ -406,7 +412,7 @@
clientSession2.close();
}
-
+
public void testReceiveRollback() throws Exception
{
int numSessions = 100;
@@ -986,7 +992,6 @@
}
}
- private static volatile int received = 0;
class TxMessageHandler implements MessageHandler
{