mirror of https://github.com/apache/activemq.git
attempt to fix test case after changes in https://issues.apache.org/jira/browse/AMQ-4237 broke the test's MBean lookup, not quite there but close.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1429149 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b5625e31ee
commit
5a8ca0b8a8
|
@ -30,8 +30,6 @@ import org.apache.activemq.broker.jmx.ManagementContext;
|
|||
import org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgentFactory;
|
||||
import org.apache.activemq.util.SocketProxy;
|
||||
import org.apache.activemq.util.Wait;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.jmock.Expectations;
|
||||
|
@ -45,6 +43,8 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
@RunWith(JMock.class)
|
||||
|
@ -69,14 +69,21 @@ public class DiscoveryNetworkReconnectTest {
|
|||
name = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object arg0) {
|
||||
ObjectName other = (ObjectName) arg0;
|
||||
ObjectName mine = (ObjectName) name;
|
||||
LOG.info("Match: " + mine + " vs: " + other);
|
||||
return other.getKeyProperty("Type").equals(mine.getKeyProperty("Type")) &&
|
||||
other.getKeyProperty("NetworkConnectorName").equals(mine.getKeyProperty("NetworkConnectorName"));
|
||||
|
||||
if (other.getKeyProperty("service") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return other.getKeyProperty("service").equals(mine.getKeyProperty("service")) &&
|
||||
other.getKeyProperty("networkConnectorName").equals(mine.getKeyProperty("networkConnectorName"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description arg0) {
|
||||
arg0.appendText(this.getClass().getName());
|
||||
}
|
||||
|
@ -107,21 +114,24 @@ public class DiscoveryNetworkReconnectTest {
|
|||
|
||||
// expected MBeans
|
||||
allowing(managementContext).registerMBean(with(any(Object.class)), with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Broker"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC"))));
|
||||
allowing(managementContext).registerMBean(with(any(Object.class)), with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Health"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,service=Health"))));
|
||||
allowing(managementContext).registerMBean(with(any(Object.class)), with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkConnector,NetworkConnectorName=NC"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,connector=networkConnectors,networkConnectorName=NC"))));
|
||||
allowing(managementContext).registerMBean(with(any(Object.class)), with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Topic,Destination=ActiveMQ.Advisory.Connection"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,destinationType=Topic,destinationName=ActiveMQ.Advisory.Connection"))));
|
||||
allowing(managementContext).registerMBean(with(any(Object.class)), with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Topic,Destination=ActiveMQ.Advisory.NetworkBridge"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,destinationType=Topic,destinationName=ActiveMQ.Advisory.NetworkBridge"))));
|
||||
allowing(managementContext).registerMBean(with(any(Object.class)), with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=jobScheduler,jobSchedulerName=JMS"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,destinationType=Topic,destinationName=ActiveMQ.Advisory.MasterBroker"))));
|
||||
allowing(managementContext).registerMBean(with(any(Object.class)), with(equal(
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,service=jobScheduler,jobSchedulerName=JMS"))));
|
||||
|
||||
atLeast(maxReconnects - 1).of (managementContext).registerMBean(with(any(Object.class)), with(new NetworkBridgeObjectNameMatcher<ObjectName>(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkBridge,NetworkConnectorName=NC,Name=localhost/127.0.0.1_"
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,service=NetworkBridge,networkConnectorName=NC,networkBridgeName=localhost/127.0.0.1_"
|
||||
+ proxy.getUrl().getPort())))); will(new CustomAction("signal register network mbean") {
|
||||
@Override
|
||||
public Object invoke(Invocation invocation) throws Throwable {
|
||||
LOG.info("Mbean Registered: " + invocation.getParameter(0));
|
||||
mbeanRegistered.release();
|
||||
|
@ -129,8 +139,9 @@ public class DiscoveryNetworkReconnectTest {
|
|||
}
|
||||
});
|
||||
atLeast(maxReconnects - 1).of (managementContext).unregisterMBean(with(new NetworkBridgeObjectNameMatcher<ObjectName>(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkBridge,NetworkConnectorName=NC,Name=localhost/127.0.0.1_"
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,service=NetworkBridge,networkConnectorName=NC,networkBridgeName=localhost/127.0.0.1_"
|
||||
+ proxy.getUrl().getPort())))); will(new CustomAction("signal unregister network mbean") {
|
||||
@Override
|
||||
public Object invoke(Invocation invocation) throws Throwable {
|
||||
LOG.info("Mbean Unregistered: " + invocation.getParameter(0));
|
||||
mbeanUnregistered.release();
|
||||
|
@ -139,15 +150,17 @@ public class DiscoveryNetworkReconnectTest {
|
|||
});
|
||||
|
||||
allowing(managementContext).unregisterMBean(with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Broker"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC"))));
|
||||
allowing(managementContext).unregisterMBean(with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Health"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,service=Health"))));
|
||||
allowing(managementContext).unregisterMBean(with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkConnector,NetworkConnectorName=NC"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,connector=networkConnectors,networkConnectorName=NC"))));
|
||||
allowing(managementContext).unregisterMBean(with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Topic,Destination=ActiveMQ.Advisory.Connection"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,destinationType=Topic,destinationName=ActiveMQ.Advisory.Connection"))));
|
||||
allowing(managementContext).unregisterMBean(with(equal(
|
||||
new ObjectName("Test:BrokerName=BrokerNC,Type=Topic,Destination=ActiveMQ.Advisory.NetworkBridge"))));
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,destinationType=Topic,destinationName=ActiveMQ.Advisory.NetworkBridge"))));
|
||||
allowing(managementContext).unregisterMBean(with(equal(
|
||||
new ObjectName("Test:type=Broker,brokerName=BrokerNC,destinationType=Topic,destinationName=ActiveMQ.Advisory.MasterBroker"))));
|
||||
}});
|
||||
|
||||
brokerB = new BrokerService();
|
||||
|
@ -184,8 +197,6 @@ public class DiscoveryNetworkReconnectTest {
|
|||
doReconnect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSimpleReconnect() throws Exception {
|
||||
brokerB.addNetworkConnector("simple://(" + proxy.getUrl()
|
||||
|
@ -200,6 +211,7 @@ public class DiscoveryNetworkReconnectTest {
|
|||
for (int i=0; i<maxReconnects; i++) {
|
||||
// Wait for connection
|
||||
assertTrue("we got a network connection in a timely manner", Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
return proxy.connections.size() >= 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue