use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source in project qpid-broker-j by apache.
the class Session_1_0Test method assertAttachActions.
private void assertAttachActions(final Queue<?> queue, final Attach receivedAttach) {
Collection<QueueConsumer<?, ?>> consumers = queue.getConsumers();
assertEquals("Unexpected consumers size", 1, consumers.size());
ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
verify(_connection).sendFrame(eq(_session.getChannelId()), frameCapture.capture());
Attach sentAttach = (Attach) frameCapture.getValue();
assertEquals("Unexpected name", receivedAttach.getName(), sentAttach.getName());
assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
Source receivedSource = (Source) receivedAttach.getSource();
Source sentSource = (Source) sentAttach.getSource();
assertEquals("Unexpected source address", receivedSource.getAddress(), sentSource.getAddress());
assertArrayEquals("Unexpected source capabilities", receivedSource.getCapabilities(), sentSource.getCapabilities());
assertEquals("Unexpected source durability", receivedSource.getDurable(), sentSource.getDurable());
assertEquals("Unexpected source expiry policy", receivedSource.getExpiryPolicy(), sentSource.getExpiryPolicy());
assertEquals("Unexpected source dynamic flag", receivedSource.getDynamic(), sentSource.getDynamic());
Target receivedTarget = (Target) receivedAttach.getTarget();
Target sentTarget = (Target) sentAttach.getTarget();
assertEquals("Unexpected target address", receivedTarget.getAddress(), sentTarget.getAddress());
assertArrayEquals("Unexpected target capabilities", receivedTarget.getCapabilities(), sentTarget.getCapabilities());
assertEquals("Unexpected target durability", receivedTarget.getDurable(), sentTarget.getDurable());
assertEquals("Unexpected target expiry policy", receivedTarget.getExpiryPolicy(), sentTarget.getExpiryPolicy());
assertEquals("Unexpected target dynamic flag", receivedTarget.getDynamic(), sentTarget.getDynamic());
final Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
assertEquals("Unexpected number of queues after attach", 1, queues.size());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source in project qpid-broker-j by apache.
the class Session_1_0Test method setSelector.
private void setSelector(final Attach attach, final String selectorExpression) {
JMSSelectorFilter selector = new JMSSelectorFilter(selectorExpression);
final Map<Symbol, Filter> filter = Collections.singletonMap(Symbol.getSymbol("jms-selector"), selector);
((Source) attach.getSource()).setFilter(filter);
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source 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.protocol.v1_0.type.messaging.Source in project qpid-broker-j by apache.
the class Session_1_0Test method assertAttachFailed.
private void assertAttachFailed(final AMQPConnection_1_0 connection, final Session_1_0 session, final Attach attach, int invocationOffset) {
ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
verify(connection, times(invocationOffset + 2)).sendFrame(eq(session.getChannelId()), frameCapture.capture());
List<FrameBody> sentFrames = frameCapture.getAllValues();
assertTrue("unexpected Frame sent", sentFrames.get(invocationOffset) instanceof Attach);
Attach sentAttach = (Attach) sentFrames.get(invocationOffset);
assertEquals("Unexpected name", attach.getName(), sentAttach.getName());
assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
assertEquals("Unexpected source", null, sentAttach.getSource());
assertTrue("unexpected Frame sent", sentFrames.get(invocationOffset + 1) instanceof Detach);
Detach sentDetach = (Detach) sentFrames.get(invocationOffset + 1);
assertTrue("Unexpected closed state", sentDetach.getClosed());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source in project qpid-broker-j by apache.
the class Session_1_0Test method assertFilter.
private void assertFilter(final Attach sentAttach, final String selectorExpression) {
Source source = (Source) sentAttach.getSource();
Map<Symbol, Filter> filter = source.getFilter();
assertNotNull("Filter is not set in response", filter);
assertEquals("Unexpected filter size", 1, filter.size());
assertTrue("Selector is not found", filter.containsKey(JMS_SELECTOR_FILTER));
Filter jmsSelectorFilter = filter.get(JMS_SELECTOR_FILTER);
assertTrue("Unexpected selector filter", jmsSelectorFilter instanceof JMSSelectorFilter);
assertEquals("Unexpected selector", selectorExpression, ((JMSSelectorFilter) jmsSelectorFilter).getValue());
}
Aggregations