git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1451608 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-03-01 14:55:20 +00:00
parent d98c3e0249
commit d8aca93328
1 changed files with 23 additions and 16 deletions

View File

@ -23,7 +23,9 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import junit.framework.Test;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
@ -32,8 +34,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RedeliveryRestartTest extends BrokerRestartTestSupport {
private static final transient Logger LOG = LoggerFactory.getLogger(RedeliveryRestartTest.class);
@Override
protected void setUp() throws Exception {
setAutoFail(true);
setMaxTestTime(2 * 60 * 1000);
super.setUp();
}
@Override
protected void configureBroker(BrokerService broker) throws Exception {
super.configureBroker(broker);
@ -45,8 +56,8 @@ public class RedeliveryRestartTest extends BrokerRestartTestSupport {
public void testValidateRedeliveryFlagAfterRestart() throws Exception {
ConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString() + ")?jms.transactedIndividualAck=true");
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString()
+ ")?jms.transactedIndividualAck=true");
ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
connection.start();
@ -70,7 +81,8 @@ public class RedeliveryRestartTest extends BrokerRestartTestSupport {
restartBroker();
// make failover aware of the restarted auto assigned port
((FailoverTransport) connection.getTransport().narrow(FailoverTransport.class)).add(true, broker.getTransportConnectors().get(0).getPublishableConnectString());
connection.getTransport().narrow(FailoverTransport.class).add(true, broker.getTransportConnectors().get(0)
.getPublishableConnectString());
consumer = session.createConsumer(destination);
for (int i = 0; i < 5; i++) {
@ -96,8 +108,8 @@ public class RedeliveryRestartTest extends BrokerRestartTestSupport {
}
public void testValidateRedeliveryFlagAfterRecovery() throws Exception {
ConnectionFactory connectionFactory =
new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString() + "?jms.transactedIndividualAck=true");
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString()
+ "?jms.transactedIndividualAck=true");
ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
connection.start();
@ -122,12 +134,11 @@ public class RedeliveryRestartTest extends BrokerRestartTestSupport {
broker = createRestartedBroker();
broker.start();
connectionFactory =
new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString() + "?jms.transactedIndividualAck=true");
connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString()
+ "?jms.transactedIndividualAck=true");
connection = (ActiveMQConnection) connectionFactory.createConnection();
connection.start();
session = connection.createSession(true, Session.SESSION_TRANSACTED);
consumer = session.createConsumer(destination);
msg = (TextMessage) consumer.receive(10000);
@ -139,9 +150,7 @@ public class RedeliveryRestartTest extends BrokerRestartTestSupport {
connection.close();
}
private void populateDestination(final int nbMessages,
final String destinationName, javax.jms.Connection connection)
throws JMSException {
private void populateDestination(final int nbMessages, final String destinationName, javax.jms.Connection connection) throws JMSException {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(destinationName);
MessageProducer producer = session.createProducer(destination);
@ -152,7 +161,6 @@ public class RedeliveryRestartTest extends BrokerRestartTestSupport {
session.close();
}
public static Test suite() {
return suite(RedeliveryRestartTest.class);
}
@ -160,5 +168,4 @@ public class RedeliveryRestartTest extends BrokerRestartTestSupport {
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}