Search in sources :

Example 16 with Rejected

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

the class DischargeTest method dischargeUnknownTransactionIdWhenSourceDoesNotSupportRejectedOutcome.

@Test
@SpecificationTest(section = "4.3", description = "If the coordinator is unable to complete the discharge, the coordinator MUST convey the error to the controller " + "as a transaction-error. [...] If the source does not support " + "the rejected outcome, the transactional resource MUST detach the link to the coordinator, with the detach " + "performative carrying the transaction-error.")
public void dischargeUnknownTransactionIdWhenSourceDoesNotSupportRejectedOutcome() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final Disposition disposition = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attachTarget(new Coordinator()).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayloadData(new Declare()).transfer().consumeResponse().getLatestResponse(Disposition.class);
        assertThat(disposition.getSettled(), is(equalTo(true)));
        assertThat(disposition.getState(), is(instanceOf(Declared.class)));
        assertThat(((Declared) disposition.getState()).getTxnId(), is(notNullValue()));
        interaction.consumeResponse(Flow.class);
        final Discharge discharge = new Discharge();
        discharge.setTxnId(new Binary("nonExistingTransaction".getBytes(UTF_8)));
        final Detach detachResponse = interaction.transferDeliveryId(UnsignedInteger.ONE).transferDeliveryTag(new Binary("discharge".getBytes(UTF_8))).transferPayloadData(discharge).transfer().consumeResponse(Detach.class).getLatestResponse(Detach.class);
        Error error = detachResponse.getError();
        assertThat(error, is(notNullValue()));
        assertThat(error.getCondition(), is(equalTo(TransactionError.UNKNOWN_ID)));
    }
}
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) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Coordinator(org.apache.qpid.server.protocol.v1_0.type.transaction.Coordinator) Declare(org.apache.qpid.server.protocol.v1_0.type.transaction.Declare) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Discharge(org.apache.qpid.server.protocol.v1_0.type.transaction.Discharge) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)12 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)12 Test (org.junit.Test)12 Rejected (org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected)10 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)10 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)10 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)10 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)10 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)8 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)8 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)6 Discharge (org.apache.qpid.server.protocol.v1_0.type.transaction.Discharge)6 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)6 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)6 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)5 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)4 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)4 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)3 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)3