git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1431123 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-01-09 22:36:17 +00:00
parent 3dd24195e6
commit ac23437828
1 changed files with 130 additions and 131 deletions

View File

@ -39,7 +39,6 @@ import javax.management.ObjectName;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.BrokerTestSupport; import org.apache.activemq.broker.BrokerTestSupport;
import org.apache.activemq.broker.StubConnection; import org.apache.activemq.broker.StubConnection;
@ -72,9 +71,6 @@ import org.slf4j.LoggerFactory;
* and {@link BrokerTestSupport} because more control was needed over how brokers * and {@link BrokerTestSupport} because more control was needed over how brokers
* and connectors are created. Also, this test asserts message counts via JMX on * and connectors are created. Also, this test asserts message counts via JMX on
* each broker. * each broker.
*
* @author bsnyder
*
*/ */
public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSupport*/ { public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSupport*/ {
@ -85,7 +81,7 @@ public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSu
private DemandForwardingBridge bridge; private DemandForwardingBridge bridge;
protected Map<String, BrokerService> brokers = new HashMap<String, BrokerService>(); protected Map<String, BrokerService> brokers = new HashMap<String, BrokerService>();
protected ArrayList connections = new ArrayList(); protected ArrayList<StubConnection> connections = new ArrayList<StubConnection>();
protected TransportConnector connector; protected TransportConnector connector;
protected TransportConnector remoteConnector; protected TransportConnector remoteConnector;
@ -98,6 +94,7 @@ public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSu
protected String amqDomain = "org.apache.activemq"; protected String amqDomain = "org.apache.activemq";
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
// For those who want visual confirmation: // For those who want visual confirmation:
@ -142,6 +139,7 @@ public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSu
if (!broker.getNetworkConnectors().isEmpty()) { if (!broker.getNetworkConnectors().isEmpty()) {
// Max wait here is 30 secs // Max wait here is 30 secs
Wait.waitFor(new Wait.Condition() { Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception { public boolean isSatisified() throws Exception {
return !broker.getNetworkConnectors().get(0).activeBridges().isEmpty(); return !broker.getNetworkConnectors().get(0).activeBridges().isEmpty();
}}); }});
@ -149,6 +147,7 @@ public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSu
} }
} }
@Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
bridge.stop(); bridge.stop();
localBroker.stop(); localBroker.stop();
@ -385,7 +384,7 @@ public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSu
return connection; return connection;
} }
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "unused" })
private Object[] browseQueueWithJms(BrokerService broker) throws Exception { private Object[] browseQueueWithJms(BrokerService broker) throws Exception {
Object[] messages = null; Object[] messages = null;
Connection connection = null; Connection connection = null;
@ -420,15 +419,16 @@ public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSu
private Object[] browseQueueWithJmx(BrokerService broker) throws Exception { private Object[] browseQueueWithJmx(BrokerService broker) throws Exception {
Hashtable<String, String> params = new Hashtable<String, String>(); Hashtable<String, String> params = new Hashtable<String, String>();
params.put("BrokerName", broker.getBrokerName()); params.put("brokerName", broker.getBrokerName());
params.put("Type", "Queue"); params.put("type", "Broker");
params.put("Destination", queueName); params.put("destinationType", "Queue");
params.put("destinationName", queueName);
ObjectName queueObjectName = ObjectName.getInstance(amqDomain, params); ObjectName queueObjectName = ObjectName.getInstance(amqDomain, params);
ManagementContext mgmtCtx = broker.getManagementContext(); ManagementContext mgmtCtx = broker.getManagementContext();
QueueViewMBean queueView = (QueueViewMBean)mgmtCtx.newProxyInstance(queueObjectName, QueueViewMBean.class, true); QueueViewMBean queueView = (QueueViewMBean)mgmtCtx.newProxyInstance(queueObjectName, QueueViewMBean.class, true);
Object[] messages = (Object[]) queueView.browse(); Object[] messages = queueView.browse();
LOG.info("+Browsed with JMX: " + messages.length); LOG.info("+Browsed with JMX: " + messages.length);
@ -530,5 +530,4 @@ public class BrokerNetworkWithStuckMessagesTest extends TestCase /*NetworkTestSu
} }
} }
} }
} }