Search in sources :

Example 1 with Begin

use of org.apache.qpid.server.protocol.v1_0.type.transport.Begin in project qpid-broker-j by apache.

the class Session_1_0Test method createSession_1_0.

private Session_1_0 createSession_1_0(final AMQPConnection_1_0 connection, int channelId) {
    Begin begin = mock(Begin.class);
    when(begin.getNextOutgoingId()).thenReturn(new UnsignedInteger(channelId));
    return new Session_1_0(connection, begin, channelId, channelId, 2048);
}
Also used : Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 2 with Begin

use of org.apache.qpid.server.protocol.v1_0.type.transport.Begin in project qpid-broker-j by apache.

the class ResumeDeliveriesTest method resumeReceivingLinkWithSingleUnsettledAccepted.

@Ignore("QPID-7845")
@Test
@SpecificationTest(section = "2.6.13", description = "When a suspended link having unsettled deliveries is resumed," + " the unsettled field from the attach frame will carry" + " the delivery-tags and delivery state of all deliveries" + " considered unsettled by the issuing link endpoint.")
public void resumeReceivingLinkWithSingleUnsettledAccepted() throws Exception {
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse().begin().consumeResponse().attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attachSndSettleMode(SenderSettleMode.UNSETTLED).attach().consumeResponse();
        Attach attach = interaction.getLatestResponse(Attach.class);
        assumeThat(attach.getSndSettleMode(), is(equalTo(SenderSettleMode.UNSETTLED)));
        interaction.flowIncomingWindow(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery();
        List<Transfer> transfers = interaction.getLatestDelivery();
        assertThat(transfers, hasSize(1));
        Transfer transfer = transfers.get(0);
        Binary deliveryTag = transfer.getDeliveryTag();
        assertThat(deliveryTag, is(notNullValue()));
        assertThat(transfer.getSettled(), is(not(equalTo(true))));
        Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
        assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
        Detach detach = interaction.detach().consumeResponse().getLatestResponse(Detach.class);
        assertThat(detach.getClosed(), anyOf(nullValue(), equalTo(false)));
        interaction.attachUnsettled(Collections.singletonMap(deliveryTag, new Accepted())).attach().consumeResponse(Attach.class);
        Attach resumeAttach = interaction.getLatestResponse(Attach.class);
        Map<Binary, DeliveryState> unsettled = resumeAttach.getUnsettled();
        assertThat(unsettled, is(notNullValue()));
        assertThat(unsettled.entrySet(), hasSize(1));
        Map.Entry<Binary, DeliveryState> entry = unsettled.entrySet().iterator().next();
        assertThat(entry.getKey(), is(equalTo(deliveryTag)));
        interaction.flowNextIncomingId(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery();
        transfers = interaction.getLatestDelivery();
        assertThat(transfers, hasSize(1));
        Transfer resumeTransfer = transfers.get(0);
        assertThat(resumeTransfer.getResume(), is(equalTo(true)));
        assertThat(resumeTransfer.getDeliveryTag(), is(equalTo(deliveryTag)));
        assertThat(resumeTransfer.getPayload(), is(nullValue()));
        if (!Boolean.TRUE.equals(resumeTransfer.getSettled())) {
            interaction.dispositionSettled(true).dispositionState(new Accepted()).dispositionRole(Role.RECEIVER).disposition();
        }
        interaction.doCloseConnection();
        if (getBrokerAdmin().isQueueDepthSupported()) {
            assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) DeliveryState(org.apache.qpid.server.protocol.v1_0.type.DeliveryState) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Map(java.util.Map) HashMap(java.util.HashMap) Ignore(org.junit.Ignore) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 3 with Begin

use of org.apache.qpid.server.protocol.v1_0.type.transport.Begin in project qpid-broker-j by apache.

the class ResumeDeliveriesTest method resumeReceivingLinkOneUnsettledWithNoOutcome.

@Ignore("QPID-7845")
@Test
@SpecificationTest(section = "2.6.13", description = "When a suspended link having unsettled deliveries is resumed," + " the unsettled field from the attach frame will carry" + " the delivery-tags and delivery state of all deliveries" + " considered unsettled by the issuing link endpoint.")
public void resumeReceivingLinkOneUnsettledWithNoOutcome() throws Exception {
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse().begin().consumeResponse().attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attachSndSettleMode(SenderSettleMode.UNSETTLED).attach().consumeResponse();
        Attach attach = interaction.getLatestResponse(Attach.class);
        assumeThat(attach.getSndSettleMode(), is(equalTo(SenderSettleMode.UNSETTLED)));
        interaction.flowIncomingWindow(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery();
        List<Transfer> transfers = interaction.getLatestDelivery();
        assertThat(transfers, hasSize(1));
        Transfer transfer = transfers.get(0);
        Binary deliveryTag = transfer.getDeliveryTag();
        assertThat(deliveryTag, is(notNullValue()));
        Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
        assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
        Detach detach = interaction.detach().consumeResponse(Detach.class).getLatestResponse(Detach.class);
        assertThat(detach.getClosed(), anyOf(nullValue(), equalTo(false)));
        interaction.attachUnsettled(Collections.singletonMap(deliveryTag, null)).attach().consumeResponse(Attach.class);
        Attach resumeAttach = interaction.getLatestResponse(Attach.class);
        Map<Binary, DeliveryState> unsettled = resumeAttach.getUnsettled();
        assertThat(unsettled, is(notNullValue()));
        assertThat(unsettled.entrySet(), hasSize(1));
        Map.Entry<Binary, DeliveryState> entry = unsettled.entrySet().iterator().next();
        assertThat(entry.getKey(), is(equalTo(deliveryTag)));
        interaction.flowNextIncomingId(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery();
        transfers = interaction.getLatestDelivery();
        assertThat(transfers, hasSize(1));
        Transfer resumeTransfer = transfers.get(0);
        assertThat(resumeTransfer.getResume(), is(equalTo(true)));
        assertThat(resumeTransfer.getDeliveryTag(), is(equalTo(deliveryTag)));
        assertThat(resumeTransfer.getPayload(), is(notNullValue()));
        interaction.dispositionSettled(true).dispositionState(new Accepted()).dispositionRole(Role.RECEIVER).disposition();
        interaction.doCloseConnection();
        if (getBrokerAdmin().isQueueDepthSupported()) {
            assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), Matchers.is(Matchers.equalTo(0)));
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) DeliveryState(org.apache.qpid.server.protocol.v1_0.type.DeliveryState) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Map(java.util.Map) HashMap(java.util.HashMap) Ignore(org.junit.Ignore) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 4 with Begin

use of org.apache.qpid.server.protocol.v1_0.type.transport.Begin in project qpid-broker-j by apache.

the class BeginTest method emptyBegin.

@Test
@SpecificationTest(section = "1.3.4", description = "Begin without mandatory fields should result in a decoding error.")
public void emptyBegin() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Close responseClose = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).beginNextOutgoingId(null).beginIncomingWindow(null).beginOutgoingWindow(null).begin().consumeResponse().getLatestResponse(Close.class);
        assertThat(responseClose.getError(), is(notNullValue()));
        assertThat(responseClose.getError().getCondition(), equalTo(AmqpError.DECODE_ERROR));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 5 with Begin

use of org.apache.qpid.server.protocol.v1_0.type.transport.Begin in project qpid-broker-j by apache.

the class Interaction method copyBegin.

private Begin copyBegin(final Begin begin) {
    final Begin beginCopy = new Begin();
    beginCopy.setRemoteChannel(begin.getRemoteChannel());
    beginCopy.setNextOutgoingId(begin.getNextOutgoingId());
    beginCopy.setIncomingWindow(begin.getIncomingWindow());
    beginCopy.setOutgoingWindow(begin.getOutgoingWindow());
    beginCopy.setHandleMax(begin.getHandleMax());
    beginCopy.setOfferedCapabilities(begin.getOfferedCapabilities());
    beginCopy.setDesiredCapabilities(begin.getDesiredCapabilities());
    if (begin.getProperties() != null) {
        beginCopy.setProperties(new LinkedHashMap<>(begin.getProperties()));
    }
    return beginCopy;
}
Also used : Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin)

Aggregations

Test (org.junit.Test)76 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)74 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)74 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)57 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)51 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)39 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)35 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)30 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)24 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)23 InetSocketAddress (java.net.InetSocketAddress)19 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)18 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)18 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)15 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)11 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)10 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)9 Ignore (org.junit.Ignore)8 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)7