use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.
the class AmqpInboundConnectionTest method testBrokerConnectionProperties.
@Test(timeout = 60000)
public void testBrokerConnectionProperties() throws Exception {
AmqpClient client = createAmqpClient();
client.setValidator(new AmqpValidator() {
@Override
public void inspectOpenedResource(Connection connection) {
Map<Symbol, Object> properties = connection.getRemoteProperties();
if (!properties.containsKey(PRODUCT)) {
markAsInvalid("Broker did not send a queue product name value");
return;
}
if (!properties.containsKey(VERSION)) {
markAsInvalid("Broker did not send a queue version value");
return;
}
if (!PRODUCT_NAME.equals(properties.get(PRODUCT))) {
markAsInvalid("Broker did not send a the expected product name");
return;
}
String brokerVersion = VersionLoader.getVersion().getFullVersion();
if (!brokerVersion.equals(properties.get(VERSION))) {
markAsInvalid("Broker did not send a the expected product version");
return;
}
}
});
AmqpConnection connection = addConnection(client.connect());
try {
assertNotNull(connection);
connection.getStateInspector().assertValid();
} finally {
connection.close();
}
}
use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.
the class AmqpBrokerReuqestedHearbeatsTest method testBrokerSendsHalfConfiguredIdleTimeout.
@Test(timeout = 60000)
public void testBrokerSendsHalfConfiguredIdleTimeout() throws Exception {
AmqpClient client = createAmqpClient();
assertNotNull(client);
client.setValidator(new AmqpValidator() {
@Override
public void inspectOpenedResource(Connection connection) {
assertEquals("Broker did not send half the idle timeout", TEST_IDLE_TIMEOUT / 2, connection.getTransport().getRemoteIdleTimeout());
}
});
AmqpConnection connection = addConnection(client.connect());
assertNotNull(connection);
connection.getStateInspector().assertValid();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.
the class AmqpReceiverTest method testReceiverCloseSendsRemoteClose.
@Test(timeout = 60000)
public void testReceiverCloseSendsRemoteClose() throws Exception {
AmqpClient client = createAmqpClient();
assertNotNull(client);
final AtomicBoolean closed = new AtomicBoolean();
client.setValidator(new AmqpValidator() {
@Override
public void inspectClosedResource(Session session) {
IntegrationTestLogger.LOGGER.info("Session closed: " + session.getContext());
}
@Override
public void inspectDetachedResource(Receiver receiver) {
markAsInvalid("Broker should not detach receiver linked to closed session.");
}
@Override
public void inspectClosedResource(Receiver receiver) {
IntegrationTestLogger.LOGGER.info("Receiver closed: " + receiver.getContext());
closed.set(true);
}
});
AmqpConnection connection = addConnection(client.connect());
assertNotNull(connection);
AmqpSession session = connection.createSession();
assertNotNull(session);
AmqpReceiver receiver = session.createReceiver(getQueueName());
assertNotNull(receiver);
receiver.close();
assertTrue("Did not process remote close as expected", closed.get());
connection.getStateInspector().assertValid();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.
the class AmqpReceiverTest method testCreateQueueReceiverWithJMSSelector.
@Test(timeout = 60000)
public void testCreateQueueReceiverWithJMSSelector() throws Exception {
AmqpClient client = createAmqpClient();
client.setValidator(new AmqpValidator() {
@SuppressWarnings("unchecked")
@Override
public void inspectOpenedResource(Receiver receiver) {
if (receiver.getRemoteSource() == null) {
markAsInvalid("Link opened with null source.");
}
Source source = (Source) receiver.getRemoteSource();
Map<Symbol, Object> filters = source.getFilter();
if (findFilter(filters, JMS_SELECTOR_FILTER_IDS) == null) {
markAsInvalid("Broker did not return the JMS Filter on Attach");
}
}
});
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
session.createReceiver(getQueueName(), "JMSPriority > 8");
connection.getStateInspector().assertValid();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.
the class AmqpReceiverWithFiltersTest method testSupportedFiltersAreListedAsSupported.
@Test(timeout = 60000)
public void testSupportedFiltersAreListedAsSupported() throws Exception {
AmqpClient client = createAmqpClient();
client.setValidator(new AmqpValidator() {
@SuppressWarnings("unchecked")
@Override
public void inspectOpenedResource(Receiver receiver) {
if (receiver.getRemoteSource() == null) {
markAsInvalid("Link opened with null source.");
}
Source source = (Source) receiver.getRemoteSource();
Map<Symbol, Object> filters = source.getFilter();
if (findFilter(filters, AmqpSupport.JMS_SELECTOR_FILTER_IDS) == null) {
markAsInvalid("Broker should return selector filter on attach.");
}
}
});
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
session.createReceiver(getQueueName(), "color = red");
connection.getStateInspector().assertValid();
connection.close();
}
Aggregations