JBoss hornetq SVN: r11821 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-12-05 04:40:04 -0500 (Mon, 05 Dec 2011)
New Revision: 11821
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java
Log:
fix closing of serverlocator
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2011-12-02 21:35:46 UTC (rev 11820)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2011-12-05 09:40:04 UTC (rev 11821)
@@ -101,7 +101,7 @@
try
{
server.start();
- ServerLocator locator = createInVMNonHALocator();
+ locator = createInVMNonHALocator();
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession sendSession = cf.createSession(false, true, false);
ClientProducer cp = sendSession.createProducer(addressA);
13 years
JBoss hornetq SVN: r11820 - in branches/Branch_2_2_EAP: tests/src/org/hornetq/tests/integration/cluster/failover and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-12-02 16:35:46 -0500 (Fri, 02 Dec 2011)
New Revision: 11820
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/DelegatingSession.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/util/InVMNodeManager.java
Log:
https://issues.jboss.org/browse/JBPAPP-6543, https://issues.jboss.org/browse/HORNETQ-685 (Fix provided by Andy Taylor.. I'm just doing the commit after a review)
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-12-02 21:23:10 UTC (rev 11819)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-12-02 21:35:46 UTC (rev 11820)
@@ -921,6 +921,17 @@
*/
private void reconnectSessions(final CoreRemotingConnection oldConnection, final int reconnectAttempts)
{
+ HashSet<ClientSessionInternal> sessionsToFailover;
+ synchronized (sessions)
+ {
+ sessionsToFailover = new HashSet<ClientSessionInternal>(sessions);
+ }
+
+ for (ClientSessionInternal session : sessionsToFailover)
+ {
+ session.preHandleFailover(connection);
+ }
+
getConnectionWithRetry(reconnectAttempts);
if (connection == null)
@@ -946,12 +957,6 @@
connection.setFailureListeners(newListeners);
- HashSet<ClientSessionInternal> sessionsToFailover;
- synchronized (sessions)
- {
- sessionsToFailover = new HashSet<ClientSessionInternal>(sessions);
- }
-
for (ClientSessionInternal session : sessionsToFailover)
{
session.handleFailover(connection);
@@ -968,7 +973,7 @@
" multiplier = " +
retryIntervalMultiplier, new Exception("trace"));
}
-
+
long interval = retryInterval;
int count = 0;
@@ -1042,6 +1047,10 @@
}
else
{
+ if (log.isDebugEnabled())
+ {
+ log.debug("Reconnection successfull");
+ }
return;
}
}
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2011-12-02 21:23:10 UTC (rev 11819)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2011-12-02 21:35:46 UTC (rev 11820)
@@ -757,7 +757,10 @@
}
checkClosed();
-
+ if (log.isDebugEnabled())
+ {
+ log.debug("client ack messageID = " + messageID);
+ }
SessionAcknowledgeMessage message = new SessionAcknowledgeMessage(consumerID, messageID, blockOnAcknowledge);
if (blockOnAcknowledge)
@@ -935,6 +938,14 @@
sendAckHandler = handler;
}
+ public void preHandleFailover(CoreRemotingConnection connection)
+ {
+ // We lock the channel to prevent any packets to be added to the resend
+ // cache during the failover process
+ //we also do this before the connection fails over to give the session a chance to block for failover
+ channel.lock();
+ }
+
// Needs to be synchronized to prevent issues with occurring concurrently with close()
public void handleFailover(final CoreRemotingConnection backupConnection)
@@ -948,9 +959,6 @@
boolean resetCreditManager = false;
- // We lock the channel to prevent any packets to be added to the resend
- // cache during the failover process
- channel.lock();
try
{
channel.transferConnection(backupConnection);
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java 2011-12-02 21:23:10 UTC (rev 11819)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java 2011-12-02 21:35:46 UTC (rev 11820)
@@ -59,6 +59,8 @@
void handleReceiveContinuation(long consumerID, SessionReceiveContinuationMessage continuation) throws Exception;
+ void preHandleFailover(CoreRemotingConnection connection);
+
void handleFailover(CoreRemotingConnection backupConnection);
RemotingConnection getConnection();
@@ -92,5 +94,4 @@
void setPacketSize(int packetSize);
void resetIfNeeded() throws HornetQException;
-
}
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/DelegatingSession.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/DelegatingSession.java 2011-12-02 21:23:10 UTC (rev 11819)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/DelegatingSession.java 2011-12-02 21:35:46 UTC (rev 11820)
@@ -373,6 +373,11 @@
return session.getXAResource();
}
+ public void preHandleFailover(CoreRemotingConnection connection)
+ {
+ session.preHandleFailover(connection);
+ }
+
public void handleFailover(final CoreRemotingConnection backupConnection)
{
session.handleFailover(backupConnection);
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2011-12-02 21:23:10 UTC (rev 11819)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2011-12-02 21:35:46 UTC (rev 11820)
@@ -44,6 +44,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.transaction.impl.XidImpl;
import org.hornetq.jms.client.HornetQTextMessage;
+import org.hornetq.tests.integration.cluster.util.InVMNodeManager;
import org.hornetq.tests.integration.cluster.util.TestableServer;
import org.hornetq.tests.util.RandomUtil;
@@ -129,6 +130,246 @@
return sf.createSession(xa, autoCommitSends, autoCommitAcks);
}
+ // https://issues.jboss.org/browse/HORNETQ-685
+ public void testTimeoutOnFailover() throws Exception
+ {
+ locator.setCallTimeout(5000);
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnDurableSend(true);
+ locator.setAckBatchSize(0);
+ locator.setReconnectAttempts(-1);
+ ((InVMNodeManager)nodeManager).failoverPause = 5000l;
+
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+
+ final ClientSession session = createSession(sf, true, true);
+
+ session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
+
+ final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
+
+ final CountDownLatch latch = new CountDownLatch(10);
+
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ for (int i = 0; i < 500; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ message.putIntProperty("counter", i);
+ try
+ {
+ System.out.println("sending message: " + i);
+ producer.send(message);
+ if (i < 10)
+ {
+ latch.countDown();
+ }
+ }
+ catch (HornetQException e)
+ {
+ // this is our retry
+ try
+ {
+ producer.send(message);
+ }
+ catch (HornetQException e1)
+ {
+ e1.printStackTrace();
+ }
+ }
+ }
+ }
+ };
+ Thread t = new Thread(r);
+ t.start();
+ latch.await(10, TimeUnit.SECONDS);
+ log.info("crashing session");
+ crash(session);
+ t.join(5000);
+ ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
+ session.start();
+ for (int i = 0; i < 500; i++)
+ {
+ ClientMessage m = consumer.receive(1000);
+ assertNotNull(m);
+ System.out.println("received message " + i);
+ // assertEquals(i, m.getIntProperty("counter").intValue());
+ }
+ }
+
+ // https://issues.jboss.org/browse/HORNETQ-685
+ public void testTimeoutOnFailoverConsume() throws Exception
+ {
+ locator.setCallTimeout(5000);
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnDurableSend(true);
+ locator.setAckBatchSize(0);
+ locator.setBlockOnAcknowledge(true);
+ locator.setReconnectAttempts(-1);
+ locator.setRetryInterval(500);
+ locator.setAckBatchSize(0);
+ ((InVMNodeManager)nodeManager).failoverPause = 5000l;
+
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+
+ final ClientSession session = createSession(sf, true, true);
+
+ session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
+
+ final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
+
+ for (int i = 0; i < 500; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ message.putIntProperty("counter", i);
+ producer.send(message);
+ }
+
+ final CountDownLatch latch = new CountDownLatch(1);
+ final CountDownLatch endLatch = new CountDownLatch(1);
+
+ final ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
+ session.start();
+
+ final Map<Integer, ClientMessage> received = new HashMap<Integer, ClientMessage>();
+
+ consumer.setMessageHandler(new MessageHandler()
+ {
+
+ public void onMessage(ClientMessage message)
+ {
+ Integer counter = message.getIntProperty("counter");
+ received.put(counter, message);
+ try
+ {
+ log.info("acking message = id = " + message.getMessageID() +
+ ", counter = " +
+ message.getIntProperty("counter"));
+ message.acknowledge();
+ }
+ catch (HornetQException e)
+ {
+ e.printStackTrace();
+ return;
+ }
+ log.info("Acked counter = " + counter);
+ if (counter.equals(10))
+ {
+ latch.countDown();
+ }
+ if (received.size() == 500)
+ {
+ endLatch.countDown();
+ }
+ }
+
+ });
+ latch.await(10, TimeUnit.SECONDS);
+ log.info("crashing session");
+ crash(session);
+ endLatch.await(60, TimeUnit.SECONDS);
+ assertTrue("received only " + received.size(), received.size() == 500);
+
+ session.close();
+ }
+
+ // https://issues.jboss.org/browse/HORNETQ-685
+ public void testTimeoutOnFailoverTransactionCommit() throws Exception
+ {
+ locator.setCallTimeout(2000);
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnDurableSend(true);
+ locator.setAckBatchSize(0);
+ locator.setReconnectAttempts(-1);
+ ((InVMNodeManager)nodeManager).failoverPause = 5000l;
+
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+
+ final ClientSession session = createSession(sf, true, false, false);
+
+ session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
+
+ final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
+
+ Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
+
+ session.start(xid, XAResource.TMNOFLAGS);
+
+ for (int i = 0; i < 500; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ message.putIntProperty("counter", i);
+
+ System.out.println("sending message: " + i);
+ producer.send(message);
+
+ }
+ session.end(xid, XAResource.TMSUCCESS);
+ session.prepare(xid);
+ System.out.println("crashing session");
+ crash(false, session);
+
+ session.commit(xid, false);
+
+ ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
+ session.start();
+ for (int i = 0; i < 500; i++)
+ {
+ ClientMessage m = consumer.receive(1000);
+ assertNotNull(m);
+ System.out.println("received message " + i);
+ assertEquals(i, m.getIntProperty("counter").intValue());
+ }
+ }
+
+ // https://issues.jboss.org/browse/HORNETQ-685
+ public void testTimeoutOnFailoverTransactionRollback() throws Exception
+ {
+ locator.setCallTimeout(2000);
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnDurableSend(true);
+ locator.setAckBatchSize(0);
+ locator.setReconnectAttempts(-1);
+ ((InVMNodeManager)nodeManager).failoverPause = 5000l;
+
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+
+ final ClientSession session = createSession(sf, true, false, false);
+
+ session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
+
+ final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
+
+ Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
+
+ session.start(xid, XAResource.TMNOFLAGS);
+
+ for (int i = 0; i < 500; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ message.putIntProperty("counter", i);
+
+ System.out.println("sending message: " + i);
+ producer.send(message);
+ }
+
+ session.end(xid, XAResource.TMSUCCESS);
+ session.prepare(xid);
+ System.out.println("crashing session");
+ crash(false, session);
+
+ session.rollback(xid);
+
+ ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
+ session.start();
+
+ ClientMessage m = consumer.receive(1000);
+ assertNull(m);
+
+ }
+
// https://jira.jboss.org/browse/HORNETQ-522
public void testNonTransactedWithZeroConsumerWindowSize() throws Exception
{
@@ -1334,7 +1575,7 @@
session2.end(xid, XAResource.TMSUCCESS);
- // session2.prepare(xid);
+ // session2.prepare(xid);
crash(session2);
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/util/InVMNodeManager.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/util/InVMNodeManager.java 2011-12-02 21:23:10 UTC (rev 11819)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/util/InVMNodeManager.java 2011-12-02 21:35:46 UTC (rev 11820)
@@ -37,6 +37,8 @@
public State state = NOT_STARTED;
+ public long failoverPause = 0l;
+
public InVMNodeManager()
{
liveLock = new Semaphore(1);
@@ -73,6 +75,10 @@
}
}
while (true);
+ if(failoverPause > 0l)
+ {
+ Thread.sleep(failoverPause);
+ }
}
@Override
13 years
JBoss hornetq SVN: r11819 - in branches/HORNETQ-316: hornetq-core/src/test/java/org/hornetq/tests/util and 3 other directories.
by do-not-reply@jboss.org
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();
13 years
JBoss hornetq SVN: r11818 - branches/HORNETQ-316.
by do-not-reply@jboss.org
Author: igarashitm
Date: 2011-12-02 16:21:00 -0500 (Fri, 02 Dec 2011)
New Revision: 11818
Modified:
branches/HORNETQ-316/
Log:
svn propdel mergeinfo
Property changes on: branches/HORNETQ-316
___________________________________________________________________
Deleted: svn:mergeinfo
- /branches/HORNETQ-720_Replication:10878-11528
/branches/STOMP11:11225-11517
/trunk:11696-11816
13 years
JBoss hornetq SVN: r11817 - in branches/HORNETQ-316: hornetq-core/src/main/java/org/hornetq/core/client/impl and 1 other directory.
by do-not-reply@jboss.org
Author: igarashitm
Date: 2011-12-02 16:07:27 -0500 (Fri, 02 Dec 2011)
New Revision: 11817
Modified:
branches/HORNETQ-316/
branches/HORNETQ-316/hornetq-core/src/main/java/org/hornetq/core/client/impl/StaticServerLocatorImpl.java
Log:
make serializable
Property changes on: branches/HORNETQ-316
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/HORNETQ-720_Replication:10878-11528
/branches/STOMP11:11225-11517
/trunk:11696-11800
+ /branches/HORNETQ-720_Replication:10878-11528
/branches/STOMP11:11225-11517
/trunk:11696-11816
Modified: branches/HORNETQ-316/hornetq-core/src/main/java/org/hornetq/core/client/impl/StaticServerLocatorImpl.java
===================================================================
--- branches/HORNETQ-316/hornetq-core/src/main/java/org/hornetq/core/client/impl/StaticServerLocatorImpl.java 2011-12-02 16:01:11 UTC (rev 11816)
+++ branches/HORNETQ-316/hornetq-core/src/main/java/org/hornetq/core/client/impl/StaticServerLocatorImpl.java 2011-12-02 21:07:27 UTC (rev 11817)
@@ -65,34 +65,7 @@
setStaticTransportConfigurations(initialConnectors.toArray(new TransportConfiguration[0]));
}
- setDiscoveryGroup(new DiscoveryGroup()
- {
- @Override public void setNotificationService(NotificationService notificationService) {}
- @Override public void start() throws Exception {}
- @Override public void stop() throws Exception {}
- @Override public void registerListener(DiscoveryListener listener) {}
- @Override public void unregisterListener(DiscoveryListener listener) {}
- @Override
- public String getName()
- {
- return "StaticDiscoveryGroup";
- }
- @Override
- public List<DiscoveryEntry> getDiscoveryEntries()
- {
- return null;
- }
- @Override
- public boolean isStarted()
- {
- return true;
- }
- @Override
- public boolean waitForBroadcast(long timeout)
- {
- return true;
- }
- });
+ setDiscoveryGroup(new StaticDiscovceryGroup());
e.fillInStackTrace();
}
@@ -148,6 +121,45 @@
staticConnector.disconnect();
}
+ private final class StaticDiscovceryGroup implements DiscoveryGroup, Serializable
+ {
+ private static final long serialVersionUID = -2886661316861662880L;
+
+ @Override public void setNotificationService(NotificationService notificationService) {}
+
+ @Override public void start() throws Exception {}
+
+ @Override public void stop() throws Exception {}
+
+ @Override public void registerListener(DiscoveryListener listener) {}
+
+ @Override public void unregisterListener(DiscoveryListener listener) {}
+
+ @Override
+ public String getName()
+ {
+ return "StaticDiscoveryGroup";
+ }
+
+ @Override
+ public List<DiscoveryEntry> getDiscoveryEntries()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isStarted()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean waitForBroadcast(long timeout)
+ {
+ return true;
+ }
+ }
+
private final class StaticConnector implements Serializable
{
private static final long serialVersionUID = 6772279632415242634l;
@@ -317,8 +329,10 @@
super.finalize();
}
- private class Connector
+ private class Connector implements Serializable
{
+ private static final long serialVersionUID = -8050491153483326679L;
+
private final TransportConfiguration initialConnector;
private volatile ClientSessionFactoryInternal factory;
13 years
JBoss hornetq SVN: r11816 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-02 11:01:11 -0500 (Fri, 02 Dec 2011)
New Revision: 11816
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java
Log:
FIX test: server must have persistency enabled for test to make sense (and work).
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-12-02 15:45:51 UTC (rev 11815)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/AddressControlTest.java 2011-12-02 16:01:11 UTC (rev 11816)
@@ -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();
13 years
JBoss hornetq SVN: r11815 - in trunk: tests/integration-tests/src/test/java/org/hornetq/tests/integration/client and 1 other directory.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-02 10:45:51 -0500 (Fri, 02 Dec 2011)
New Revision: 11815
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
Log:
Close session factory on 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-02 15:45:15 UTC (rev 11814)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-02 15:45:51 UTC (rev 11815)
@@ -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: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-02 15:45:15 UTC (rev 11814)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-02 15:45:51 UTC (rev 11815)
@@ -56,6 +56,8 @@
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.ServerLocator;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.client.impl.ServerLocatorImpl;
@@ -81,6 +83,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;
@@ -1423,6 +1426,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: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-12-02 15:45:15 UTC (rev 11814)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-12-02 15:45:51 UTC (rev 11815)
@@ -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();
}
}
13 years
JBoss hornetq SVN: r11814 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-12-02 10:45:15 -0500 (Fri, 02 Dec 2011)
New Revision: 11814
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java
Log:
always add backup in topology
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java 2011-12-02 14:58:14 UTC (rev 11813)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java 2011-12-02 15:45:15 UTC (rev 11814)
@@ -225,6 +225,11 @@
}
else
{
+ /*always add the backup, better to try to reconnect to something thats not there then to not know about it at all*/
+ if(currentMember.getB() == null && memberInput.getB() != null)
+ {
+ currentMember.setB(memberInput.getB());
+ }
return false;
}
}
13 years
JBoss hornetq SVN: r11813 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/management.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-12-02 09:58:14 -0500 (Fri, 02 Dec 2011)
New Revision: 11813
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlUsingCoreTest.java
Log:
fixed test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlUsingCoreTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlUsingCoreTest.java 2011-12-02 13:16:40 UTC (rev 11812)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlUsingCoreTest.java 2011-12-02 14:58:14 UTC (rev 11813)
@@ -101,6 +101,11 @@
return (String)proxy.retrieveAttributeValue("staticConnectorNamePairsAsJSON");
}
+ public String getTopology()
+ {
+ return (String)proxy.retrieveAttributeValue("topology");
+ }
+
public Map<String, String> getNodes() throws Exception
{
return (Map<String, String>)proxy.retrieveAttributeValue("nodes");
@@ -141,12 +146,6 @@
proxy.invokeOperation("stop");
}
- public String getTopology()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
};
}
13 years
JBoss hornetq SVN: r11812 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-02 08:16:40 -0500 (Fri, 02 Dec 2011)
New Revision: 11812
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
Log:
Need different instances of the SessionFailureListener, as they end up in a Set
of the same SessionFactory.
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-12-02 13:16:26 UTC (rev 11811)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-12-02 13:16:40 UTC (rev 11812)
@@ -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);
}
}
13 years