Search in sources :

Example 51 with Source

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

the class DischargeTest method dischargeUnknownTransactionIdWhenSourceSupportsRejectedOutcome.

@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 for the link to the coordinator supports the rejected outcome, then the " + "message MUST be rejected with this outcome carrying the transaction-error.")
public void dischargeUnknownTransactionIdWhenSourceSupportsRejectedOutcome() 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(Rejected.REJECTED_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 Disposition dischargeDisposition = interaction.transferDeliveryId(UnsignedInteger.ONE).transferDeliveryTag(new Binary("discharge".getBytes(UTF_8))).transferPayloadData(discharge).transfer().consumeResponse().getLatestResponse(Disposition.class);
        assertThat(dischargeDisposition.getState(), is(instanceOf(Rejected.class)));
        final Error error = ((Rejected) dischargeDisposition.getState()).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) Rejected(org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected) Coordinator(org.apache.qpid.server.protocol.v1_0.type.transaction.Coordinator) Declare(org.apache.qpid.server.protocol.v1_0.type.transaction.Declare) 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)

Example 52 with Source

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source 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)

Example 53 with Source

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

the class Interaction method attachSourceOutcomes.

public Interaction attachSourceOutcomes(final Symbol... outcomes) {
    Source source = ((Source) _attach.getSource());
    source.setOutcomes(outcomes);
    _attach.setSource(source);
    return this;
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 54 with Source

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

the class Interaction method attachSourceAddress.

public Interaction attachSourceAddress(String address) {
    Source source = (Source) _attach.getSource();
    source.setAddress(address);
    _attach.setSource(source);
    return this;
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 55 with Source

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

the class Interaction method attachSourceDefaultOutcome.

public Interaction attachSourceDefaultOutcome(final Outcome defaultOutcome) {
    Source source = ((Source) _attach.getSource());
    source.setDefaultOutcome(defaultOutcome);
    _attach.setSource(source);
    return this;
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Aggregations

Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)32 BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)16 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)15 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)14 Test (org.junit.Test)14 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)13 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)13 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)11 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)10 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)10 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)10 MessageSource (org.apache.qpid.server.message.MessageSource)9 LinkKey (org.apache.qpid.server.protocol.v1_0.LinkKey)8 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)8 StoreException (org.apache.qpid.server.store.StoreException)8 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)7 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)7 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)6 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)6 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)6