reinstate this test case

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@960869 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2010-07-06 10:58:06 +00:00
parent 4160249750
commit cc700dd841
1 changed files with 10 additions and 2 deletions

View File

@ -32,6 +32,7 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer; import javax.jms.MessageProducer;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import javax.jms.TransactionRolledBackException;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -263,11 +264,12 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
MessageConsumer consumer = session.createConsumer(session MessageConsumer consumer = session.createConsumer(session
.createQueue(QUEUE_NAME)); .createQueue(QUEUE_NAME));
boolean restartDone = false;
for (int i = 0; i < MESSAGE_COUNT; i++) { for (int i = 0; i < MESSAGE_COUNT; i++) {
Message message = consumer.receive(500); Message message = consumer.receive(500);
assertNotNull(message); assertNotNull(message);
if (i == 222) { if (i == 222 && !restartDone) {
// Simulate broker failure & restart // Simulate broker failure & restart
bs.stop(); bs.stop();
bs = new BrokerService(); bs = new BrokerService();
@ -275,10 +277,16 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
bs.setUseJmx(true); bs.setUseJmx(true);
bs.addConnector(tcpUri); bs.addConnector(tcpUri);
bs.start(); bs.start();
restartDone = true;
} }
assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER)); assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
try {
session.commit(); session.commit();
} catch (TransactionRolledBackException expectedOnOccasion) {
log.info("got rollback: " + expectedOnOccasion);
i--;
}
} }
assertNull(consumer.receive(500)); assertNull(consumer.receive(500));