Search in sources :

Example 1 with 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 testReceiveAttachRebindingQueueNoActiveLinks.

public void testReceiveAttachRebindingQueueNoActiveLinks() {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createSharedTopicAttach(true, linkName, address, true);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
    sendDetach(_session, attach.getHandle(), false);
    ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
    verify(_connection, times(2)).sendFrame(eq(_session.getChannelId()), frameCapture.capture());
    assertTrue(frameCapture.getAllValues().get(1) instanceof Detach);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
    String topicName2 = TOPIC_NAME + "2";
    final String address2 = "amq.direct/" + topicName2;
    Attach attach2 = createSharedTopicAttach(true, linkName + "|2", address2, true);
    _session.receiveAttach(attach2);
    assertAttachSent(_connection, _session, attach2, 2);
    assertQueues(topicName2, LifetimePolicy.PERMANENT);
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) FrameBody(org.apache.qpid.server.protocol.v1_0.type.FrameBody) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Example 2 with 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 testReceiveDetachClosed.

public void testReceiveDetachClosed() 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(), true);
    Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after unsubscribe", 0, queues.size());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue)

Example 3 with 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 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());
}
Also used : Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) QueueConsumer(org.apache.qpid.server.queue.QueueConsumer) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) FrameBody(org.apache.qpid.server.protocol.v1_0.type.FrameBody) Queue(org.apache.qpid.server.model.Queue) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 4 with 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 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);
}
Also used : JMSSelectorFilter(org.apache.qpid.server.protocol.v1_0.type.messaging.JMSSelectorFilter) Filter(org.apache.qpid.server.protocol.v1_0.type.messaging.Filter) JMSSelectorFilter(org.apache.qpid.server.protocol.v1_0.type.messaging.JMSSelectorFilter) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 5 with 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 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());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue)

Aggregations

Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)85 Test (org.junit.Test)84 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)82 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)82 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)70 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)39 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)37 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)36 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)32 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)32 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)27 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)24 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)23 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)20 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)18 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)17 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)17 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)14 InetSocketAddress (java.net.InetSocketAddress)13 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)11