Ensure that the broker send a container ID using its assigned Broker
name value.
This commit is contained in:
Timothy Bish 2016-06-01 18:38:41 -04:00
parent 8448cf1cb8
commit 76b70545f2
2 changed files with 30 additions and 0 deletions

View File

@ -492,6 +492,7 @@ public class AmqpConnection implements AmqpProtocolConverter {
protonConnection.setOfferedCapabilities(getConnectionCapabilitiesOffered()); protonConnection.setOfferedCapabilities(getConnectionCapabilitiesOffered());
protonConnection.setProperties(getConnetionProperties()); protonConnection.setProperties(getConnetionProperties());
protonConnection.setContainer(brokerService.getBrokerName());
protonConnection.open(); protonConnection.open();
configureInactivityMonitor(); configureInactivityMonitor();

View File

@ -113,6 +113,35 @@ public class AmqpConnectionsTest extends AmqpClientTestSupport {
assertEquals(0, getProxyToBroker().getCurrentConnectionsCount()); assertEquals(0, getProxyToBroker().getCurrentConnectionsCount());
} }
@Test(timeout = 60000)
public void testConnectionCarriesContainerId() throws Exception {
AmqpClient client = createAmqpClient();
assertNotNull(client);
client.setValidator(new AmqpValidator() {
@Override
public void inspectOpenedResource(Connection connection) {
String remoteContainer = connection.getRemoteContainer();
if (remoteContainer == null || !remoteContainer.equals(brokerService.getBrokerName())) {
markAsInvalid("Broker did not send a valid container ID");
} else {
LOG.info("Broker container ID = {}", remoteContainer);
}
}
});
AmqpConnection connection = client.connect();
assertNotNull(connection);
assertEquals(1, getProxyToBroker().getCurrentConnectionsCount());
connection.getStateInspector().assertValid();
connection.close();
assertEquals(0, getProxyToBroker().getCurrentConnectionsCount());
}
@Test(timeout = 60000) @Test(timeout = 60000)
public void testCanConnectWithDifferentContainerIds() throws Exception { public void testCanConnectWithDifferentContainerIds() throws Exception {
AmqpClient client = createAmqpClient(); AmqpClient client = createAmqpClient();