Search in sources :

Example 61 with Error

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

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

the class OpenTest method failOpenOnChannelNotZero.

@Test
@SpecificationTest(section = "2.4.1", description = "The open frame can only be sent on channel 0. ยง2.7.1: A peer that receives a channel number outside the supported range MUST close the connection with the framing-error error-code.")
public void failOpenOnChannelNotZero() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        final Interaction interaction = transport.newInteraction();
        Open responseOpen = interaction.negotiateProtocol().consumeResponse().openContainerId("testContainerId").connectionChannel(UnsignedShort.valueOf((short) 1)).open().consumeResponse().getLatestResponse(Open.class);
        assertThat(responseOpen.getContainerId(), is(notNullValue()));
        Close responseClose = interaction.consumeResponse().getLatestResponse(Close.class);
        assertThat(responseClose.getError(), is(notNullValue()));
        assertThat(responseClose.getError().getCondition(), equalTo(ConnectionError.FRAMING_ERROR));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) 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 63 with Error

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

the class OpenTest method emptyOpen.

@Test
@SpecificationTest(section = "1.3.4", description = "Open without mandatory fields should result in a decoding error.")
public void emptyOpen() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        final Interaction interaction = transport.newInteraction();
        Open responseOpen = interaction.negotiateProtocol().consumeResponse().openContainerId(null).open().consumeResponse().getLatestResponse(Open.class);
        assertThat(responseOpen.getContainerId(), is(notNullValue()));
        Close responseClose = interaction.consumeResponse().getLatestResponse(Close.class);
        assertThat(responseClose.getError(), is(notNullValue()));
        assertThat(responseClose.getError().getCondition(), equalTo(AmqpError.DECODE_ERROR));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) 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 64 with Error

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

the class FlowTest method emptyFlow.

@Test
@SpecificationTest(section = "1.3.4", description = "Flow without mandatory fields should result in a decoding error.")
public void emptyFlow() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Close responseClose = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).flowIncomingWindow(null).flowNextIncomingId(null).flowOutgoingWindow(null).flowNextOutgoingId(null).flow().consumeResponse().getLatestResponse(Close.class);
        assertThat(responseClose.getError(), is(notNullValue()));
        assertThat(responseClose.getError().getCondition(), is(AmqpError.DECODE_ERROR));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) 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 65 with Error

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

the class FlowTest method flowWithUnknownHandle.

@Test
@SpecificationTest(section = "2.7.4", description = "If set to a handle that is not currently associated with an attached link, the recipient" + " MUST respond by ending the session with an unattached-handle session error.")
public void flowWithUnknownHandle() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        End responseEnd = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).flowEcho(true).flowHandle(UnsignedInteger.ONE).flow().consumeResponse().getLatestResponse(End.class);
        assertThat(responseEnd.getError(), is(notNullValue()));
        assertThat(responseEnd.getError().getCondition(), is(equalTo(SessionError.UNATTACHED_HANDLE)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) 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

Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)49 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)40 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)30 Test (org.junit.Test)30 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)28 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)22 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)17 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)15 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)15 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)15 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)15 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)14 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)14 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)14 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)13 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)12 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)12 LinkError (org.apache.qpid.server.protocol.v1_0.type.transport.LinkError)12 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)11 InetSocketAddress (java.net.InetSocketAddress)10