Author: clebert.suconic(a)jboss.com
Date: 2011-07-19 15:59:01 -0400 (Tue, 19 Jul 2011)
New Revision: 11005
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java
Log:
Fixing test
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java 2011-07-19
11:54:31 UTC (rev 11004)
+++
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeReconnectTest.java 2011-07-19
19:59:01 UTC (rev 11005)
@@ -57,6 +57,7 @@
{
private static final Logger log = Logger.getLogger(BridgeReconnectTest.class);
+ private final int NUM_MESSAGES = 100;
protected boolean isNetty()
{
return false;
@@ -129,7 +130,7 @@
HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
retryIntervalMultiplier,
reconnectAttempts,
- false,
+ true,
confirmationWindowSize,
staticConnectors,
false,
@@ -181,7 +182,7 @@
session2.start();
- final int numMessages = 10;
+ final int numMessages = NUM_MESSAGES;
SimpleString propKey = new SimpleString("propkey");
@@ -273,7 +274,7 @@
HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
retryIntervalMultiplier,
reconnectAttempts,
- false,
+ true,
confirmationWindowSize,
staticConnectors,
false,
@@ -318,7 +319,7 @@
session2.start();
- final int numMessages = 10;
+ final int numMessages = NUM_MESSAGES;
SimpleString propKey = new SimpleString("propkey");
@@ -401,7 +402,7 @@
HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
retryIntervalMultiplier,
reconnectAttempts,
- false,
+ true,
confirmationWindowSize,
staticConnectors,
false,
@@ -451,7 +452,7 @@
forwardingConnection = getForwardingConnection(bridge);
forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));
- final int numMessages = 10;
+ final int numMessages = NUM_MESSAGES;
SimpleString propKey = new SimpleString("propkey");
@@ -544,7 +545,7 @@
HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
retryIntervalMultiplier,
reconnectAttempts,
- false,
+ true,
confirmationWindowSize,
staticConnectors,
false,
@@ -596,7 +597,7 @@
session1.start();
- final int numMessages = 10;
+ final int numMessages = NUM_MESSAGES;
SimpleString propKey = new SimpleString("propkey");
@@ -637,7 +638,7 @@
Assert.assertEquals(0, server0.getRemotingService().getConnections().size());
Assert.assertEquals(0, server1.getRemotingService().getConnections().size());
}
-
+
public void testFailoverThenFailAgainAndReconnect() throws Exception
{
Map<String, Object> server0Params = new HashMap<String, Object>();
@@ -680,7 +681,7 @@
HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
retryIntervalMultiplier,
reconnectAttempts,
- false,
+ true,
confirmationWindowSize,
staticConnectors,
false,
@@ -725,9 +726,9 @@
InVMConnector.failOnCreateConnection = true;
InVMConnector.numberOfFailures = reconnectAttempts - 1;
forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));
+
+ final int numMessages = NUM_MESSAGES;
- final int numMessages = 10;
-
SimpleString propKey = new SimpleString("propkey");
for (int i = 0; i < numMessages; i++)
@@ -737,19 +738,32 @@
prod0.send(message);
}
+ int outOfOrder = -1;
+ int supposed = -1;
for (int i = 0; i < numMessages; i++)
{
ClientMessage r1 = cons1.receive(1500);
Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ if (outOfOrder == -1 && i != r1.getIntProperty(propKey).intValue())
+ {
+ outOfOrder = r1.getIntProperty(propKey).intValue();
+ supposed = i;
+ }
}
+ if (outOfOrder != -1)
+ {
+ fail("Message " + outOfOrder + " was received out of order, it
was supposed to be " + supposed);
+ }
+ log.info("=========== second failure, sending message");
+
+
// Fail again - should reconnect
forwardingConnection = ((BridgeImpl)bridge).getForwardingConnection();
InVMConnector.failOnCreateConnection = true;
InVMConnector.numberOfFailures = reconnectAttempts - 1;
- forwardingConnection.fail(new
HornetQException(HornetQException.NOT_CONNECTED));
+ forwardingConnection.fail(new HornetQException(5));
for (int i = 0; i < numMessages; i++)
{
@@ -762,12 +776,22 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage r1 = cons1.receive(1500);
- Assert.assertNotNull(r1);
- Assert.assertEquals(i, r1.getObjectProperty(propKey));
+ Assert.assertNotNull("Didn't receive message", r1);
+ if (outOfOrder == -1 && i != r1.getIntProperty(propKey).intValue())
+ {
+ outOfOrder = r1.getIntProperty(propKey).intValue();
+ supposed = i;
+ }
}
+
session0.close();
session1.close();
+
+ if (outOfOrder != -1)
+ {
+ fail("Message " + outOfOrder + " was received out of order, it
was supposed to be " + supposed);
+ }
}
finally
{