Allow for broker stats to be viewed in tests by enabling JMX but
disabling the creation of a management connector.
This commit is contained in:
Timothy Bish 2017-03-15 09:59:57 -04:00
parent 36689beff7
commit 44a318bd3f
1 changed files with 6 additions and 4 deletions

View File

@ -16,10 +16,13 @@
*/ */
package org.apache.activemq.junit; package org.apache.activemq.junit;
import static org.apache.activemq.command.ActiveMQDestination.QUEUE_TYPE;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Map; import java.util.Map;
import javax.jms.BytesMessage; import javax.jms.BytesMessage;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.JMSException; import javax.jms.JMSException;
@ -45,8 +48,6 @@ import org.junit.rules.ExternalResource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static org.apache.activemq.command.ActiveMQDestination.QUEUE_TYPE;
/** /**
* A JUnit Rule that embeds an ActiveMQ broker into a test. * A JUnit Rule that embeds an ActiveMQ broker into a test.
*/ */
@ -61,12 +62,13 @@ public class EmbeddedActiveMQBroker extends ExternalResource {
* <p> * <p>
* The defaults are: * The defaults are:
* - the broker name is 'embedded-broker' * - the broker name is 'embedded-broker'
* - JMX is disabled * - JMX is enable but no management connector is created.
* - Persistence is disabled * - Persistence is disabled
*/ */
public EmbeddedActiveMQBroker() { public EmbeddedActiveMQBroker() {
brokerService = new BrokerService(); brokerService = new BrokerService();
brokerService.setUseJmx(false); brokerService.setUseJmx(true);
brokerService.getManagementContext().setCreateConnector(false);
brokerService.setUseShutdownHook(false); brokerService.setUseShutdownHook(false);
brokerService.setPersistent(false); brokerService.setPersistent(false);
brokerService.setBrokerName("embedded-broker"); brokerService.setBrokerName("embedded-broker");