mirror of https://github.com/apache/activemq.git
fix brokerSerivce instances left running if assertions fail
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1404348 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
13270e4e74
commit
0ad3cfc11e
|
@ -22,19 +22,14 @@ import static org.junit.Assume.assumeNotNull;
|
|||
import java.net.MalformedURLException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.ObjectInstance;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.remote.JMXConnector;
|
||||
import javax.management.remote.JMXConnectorFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class DuplexNetworkMBeanTest {
|
||||
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(DuplexNetworkMBeanTest.class);
|
||||
|
@ -60,6 +55,7 @@ public class DuplexNetworkMBeanTest {
|
|||
@Test
|
||||
public void testMbeanPresenceOnNetworkBrokerRestart() throws Exception {
|
||||
BrokerService broker = createBroker();
|
||||
try {
|
||||
broker.start();
|
||||
assertEquals(1, countMbeans(broker, "Connector", 30000));
|
||||
assertEquals(0, countMbeans(broker, "Connection"));
|
||||
|
@ -80,14 +76,17 @@ public class DuplexNetworkMBeanTest {
|
|||
assertEquals(0, countMbeans(networkedBroker, "Connector"));
|
||||
assertEquals(0, countMbeans(networkedBroker, "Connection"));
|
||||
assertEquals(1, countMbeans(broker, "Connector"));
|
||||
} finally {
|
||||
broker.stop();
|
||||
broker.waitUntilStopped();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMbeanPresenceOnBrokerRestart() throws Exception {
|
||||
|
||||
BrokerService networkedBroker = createNetworkedBroker();
|
||||
try {
|
||||
networkedBroker.start();
|
||||
assertEquals(1, countMbeans(networkedBroker, "Connector", 30000));
|
||||
assertEquals(0, countMbeans(networkedBroker, "Connection"));
|
||||
|
@ -95,12 +94,14 @@ public class DuplexNetworkMBeanTest {
|
|||
BrokerService broker = null;
|
||||
for (int i=0; i<numRestarts; i++) {
|
||||
broker = createBroker();
|
||||
try {
|
||||
broker.start();
|
||||
assertEquals(1, countMbeans(networkedBroker, "NetworkBridge", 5000));
|
||||
assertEquals("restart number: " + i, 1, countMbeans(broker, "Connection", 10000));
|
||||
|
||||
} finally {
|
||||
broker.stop();
|
||||
broker.waitUntilStopped();
|
||||
}
|
||||
assertEquals(0, countMbeans(broker, "stopped"));
|
||||
}
|
||||
|
||||
|
@ -108,10 +109,11 @@ public class DuplexNetworkMBeanTest {
|
|||
assertEquals(1, countMbeans(networkedBroker, "Connector"));
|
||||
assertEquals(0, countMbeans(networkedBroker, "Connection"));
|
||||
assertEquals(0, countMbeans(broker, "Connection"));
|
||||
|
||||
} finally {
|
||||
networkedBroker.stop();
|
||||
networkedBroker.waitUntilStopped();
|
||||
}
|
||||
}
|
||||
|
||||
private int countMbeans(BrokerService broker, String type) throws Exception {
|
||||
return countMbeans(broker, type, 0);
|
||||
|
|
Loading…
Reference in New Issue