Search in sources :

Example 11 with UnsignedInteger

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

the class TransferTest method assertDeliveries.

private void assertDeliveries(final Interaction interaction, final TreeSet<UnsignedInteger> expectedDeliveryIds) throws Exception {
    do {
        Response<?> response = interaction.consumeResponse(Disposition.class, Flow.class).getLatestResponse();
        if (response.getBody() instanceof Disposition) {
            Disposition disposition = (Disposition) response.getBody();
            LongStream.rangeClosed(disposition.getFirst().longValue(), disposition.getLast() == null ? disposition.getFirst().longValue() : disposition.getLast().longValue()).forEach(value -> {
                UnsignedInteger deliveryId = expectedDeliveryIds.first();
                assertThat(value, is(equalTo(deliveryId.longValue())));
                expectedDeliveryIds.remove(deliveryId);
            });
        }
    } while (!expectedDeliveryIds.isEmpty());
}
Also used : Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow)

Example 12 with UnsignedInteger

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

the class DischargeTest method dischargeSettledAfterReceiverDetach.

@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement [...]" + " To associate an outcome with a transaction the controller sends a disposition" + " performative which sets the state of the delivery to a transactional-state with the" + " desired transaction identifier and the outcome to be applied upon a successful discharge.")
public void dischargeSettledAfterReceiverDetach() throws Exception {
    assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "test message");
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
        List<Transfer> transfers = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().getLatestDelivery();
        assertThat(transfers, is(notNullValue()));
        assertThat(transfers, is(not(empty())));
        final UnsignedInteger deliveryId = transfers.get(0).getDeliveryId();
        interaction.detach().consumeResponse(Detach.class).dispositionFirst(deliveryId).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).dispositionRole(Role.RECEIVER).disposition().txnDischarge(txnState, false);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 13 with UnsignedInteger

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

the class TransactionalTransferTest method sendTransactionalPostingTransferFailsDueToUnknownTransactionId.

@Test
@SpecificationTest(section = "4.4.1", description = "If the transaction controller wishes to associate an outgoing transfer with a transaction," + " it MUST set the state of the transfer with a transactional-state carrying the appropriate" + " transaction identifier.")
public void sendTransactionalPostingTransferFailsDueToUnknownTransactionId() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final UnsignedInteger linkHandle = UnsignedInteger.ONE;
        final Interaction interaction = transport.newInteraction();
        final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
        Response<?> response = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachHandle(linkHandle).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferHandle(linkHandle).transferPayloadData(TEST_MESSAGE_CONTENT).transferTransactionalState(integerToBinary(Integer.MAX_VALUE)).transfer().consumeResponse().getLatestResponse();
        assertUnknownTransactionIdError(response);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 14 with UnsignedInteger

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

the class TransactionalTransferTest method receiveTransactionalRetirementDispositionFailsDueToUnknownTransactionId.

@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement[...]" + " To associate an outcome with a transaction the controller" + " sends a disposition performative which sets the state" + " of the delivery to a transactional-state with the desired" + " transaction identifier and the outcome to be applied" + " upon a successful discharge.")
public void receiveTransactionalRetirementDispositionFailsDueToUnknownTransactionId() throws Exception {
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
        List<Transfer> transfers = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().getLatestDelivery();
        UnsignedInteger deliveryId = transfers.get(0).getDeliveryId();
        assertThat(deliveryId, is(notNullValue()));
        Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
        assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
        Response<?> response = interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(integerToBinary(Integer.MAX_VALUE), new Accepted()).dispositionFirst(deliveryId).disposition().consumeResponse().getLatestResponse();
        assertUnknownTransactionIdError(response);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 15 with UnsignedInteger

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

the class FlowTest method synchronousGetWithTimeoutEmptyQueue.

@Test
@SpecificationTest(section = "2.6.8", description = "Synchronous get with a timeout is accomplished by incrementing the link-credit," + " sending the updated flow state and waiting for the link-credit to be consumed." + " When the desired time has elapsed the receiver then sets the drain flag and sends" + " the newly updated flow state again, while continuing to wait for the link-credit" + " to be consumed.")
public void synchronousGetWithTimeoutEmptyQueue() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class);
        Attach remoteAttach = interaction.getLatestResponse(Attach.class);
        UnsignedInteger remoteHandle = remoteAttach.getHandle();
        assertThat(remoteHandle, is(notNullValue()));
        Flow responseFlow = interaction.flowIncomingWindow(UnsignedInteger.valueOf(1)).flowNextIncomingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.FALSE).flowEcho(Boolean.TRUE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
        assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
        assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ONE)));
        assertThat(responseFlow.getDrain(), is(equalTo(Boolean.FALSE)));
        responseFlow = interaction.flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.TRUE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
        assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
        assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)57 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)35 Test (org.junit.Test)35 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)33 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)29 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)25 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)20 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)18 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)17 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)14 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)13 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)12 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)11 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)11 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)8 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)7 InetSocketAddress (java.net.InetSocketAddress)6 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)6 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)6