Search in sources :

Example 21 with Accepted

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

the class TransactionalTransferTest method sendTransactionalPostingReceiverSettlesSecond.

@Test
@SpecificationTest(section = "4.4.4", description = "Transactional Posting[...]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 sendTransactionalPostingReceiverSettlesSecond() 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);
        Disposition responseDisposition = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachHandle(linkHandle).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferHandle(linkHandle).transferPayloadData(TEST_MESSAGE_CONTENT).transferTransactionalState(txnState.getCurrentTransactionId()).transfer().consumeResponse(Disposition.class).getLatestResponse(Disposition.class);
        assertThat(responseDisposition.getRole(), is(Role.RECEIVER));
        assertThat(responseDisposition.getSettled(), is(Boolean.FALSE));
        assertThat(responseDisposition.getState(), is(instanceOf(TransactionalState.class)));
        assertThat(((TransactionalState) responseDisposition.getState()).getOutcome(), is(instanceOf(Accepted.class)));
        interaction.dispositionRole(Role.SENDER).dispositionSettled(true).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition();
        interaction.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) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) 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)

Aggregations

Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)20 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)16 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)16 Test (org.junit.Test)16 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)15 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)11 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)10 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)10 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)9 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)6 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)5 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)5 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)5 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)4 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Rejected (org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected)3 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)3