Search in sources :

Example 1 with Outcome

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

the class AnonymousTerminusTest method transferUnsettledToUnknownDestinationWhenRejectedOutcomeNotSupportedBySource.

@SpecificationTest(section = "Using the Anonymous Terminus for Message Routing. 2.2.2 Routing Errors", description = "It is possible that a message sent to a routing node has an address in the to field" + " of properties which, if used in the address field of target of an attach," + " would result in an unsuccessful link establishment (for example," + " if the address cannot be resolved to a node). In this case the routing node" + " MUST communicate the error back to the sender of the message." + " [...]" + " If the source of the link does not support the rejected outcome," + " [...] then the routing node MUST detach the link with an error." + " [...] the info field of error MUST contain an entry with symbolic key delivery-tag" + " and binary value of the delivery-tag of the message which caused the failure.")
@Test
public void transferUnsettledToUnknownDestinationWhenRejectedOutcomeNotSupportedBySource() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = openInteractionWithAnonymousRelayCapability(transport);
        interaction.begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(generateMessagePayloadToDestination("Unknown")).transferDeliveryTag(_deliveryTag).transfer();
        Detach detach = interaction.consumeResponse().getLatestResponse(Detach.class);
        Error error = detach.getError();
        assertThat(error, is(notNullValue()));
        assertThat(error.getCondition(), is(equalTo(AmqpError.NOT_FOUND)));
        assertThat(error.getInfo(), is(notNullValue()));
        assertThat(error.getInfo().get(DELIVERY_TAG), is(equalTo(_deliveryTag)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) 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)

Example 2 with Outcome

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

the class TransferTest method durableTransferWithRejectedOutcome.

@Test
@SpecificationTest(section = "3.2.1", description = "Durable messages MUST NOT be lost even if an intermediary is unexpectedly terminated and " + "restarted. A target which is not capable of fulfilling this guarantee MUST NOT accept messages " + "where the durable header is set to true: if the source allows the rejected outcome then the " + "message SHOULD be rejected with the precondition-failed error, otherwise the link MUST be " + "detached by the receiver with the same error.")
public void durableTransferWithRejectedOutcome() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        MessageEncoder messageEncoder = new MessageEncoder();
        final Header header = new Header();
        header.setDurable(true);
        messageEncoder.setHeader(header);
        messageEncoder.addData("foo");
        final Disposition receivedDisposition = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL, Rejected.REJECTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(messageEncoder.getPayload()).transferRcvSettleMode(ReceiverSettleMode.FIRST).transfer().consumeResponse().getLatestResponse(Disposition.class);
        assertThat(receivedDisposition.getSettled(), is(true));
        assertThat(receivedDisposition.getState(), is(instanceOf(Outcome.class)));
        if (getBrokerAdmin().supportsRestart()) {
            assertThat(((Outcome) receivedDisposition.getState()).getSymbol(), is(Accepted.ACCEPTED_SYMBOL));
        } else {
            assertThat(((Outcome) receivedDisposition.getState()).getSymbol(), is(Rejected.REJECTED_SYMBOL));
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) MessageEncoder(org.apache.qpid.tests.protocol.v1_0.MessageEncoder) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 3 with Outcome

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

the class TransferTest method durableTransferWithoutRejectedOutcome.

@Test
@SpecificationTest(section = "3.2.1", description = "Durable messages MUST NOT be lost even if an intermediary is unexpectedly terminated and " + "restarted. A target which is not capable of fulfilling this guarantee MUST NOT accept messages " + "where the durable header is set to true: if the source allows the rejected outcome then the " + "message SHOULD be rejected with the precondition-failed error, otherwise the link MUST be " + "detached by the receiver with the same error.")
public void durableTransferWithoutRejectedOutcome() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        MessageEncoder messageEncoder = new MessageEncoder();
        final Header header = new Header();
        header.setDurable(true);
        messageEncoder.setHeader(header);
        messageEncoder.addData("foo");
        final Response<?> response = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(messageEncoder.getPayload()).transferRcvSettleMode(ReceiverSettleMode.FIRST).transfer().consumeResponse().getLatestResponse();
        if (getBrokerAdmin().supportsRestart()) {
            assertThat(response, is(notNullValue()));
            assertThat(response.getBody(), is(instanceOf(Disposition.class)));
            final Disposition receivedDisposition = (Disposition) response.getBody();
            assertThat(receivedDisposition.getSettled(), is(true));
            assertThat(receivedDisposition.getState(), is(instanceOf(Outcome.class)));
            assertThat(((Outcome) receivedDisposition.getState()).getSymbol(), is(Accepted.ACCEPTED_SYMBOL));
        } else {
            assertThat(response, is(notNullValue()));
            assertThat(response.getBody(), is(instanceOf(Detach.class)));
            final Detach receivedDetach = (Detach) response.getBody();
            assertThat(receivedDetach.getError(), is(notNullValue()));
            assertThat(receivedDetach.getError().getCondition(), is(AmqpError.PRECONDITION_FAILED));
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) MessageEncoder(org.apache.qpid.tests.protocol.v1_0.MessageEncoder) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 4 with Outcome

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

the class DischargeTest method dischargeSettledAfterSenderDetach.

@Test
@SpecificationTest(section = "4.4.4.1", description = "Transactional Posting [...]" + " Delivery Sent Unsettled By Controller; Resource Settles [...]" + " The resource MUST determine the outcome of the delivery before committing the" + " transaction, and this MUST be communicated to the controller before the acceptance" + " of a successful discharge. The outcome communicated by the resource MUST be associated" + " with the same transaction with which the transfer from controller to resource" + " was associated.")
public void dischargeSettledAfterSenderDetach() throws Exception {
    assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
    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.SENDER).attachHandle(UnsignedInteger.ONE).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferTransactionalState(txnState.getCurrentTransactionId()).transferPayloadData("test message").transferHandle(UnsignedInteger.ONE).transfer().consumeResponse(Disposition.class).detachHandle(UnsignedInteger.ONE).detach().consumeResponse(Detach.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        interaction.txnDischarge(txnState, false);
        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) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 5 with Outcome

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

the class DischargeTest method dischargeUnsettledAfterSenderClose.

@Test
@SpecificationTest(section = "4.4.4.1", description = "Transactional Posting [...]" + " Delivery Sent Unsettled By Controller; Resource Does Not Settle [...]" + " After a successful discharge, the state of unsettled deliveries at the resource MUST" + " reflect the outcome that was applied.")
public void dischargeUnsettledAfterSenderClose() throws Exception {
    assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
    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.SENDER).attachHandle(UnsignedInteger.ONE).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferTransactionalState(txnState.getCurrentTransactionId()).transferPayloadData("test message").transferHandle(UnsignedInteger.ONE).transfer().consumeResponse(Disposition.class).detachHandle(UnsignedInteger.ONE).detachClose(true).detach().consumeResponse(Detach.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        interaction.txnDischarge(txnState, false);
        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) 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

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