use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class Session_1_0Test method testReceiveAttachTopicNonDurableNoContainerWithInvalidSelector.
public void testReceiveAttachTopicNonDurableNoContainerWithInvalidSelector() throws Exception {
final String linkName = "testLink";
final String address = "amq.direct/" + TOPIC_NAME;
Attach attach = createTopicAttach(false, linkName, address, true);
setSelector(attach, "invalid selector");
_session.receiveAttach(attach);
assertAttachFailed(_connection, _session, attach);
final Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after attach", 0, queues.size());
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class Session_1_0Test method testNullSourceLookup.
public void testNullSourceLookup() throws Exception {
final String linkName = "testLink";
final String address = "amq.direct/" + TOPIC_NAME;
Attach attach = createTopicAttach(true, linkName, address, false);
_session.receiveAttach(attach);
assertAttachSent(_connection, _session, attach);
assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
sendDetach(_session, attach.getHandle(), false);
Attach nullSourceAttach = createTopicAttach(true, linkName, address, false);
nullSourceAttach.setSource(null);
_session.receiveAttach(nullSourceAttach);
ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
verify(_connection, times(3)).sendFrame(eq(_session.getChannelId()), frameCapture.capture());
Attach sentAttach = (Attach) frameCapture.getAllValues().get(2);
assertEquals("Unexpected name", nullSourceAttach.getName(), sentAttach.getName());
assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
assertNotNull("Unexpected source", sentAttach.getSource());
Source source = (Source) sentAttach.getSource();
assertEquals("Unexpected address", address, source.getAddress());
assertTrue("Unexpected source capabilities", Arrays.asList(source.getCapabilities()).contains(Symbol.valueOf("topic")));
Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after unsubscribe", 1, queues.size());
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class Session_1_0Test method testSeparateSubscriptionNameSpaces.
public void testSeparateSubscriptionNameSpaces() throws Exception {
AMQPConnection_1_0 secondConnection = createAmqpConnection_1_0();
Session_1_0 secondSession = createSession_1_0(secondConnection, 0);
final String linkName = "testLink";
final String address = "amq.direct/" + TOPIC_NAME;
Attach durableSharedWithContainerId = createSharedTopicAttach(true, linkName + "|1", address, false);
_session.receiveAttach(durableSharedWithContainerId);
assertAttachSent(_connection, _session, durableSharedWithContainerId, 0);
Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after durable non shared with containerId", 1, queues.size());
Attach durableNonSharedWithContainerId = createTopicAttach(true, linkName, address, false);
_session.receiveAttach(durableNonSharedWithContainerId);
assertAttachFailed(_connection, _session, durableNonSharedWithContainerId, 1);
queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after durable non shared with containerId", 1, queues.size());
Attach nonDurableSharedWithContainerId = createSharedTopicAttach(false, linkName + "|3", address, false);
_session.receiveAttach(nonDurableSharedWithContainerId);
assertAttachSent(_connection, _session, nonDurableSharedWithContainerId, 3);
queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after durable non shared with containerId", 2, queues.size());
Attach durableSharedWithoutContainerId = createSharedTopicAttach(true, linkName + "|4", address, true);
secondSession.receiveAttach(durableSharedWithoutContainerId);
assertAttachSent(secondConnection, secondSession, durableSharedWithoutContainerId, 0);
queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after durable non shared with containerId", 3, queues.size());
Attach nonDurableSharedWithoutContainerId = createSharedTopicAttach(false, linkName + "|5", address, true);
secondSession.receiveAttach(nonDurableSharedWithoutContainerId);
assertAttachSent(secondConnection, secondSession, nonDurableSharedWithoutContainerId, 1);
queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after durable non shared with containerId", 4, queues.size());
Attach nonDurableNonSharedWithoutContainerId = createTopicAttach(false, linkName + "|6", address, true);
secondSession.receiveAttach(nonDurableNonSharedWithoutContainerId);
assertAttachSent(secondConnection, secondSession, nonDurableNonSharedWithoutContainerId, 2);
queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after durable non shared with containerId", 5, queues.size());
Attach nonDurableNonSharedWithContainerId = createTopicAttach(false, linkName + "|6", address, false);
_session.receiveAttach(nonDurableNonSharedWithContainerId);
assertAttachSent(_connection, _session, nonDurableNonSharedWithContainerId, 4);
queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after durable non shared with containerId", 6, queues.size());
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10 method setExchangeAndRoutingKeyOnDeliveryProperties.
private void setExchangeAndRoutingKeyOnDeliveryProperties(final DeliveryProperties deliveryProps, final MessageMetaData_1_0.MessageHeader_1_0 origHeader, final NamedAddressSpace addressSpace) {
final String to = origHeader.getTo();
final String subject = origHeader.getSubject() == null ? "" : origHeader.getSubject();
final String exchangeName;
final String routingKey;
if (to != null && !"".equals(to)) {
DestinationAddress destinationAddress = new DestinationAddress(addressSpace, to);
MessageDestination messageDestination = destinationAddress.getMessageDestination();
if (messageDestination instanceof Queue) {
exchangeName = "";
routingKey = messageDestination.getName();
} else if (messageDestination instanceof Exchange) {
exchangeName = messageDestination.getName();
routingKey = "".equals(destinationAddress.getRoutingKey()) ? subject : destinationAddress.getRoutingKey();
} else {
exchangeName = "";
routingKey = to;
}
} else {
exchangeName = "";
routingKey = subject;
}
deliveryProps.setRoutingKey(ensureStr8("to' or 'subject", routingKey));
deliveryProps.setExchange(ensureStr8("to", exchangeName));
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenQueueIsSpecified.
public void testToConversionWhenQueueIsSpecified() {
final String testQueue = "testQueue";
Properties properties = new Properties();
properties.setTo(testQueue);
Message_1_0 message = createTestMessage(properties);
final Queue queue = mock(Queue.class);
when(queue.getName()).thenReturn(testQueue);
when(_namedAddressSpace.getAttainedMessageDestination(testQueue)).thenReturn(queue);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
assertEquals("Unexpected routing key", testQueue, messagePublishInfo.getRoutingKey().toString());
}
Aggregations