Search in sources :

Example 11 with Flow

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

the class TransactionalTransferTest method receiveTransactionalRetirementReceiverSettleFirst.

@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement[...] The transaction controller might" + "wish to associate the outcome of a delivery with a transaction.")
public void receiveTransactionalRetirementReceiverSettleFirst() 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);
        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().decodeLatestDelivery();
        Object data = interaction.getDecodedLatestDelivery();
        assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
        interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition().txnDischarge(txnState, false);
    }
}
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) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) 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 12 with Flow

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

the class TransactionalTransferTest method receiveTransactionalAcquisitionDischargeFail.

@Test
@SpecificationTest(section = "4.4.3", description = "Transactional Acquisition[...]In the case of the flow frame," + " the transactional work is not necessarily directly" + " initiated or entirely determined when the flow frame" + " arrives at the resource, but can in fact occur at some " + " later point and in ways not necessarily" + " anticipated by the controller.")
public void receiveTransactionalAcquisitionDischargeFail() 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);
        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().flowProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), txnState.getCurrentTransactionId())).flow().receiveDelivery();
        List<Transfer> transfers = interaction.getLatestDelivery();
        assertThat(transfers.size(), is(equalTo(1)));
        Transfer transfer = transfers.get(0);
        assertThat(transfer.getState(), is(instanceOf(TransactionalState.class)));
        assertThat(((TransactionalState) transfer.getState()).getTxnId(), is(equalTo(txnState.getCurrentTransactionId())));
        Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
        assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
        interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition().txnDischarge(txnState, true);
        assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
    }
}
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) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) 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 13 with Flow

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

the class TransactionalTransferTest method receiveTransactionalAcquisitionFlowFailsDueToUnknownTransactionId.

@Test
@Ignore("QPID-7951")
@SpecificationTest(section = "4.4.3", description = "Transactional Acquisition[...]" + " the resource associates an additional piece of state with" + " outgoing link endpoints, a txn-id that identifies" + " the transaction with which acquired messages" + " will be associated. This state is determined by" + " the controller by specifying a txn-id entry in the" + " properties map of the flow frame.")
public void receiveTransactionalAcquisitionFlowFailsDueToUnknownTransactionId() 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);
        Response<?> response = 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().flowProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), integerToBinary(Integer.MAX_VALUE))).flow().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) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Ignore(org.junit.Ignore) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 14 with Flow

use of org.apache.qpid.server.protocol.v1_0.type.transport.Flow 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 Flow

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

the class AttachTest method attachSenderWithNullSource.

@Test
@SpecificationTest(section = "2.6.3", description = "Note that if the application chooses not to create a terminus, the session endpoint will" + " still create a link endpoint and issue an attach indicating that the link endpoint has" + " no associated local terminus. In this case, the session endpoint MUST immediately" + " detach the newly created link endpoint.")
public void attachSenderWithNullSource() throws Exception {
    String queueName = "testQueue";
    getBrokerAdmin().createQueue(queueName);
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction();
        final Attach responseAttach = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachSource(null).attachTargetAddress(queueName).attachInitialDeliveryCount(UnsignedInteger.ZERO).attach().consumeResponse().getLatestResponse(Attach.class);
        assertThat(responseAttach.getName(), is(notNullValue()));
        assertThat(responseAttach.getHandle().longValue(), is(both(greaterThanOrEqualTo(0L)).and(lessThan(UnsignedInteger.MAX_VALUE.longValue()))));
        assertThat(responseAttach.getRole(), is(Role.RECEIVER));
        assertThat(responseAttach.getSource(), is(nullValue()));
        assertThat(responseAttach.getTarget(), is(nullValue()));
        final Detach responseDetach = interaction.consumeResponse().getLatestResponse(Detach.class);
        assertThat(responseDetach.getClosed(), is(true));
        assertThat(responseDetach.getError(), is(notNullValue()));
        assertThat(responseDetach.getError().getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
        final End endResponse = interaction.flowHandleFromLinkHandle().flowEcho(true).flow().consumeResponse().getLatestResponse(End.class);
        assertThat(endResponse.getError(), is(notNullValue()));
    // QPID-7954
    // assertThat(endResponse.getError().getCondition(), is(equalTo(SessionError.ERRANT_LINK)));
    }
}
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) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) 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)

Aggregations

FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)42 Test (org.junit.Test)42 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)41 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)37 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)29 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)24 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)20 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)19 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)15 InetSocketAddress (java.net.InetSocketAddress)13 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)12 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)12 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)11 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)11 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)11 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)7 Ignore (org.junit.Ignore)7 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)5 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)5 BrokerAdmin (org.apache.qpid.tests.utils.BrokerAdmin)4