fix test cases after changes in https://issues.apache.org/jira/browse/AMQ-4237 broker the tests queue MBean lookup

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1427881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-01-02 17:57:22 +00:00
parent 19bf943dd7
commit 982943550f
3 changed files with 19 additions and 9 deletions

View File

@ -154,14 +154,17 @@ public class AMQ3157Test extends EmbeddedBrokerTestSupport {
String domain = "org.apache.activemq"; String domain = "org.apache.activemq";
ObjectName name; ObjectName name;
if (destination.isQueue()) { if (destination.isQueue()) {
name = new ObjectName(domain + ":BrokerName=localhost,Type=Queue,Destination=" + destination.getPhysicalName()); name = new ObjectName(domain + ":type=Broker,brokerName=localhost," +
"destinationType=Queue,destinationName=" + destination.getPhysicalName());
} else { } else {
name = new ObjectName(domain + ":BrokerName=localhost,Type=Topic,Destination=" + destination.getPhysicalName()); name = new ObjectName(domain + ":type=Broker,brokerName=localhost," +
"destinationType=Topic,destinationName=" + destination.getPhysicalName());
} }
return name; return name;
} }
@Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
if (connection != null) { if (connection != null) {
connection.close(); connection.close();

View File

@ -36,6 +36,7 @@ import javax.management.ObjectName;
import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.RedeliveryPolicy; import org.apache.activemq.RedeliveryPolicy;
import org.apache.activemq.TestSupport;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.jmx.QueueViewMBean; import org.apache.activemq.broker.jmx.QueueViewMBean;
import org.apache.activemq.broker.region.policy.AbstractDeadLetterStrategy; import org.apache.activemq.broker.region.policy.AbstractDeadLetterStrategy;
@ -43,7 +44,6 @@ import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.TestSupport;
import org.apache.activemq.util.Wait; import org.apache.activemq.util.Wait;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -117,6 +117,7 @@ public class AMQ3405Test extends TestSupport {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
assertTrue("DLQ was not filled as expected", Wait.waitFor(new Wait.Condition() { assertTrue("DLQ was not filled as expected", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception { public boolean isSatisified() throws Exception {
return dlqView.getQueueSize() == messageCount; return dlqView.getQueueSize() == messageCount;
} }
@ -137,6 +138,7 @@ public class AMQ3405Test extends TestSupport {
dlqView.moveMatchingMessagesTo("", moveTo); dlqView.moveMatchingMessagesTo("", moveTo);
assertTrue("DLQ was not emptied as expected", Wait.waitFor(new Wait.Condition() { assertTrue("DLQ was not emptied as expected", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception { public boolean isSatisified() throws Exception {
return dlqView.getQueueSize() == 0; return dlqView.getQueueSize() == 0;
} }
@ -163,6 +165,7 @@ public class AMQ3405Test extends TestSupport {
dlqConsumer = dlqSession.createConsumer(dlqDestination); dlqConsumer = dlqSession.createConsumer(dlqDestination);
} }
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
broker = createBroker(); broker = createBroker();
broker.start(); broker.start();
@ -177,6 +180,7 @@ public class AMQ3405Test extends TestSupport {
dlqSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); dlqSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} }
@Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
dlqConsumer.close(); dlqConsumer.close();
dlqSession.close(); dlqSession.close();
@ -188,6 +192,7 @@ public class AMQ3405Test extends TestSupport {
} }
}; };
@Override
protected ActiveMQConnectionFactory createConnectionFactory() protected ActiveMQConnectionFactory createConnectionFactory()
throws Exception { throws Exception {
ActiveMQConnectionFactory answer = super.createConnectionFactory(); ActiveMQConnectionFactory answer = super.createConnectionFactory();
@ -226,9 +231,9 @@ public class AMQ3405Test extends TestSupport {
} }
private QueueViewMBean getProxyToDLQ() throws MalformedObjectNameException, JMSException { private QueueViewMBean getProxyToDLQ() throws MalformedObjectNameException, JMSException {
ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq" ObjectName queueViewMBeanName = new ObjectName(
+ ":Type=Queue,Destination=ActiveMQ.DLQ" "org.apache.activemq:type=Broker,brokerName=localhost," +
+ ",BrokerName=localhost"); "destinationType=Queue,destinationName=ActiveMQ.DLQ");
QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext() QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext()
.newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true); .newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
return proxy; return proxy;
@ -256,6 +261,7 @@ public class AMQ3405Test extends TestSupport {
deliveryCount = delvery; deliveryCount = delvery;
} }
@Override
public void onMessage(Message message) { public void onMessage(Message message) {
try { try {
int expectedMessageId = rollbacks.get() / deliveryCount; int expectedMessageId = rollbacks.get() / deliveryCount;

View File

@ -16,7 +16,8 @@
*/ */
package org.apache.activemq.bugs; package org.apache.activemq.bugs;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.ConnectionFactory; import javax.jms.ConnectionFactory;
@ -121,8 +122,8 @@ public class AMQ3445Test {
private QueueViewMBean getProxyToQueueViewMBean() throws Exception { private QueueViewMBean getProxyToQueueViewMBean() throws Exception {
ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq" ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq"
+ ":Type=Queue,Destination=" + queueName + ":destinationType=Queue,destinationName=" + queueName
+ ",BrokerName=localhost"); + ",type=Broker,brokerName=localhost");
QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext() QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext()
.newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true); .newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
return proxy; return proxy;