Author: borges
Date: 2011-11-18 05:44:37 -0500 (Fri, 18 Nov 2011)
New Revision: 11700
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/RemoteSingleLiveMultipleBackupsFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java
Log:
Improve tearDown()
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/RemoteSingleLiveMultipleBackupsFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/RemoteSingleLiveMultipleBackupsFailoverTest.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/RemoteSingleLiveMultipleBackupsFailoverTest.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -20,8 +20,8 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientSession;
-import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
+import org.hornetq.core.client.impl.ServerLocatorImpl;
import org.hornetq.core.config.ClusterConnectionConfiguration;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.server.JournalType;
@@ -37,6 +37,7 @@
// Attributes ----------------------------------------------------
private static Map<Integer, String> backups = new HashMap<Integer,
String>();
+ private ClientSessionFactoryInternal sf;
// Static --------------------------------------------------------
@@ -58,13 +59,13 @@
servers.get(2).start();
servers.get(3).start();
- ServerLocator locator = getServerLocator(0);
+ locator = (ServerLocatorImpl)getServerLocator(0);
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
locator.setReconnectAttempts(-1);
- ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator,
2);
+ sf = createSessionFactoryAndWaitForTopology(locator, 2);
int backupNode;
ClientSession session = sendAndConsume(sf, true);
System.out.println("failing live node ");
@@ -94,10 +95,6 @@
backupNode = waitForNewLive(5, true, servers, 0);
assertEquals(0, backupNode);
session = sendAndConsume(sf, false);
-
- locator.close();
-
- servers.get(0).stop();
}
// Package protected ---------------------------------------------
@@ -120,12 +117,11 @@
@Override
protected void tearDown() throws Exception
{
- super.tearDown();
- // make sure
for (TestableServer testableServer : servers.values())
{
try
{
+ stopComponent(testableServer);
testableServer.destroy();
}
catch (Exception e)
@@ -133,7 +129,20 @@
e.printStackTrace(); // To change body of catch statement use File | Settings
| File Templates.
}
}
+ servers.clear();
+ try
+ {
+ if (sf != null)
+ {
+ sf.close();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ super.tearDown();
}
@Override
@@ -299,7 +308,6 @@
config1.getClusterConfigurations().add(ccc1);
config1.getConnectorConfigurations().put(backupConnector.getName(),
backupConnector);
- System.out.println(config1.getBindingsDirectory());
config1.setBindingsDirectory(config1.getBindingsDirectory() + "_" +
liveNode);
config1.setJournalDirectory(config1.getJournalDirectory() + "_" +
liveNode);
config1.setPagingDirectory(config1.getPagingDirectory() + "_" +
liveNode);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -17,7 +17,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientSession;
@@ -38,6 +37,7 @@
{
protected Map<Integer, TestableServer> servers = new HashMap<Integer,
TestableServer>();
+ protected ServerLocatorImpl locator;
private NodeManager nodeManager;
Logger log = Logger.getLogger(SingleLiveMultipleBackupsFailoverTest.class);
@@ -71,7 +71,7 @@
servers.get(4).start();
servers.get(5).start();
- ServerLocatorImpl locator = (ServerLocatorImpl)getServerLocator(0);
+ locator = (ServerLocatorImpl)getServerLocator(0);
Topology topology = locator.getTopology();
@@ -191,11 +191,11 @@
@Override
protected void tearDown() throws Exception
{
- for (Entry<Integer, TestableServer> entry : servers.entrySet())
+ for (TestableServer server : servers.values())
{
try
{
- entry.getValue().stop();
+ stopComponent(server);
}
catch (Exception e)
{
@@ -203,6 +203,7 @@
}
}
servers.clear();
+ closeServerLocator(locator);
super.tearDown();
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -16,12 +16,11 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServers;
/**
- *
+ *
* A MultiThreadRandomReattachTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -43,9 +42,6 @@
liveServer.start();
}
- /* (non-Javadoc)
- * @see
org.hornetq.tests.integration.cluster.failover.MultiThreadRandomReattachTestBase#setBody(org.hornetq.api.core.client.ClientMessage)
- */
@Override
protected void setBody(final ClientMessage message) throws Exception
{
@@ -53,9 +49,6 @@
message.getBodyBuffer().writeBytes(new byte[250]);
}
- /* (non-Javadoc)
- * @see
org.hornetq.tests.integration.cluster.failover.MultiThreadRandomReattachTestBase#checkSize(org.hornetq.api.core.client.ClientMessage)
- */
@Override
protected boolean checkSize(final ClientMessage message)
{
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -45,8 +45,8 @@
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
- *
*
+ *
*/
public abstract class MultiThreadRandomReattachTestBase extends
MultiThreadReattachSupport
{
@@ -276,7 +276,7 @@
ClientSession session = sf.createSession(false, false, false);
session.addMetaData("someData", RandomUtil.randomString());
session.addMetaData("someData2", RandomUtil.randomString());
-
+
return session;
}
@@ -828,8 +828,8 @@
ClientSession s = sf.createSession(false, false, false);
s.addMetaData("data", RandomUtil.randomString());
-
+
final int numMessages = 100;
final int numSessions = 10;
@@ -907,8 +907,8 @@
ClientSession sessConsume = sf.createSession(false, false, false);
sessConsume.addMetaData("data", RandomUtil.randomString());
-
+
sessConsume.start();
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName,
null, false);
@@ -1159,7 +1159,7 @@
for (int i = 0; i < numSessions; i++)
{
ClientSession session = sf.createSession(false, false, false);
-
+
session.addMetaData("data", RandomUtil.randomString());
session.close();
@@ -1246,7 +1246,7 @@
{
return 2;
}
-
+
protected int getNumThreads()
{
return 10;
@@ -1263,10 +1263,7 @@
@Override
protected void tearDown() throws Exception
{
- if (liveServer != null && liveServer.isStarted())
- {
- liveServer.stop();
- }
+ stopComponent(liveServer);
liveServer = null;
@@ -1306,7 +1303,7 @@
@Override
protected void stop() throws Exception
{
- liveServer.stop();
+ stopComponent(liveServer);
System.gc();
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -70,7 +70,7 @@
public void destroy()
{
- if(serverProcess != null)
+ if (serverProcess != null)
{
serverProcess.destroy();
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlTest.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -17,6 +17,7 @@
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.ClientSession;
@@ -25,10 +26,7 @@
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.api.core.management.AcceptorControl;
import org.hornetq.api.core.management.NotificationType;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
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.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.server.HornetQServer;
@@ -41,7 +39,7 @@
* A AcceptorControlTest
*
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
+ *
* Created 11 dec. 2008 17:38:58
*
*
@@ -49,13 +47,8 @@
public class AcceptorControlTest extends ManagementTestBase
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(AcceptorControlTest.class);
-
- // Attributes ----------------------------------------------------
-
private HornetQServer service;
+ private ServerLocator locator;
// Static --------------------------------------------------------
@@ -98,7 +91,9 @@
// started by the server
Assert.assertTrue(acceptorControl.isStarted());
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
+ locator =
+ HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(
+
InVMConnectorFactory.class.getName()));
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, true, true);
Assert.assertNotNull(session);
@@ -113,7 +108,7 @@
sf.createSession(false, true, true);
Assert.fail("acceptor must not accept connections when stopped
accepting");
}
- catch (Exception e)
+ catch (HornetQException e)
{
}
@@ -136,7 +131,7 @@
sf.createSession(false, true, true);
Assert.fail("acceptor must not accept connections when stopped
accepting");
}
- catch (Exception e)
+ catch (HornetQException e)
{
}
@@ -186,11 +181,8 @@
@Override
protected void tearDown() throws Exception
{
- if (service != null)
- {
- service.stop();
- }
-
+ stopComponent(service);
+ closeServerLocator(locator);
super.tearDown();
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AcceptorControlUsingCoreTest.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -22,8 +22,6 @@
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.api.core.management.AcceptorControl;
import org.hornetq.api.core.management.ResourceNames;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.tests.util.UnitTestCase;
/**
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -55,7 +55,6 @@
// Attributes ----------------------------------------------------
private HornetQServer server;
-
protected ClientSession session;
private ServerLocator locator;
@@ -104,13 +103,13 @@
session.deleteQueue(anotherQueue);
}
-
+
public void testGetBindingNames() throws Exception
{
SimpleString address = RandomUtil.randomSimpleString();
SimpleString queue = RandomUtil.randomSimpleString();
String divertName = RandomUtil.randomString();
-
+
session.createQueue(address, queue, false);
AddressControl addressControl = createManagementControl(address);
@@ -122,9 +121,9 @@
bindingNames = addressControl.getBindingNames();
Assert.assertEquals(2, bindingNames.length);
-
+
session.deleteQueue(queue);
-
+
bindingNames = addressControl.getBindingNames();
assertEquals(1, bindingNames.length);
assertEquals(divertName.toString(), bindingNames[0]);
@@ -316,12 +315,12 @@
@Override
protected void tearDown() throws Exception
{
- session.close();
+ if (session != null)
+ session.close();
- locator.close();
+ closeServerLocator(locator);
+ stopComponent(server);
- server.stop();
-
server = null;
session = null;
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java 2011-11-18
10:44:07 UTC (rev 11699)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java 2011-11-18
10:44:37 UTC (rev 11700)
@@ -29,9 +29,7 @@
import org.hornetq.api.core.management.AddressControl;
import org.hornetq.api.core.management.ResourceNames;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.security.CheckType;
import org.hornetq.core.security.Role;
import org.hornetq.core.server.HornetQServer;