resolve npe if no mbeans found

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@742443 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2009-02-09 12:27:07 +00:00
parent 657e6fa1dd
commit 4dda0d8353
1 changed files with 7 additions and 3 deletions

View File

@ -57,7 +57,7 @@ public class DuplexNetworkMBeanTest extends TestCase {
public void testMbeanPresenceOnNetworkBrokerRestart() throws Exception {
BrokerService broker = createBroker();
broker.start();
assertEquals(1, countMbeans(broker, "Connector", 2000));
assertEquals(1, countMbeans(broker, "Connector", 5000));
assertEquals(0, countMbeans(broker, "Connection"));
BrokerService networkedBroker = null;
for (int i=0; i<numRestarts; i++) {
@ -115,17 +115,21 @@ public class DuplexNetworkMBeanTest extends TestCase {
final ObjectName beanName = new ObjectName("org.apache.activemq:BrokerName="
+ broker.getBrokerName() + ",Type=" + type +",*");
Set<?> mbeans = null;
int count = 0;
do {
if (timeout > 0) {
Thread.sleep(100);
}
MBeanServerConnection mbsc = getMBeanServerConnection();
if (mbsc != null) {
LOG.info("Query name: " + beanName);
mbeans = mbsc.queryMBeans(beanName, null);
if (mbeans != null) {
count = mbeans.size();
}
}
} while ((mbeans == null || mbeans.isEmpty()) && expiryTime > System.currentTimeMillis());
return mbeans.size();
return count;
}
private MBeanServerConnection getMBeanServerConnection() throws MalformedURLException {