Author: igarashitm
Date: 2011-12-02 16:23:10 -0500 (Fri, 02 Dec 2011)
New Revision: 11819
Modified:
branches/HORNETQ-316/
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java
Log:
svn merge -r r11811:r11816
https://svn.jboss.org/repos/hornetq/trunk
Property changes on: branches/HORNETQ-316
___________________________________________________________________
Added: svn:mergeinfo
+ /trunk:11812-11816
Modified:
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
---
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-02
21:21:00 UTC (rev 11818)
+++
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-02
21:23:10 UTC (rev 11819)
@@ -101,34 +101,6 @@
}
}
- public static final void closeServerLocator(ServerLocator locator)
- {
- if (locator == null)
- return;
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public static final void closeSessionFactory(final ClientSessionFactory sf)
- {
- if (sf == null)
- return;
- try
- {
- sf.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
protected void waitForTopology(final HornetQServer server, final int nodes) throws
Exception
{
waitForTopology(server, nodes, WAIT_TIMEOUT);
@@ -228,21 +200,6 @@
}
}
- protected static final void stopComponent(HornetQComponent component)
- {
- if (component == null)
- return;
- if (component.isStarted())
- try
- {
- component.stop();
- }
- catch (Exception e)
- {
- // no-op
- }
- }
-
protected static Map<String, Object> generateParams(final int node, final
boolean netty)
{
Map<String, Object> params = new HashMap<String, Object>();
Modified:
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
---
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-02
21:21:00 UTC (rev 11818)
+++
branches/HORNETQ-316/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-02
21:23:10 UTC (rev 11819)
@@ -89,6 +89,7 @@
import org.hornetq.core.remoting.impl.invm.InVMRegistry;
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
+import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.MessageReference;
@@ -1490,6 +1491,49 @@
}
+ protected static final void stopComponent(HornetQComponent component)
+ {
+ if (component == null)
+ return;
+ if (component.isStarted())
+ try
+ {
+ component.stop();
+ }
+ catch (Exception e)
+ {
+ // no-op
+ }
+ }
+
+ public static final void closeServerLocator(ServerLocator locator)
+ {
+ if (locator == null)
+ return;
+ try
+ {
+ locator.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static final void closeSessionFactory(final ClientSessionFactory sf)
+ {
+ if (sf == null)
+ return;
+ try
+ {
+ sf.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified:
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
===================================================================
---
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-12-02
21:21:00 UTC (rev 11818)
+++
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-12-02
21:23:10 UTC (rev 11819)
@@ -17,9 +17,14 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.tests.util.UnitTestCase;
@@ -30,9 +35,9 @@
public class WildCardRoutingTest extends UnitTestCase
{
private HornetQServer server;
-
- private ClientSession clientSession;
private ServerLocator locator;
+ private ClientSession clientSession;
+ private ClientSessionFactory sessionFactory;
public void testBasicWildcardRouting() throws Exception
{
@@ -766,7 +771,7 @@
server.getManagementService().enableNotifications(false);
// then we create a client as normal
locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ sessionFactory = locator.createSessionFactory();
clientSession = sessionFactory.createSession(false, true, true);
}
@@ -784,20 +789,12 @@
//
}
}
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e1)
- {
- //
- }
- }
+ closeSessionFactory(sessionFactory);
+ stopComponent(server);
+ closeServerLocator(locator);
+ locator = null;
server = null;
clientSession = null;
- locator.close();
super.tearDown();
}
}
Modified:
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
===================================================================
---
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-12-02
21:21:00 UTC (rev 11818)
+++
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-12-02
21:23:10 UTC (rev 11819)
@@ -13,6 +13,7 @@
package org.hornetq.tests.integration.cluster.util;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
@@ -84,9 +85,10 @@
public void crash(boolean waitFailure, ClientSession... sessions) throws Exception
{
- CountDownSessionFailureListener listener = new
CountDownSessionFailureListener(sessions.length);
+ CountDownLatch latch = new CountDownLatch(sessions.length);
for (ClientSession session : sessions)
{
+ CountDownSessionFailureListener listener = new
CountDownSessionFailureListener(latch);
session.addFailureListener(listener);
}
@@ -99,8 +101,8 @@
if (waitFailure)
{
// Wait to be informed of failure
- boolean ok = listener.getLatch().await(10000, TimeUnit.MILLISECONDS);
- Assert.assertTrue("Failed to stop the server! Latch count is " +
listener.getLatch().getCount() + " out of " +
+ boolean ok = latch.await(10000, TimeUnit.MILLISECONDS);
+ Assert.assertTrue("Failed to stop the server! Latch count is " +
latch.getCount() + " out of " +
sessions.length, ok);
}
}
Modified:
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java
===================================================================
---
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-12-02
21:21:00 UTC (rev 11818)
+++
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-12-02
21:23:10 UTC (rev 11819)
@@ -57,6 +57,7 @@
private HornetQServer server;
protected ClientSession session;
private ServerLocator locator;
+ private ClientSessionFactory sf;
// Static --------------------------------------------------------
@@ -213,20 +214,22 @@
{
session.close();
server.stop();
+ server.getConfiguration().setPersistenceEnabled(true);
SimpleString address = RandomUtil.randomSimpleString();
AddressSettings addressSettings = new AddressSettings();
addressSettings.setPageSizeBytes(1024);
addressSettings.setMaxSizeBytes(10 * 1024);
- int NUMBER_MESSAGES_BEFORE_PAGING = 5;
+ final int NUMBER_MESSAGES_BEFORE_PAGING = 5;
server.getAddressSettingsRepository().addMatch(address.toString(),
addressSettings);
server.start();
-
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sf = locator.createSessionFactory();
- session = sf.createSession(false, true, false);
+ ServerLocator locator2 = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
+ ClientSessionFactory sf2 = locator2.createSessionFactory();
+ try
+ {
+ session = sf2.createSession(false, true, false);
session.start();
session.createQueue(address, address, true);
@@ -262,7 +265,13 @@
producer.send(msg);
session.commit();
- Assert.assertEquals(2, addressControl.getNumberOfPages());
+ Assert.assertEquals("# of pages is 2", 2,
addressControl.getNumberOfPages());
+ }
+ finally
+ {
+ closeSessionFactory(sf2);
+ closeServerLocator(locator2);
+ }
}
public void testGetNumberOfBytesPerPage() throws Exception
@@ -281,11 +290,19 @@
server.getAddressSettingsRepository().addMatch(address.toString(),
addressSettings);
server.start();
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sf = locator.createSessionFactory();
- session = sf.createSession(false, true, false);
- session.createQueue(address, address, true);
- Assert.assertEquals(1024, addressControl.getNumberOfBytesPerPage());
+ ServerLocator locator2 = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
+ ClientSessionFactory sf2 = locator2.createSessionFactory();
+ try
+ {
+ session = sf2.createSession(false, true, false);
+ session.createQueue(address, address, true);
+ Assert.assertEquals(1024, addressControl.getNumberOfBytesPerPage());
+ }
+ finally
+ {
+ closeServerLocator(locator2);
+ closeSessionFactory(sf2);
+ }
}
// Package protected ---------------------------------------------
@@ -307,7 +324,7 @@
locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory sf = locator.createSessionFactory();
+ sf = locator.createSessionFactory();
session = sf.createSession(false, true, false);
session.start();
}
@@ -317,12 +334,11 @@
{
if (session != null)
session.close();
-
+ closeSessionFactory(sf);
closeServerLocator(locator);
stopComponent(server);
server = null;
-
session = null;
super.tearDown();