use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.
the class Session_1_0Test method testReceiveAttachTopicNonDurableNoContainer.
public void testReceiveAttachTopicNonDurableNoContainer() throws Exception {
final String linkName = "testLink";
final String address = "amq.direct/" + TOPIC_NAME;
Attach attach = createTopicAttach(false, linkName, address, true);
_session.receiveAttach(attach);
assertAttachSent(_connection, _session, attach);
assertQueues(TOPIC_NAME, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach 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.transport.Attach in project qpid-broker-j by apache.
the class Session_1_0Test method testReceiveAttachToExistingQueue.
public void testReceiveAttachToExistingQueue() throws Exception {
final String linkName = "testLink";
Attach attach = createQueueAttach(false, linkName, QUEUE_NAME);
Queue<?> queue = _virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, QUEUE_NAME));
Exchange<?> exchange = _virtualHost.getChildByName(Exchange.class, "amq.direct");
exchange.bind(QUEUE_NAME, QUEUE_NAME, Collections.emptyMap(), false);
_session.receiveAttach(attach);
assertAttachActions(queue, attach);
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach 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.transport.Attach in project qpid-broker-j by apache.
the class Session_1_0Test method testReceiveAttachToNonExistingQueue.
public void testReceiveAttachToNonExistingQueue() throws Exception {
final String linkName = "testLink";
Attach attach = createQueueAttach(false, linkName, QUEUE_NAME);
_session.receiveAttach(attach);
assertAttachFailed(_connection, _session, attach);
}
Aggregations