Search in sources :

Example 41 with Close

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

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

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

the class SaslTest method unsupportedSaslMechanism.

@Test
@SpecificationTest(section = "5.3.2", description = "The partner MUST then choose one of the supported mechanisms and initiate a sasl exchange." + "If the selected mechanism is not supported by the receiving peer, it MUST close the connection " + "with the authentication-failure close-code.")
public void unsupportedSaslMechanism() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
    try (FrameTransport transport = new FrameTransport(addr, true).connect()) {
        final Interaction interaction = transport.newInteraction();
        final byte[] saslHeaderResponse = interaction.protocolHeader(SASL_AMQP_HEADER_BYTES).negotiateProtocol().consumeResponse().getLatestResponse(byte[].class);
        assertThat(saslHeaderResponse, is(equalTo(SASL_AMQP_HEADER_BYTES)));
        interaction.consumeResponse(SaslMechanisms.class);
        SaslOutcome saslOutcome = interaction.saslMechanism(Symbol.getSymbol("NOT-A-MECHANISM")).saslInit().consumeResponse().getLatestResponse(SaslOutcome.class);
        assertThat(saslOutcome.getCode(), equalTo(SaslCode.AUTH));
        assertThat(saslOutcome.getAdditionalData(), is(nullValue()));
        transport.assertNoMoreResponsesAndChannelClosed();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) SaslOutcome(org.apache.qpid.server.protocol.v1_0.type.security.SaslOutcome) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 44 with Close

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

the class BeginTest method channelMax.

@Test
@SpecificationTest(section = "2.7.1", description = "A peer that receives a channel number outside the supported range MUST close " + "the connection with the framing-error error-code..")
public void channelMax() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Close responseClose = transport.newInteraction().negotiateProtocol().consumeResponse().openChannelMax(UnsignedShort.valueOf(5)).open().consumeResponse(Open.class).sessionChannel(UnsignedShort.valueOf(6)).begin().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) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)26 Test (org.junit.Test)23 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)21 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)18 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)15 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)14 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)13 InetSocketAddress (java.net.InetSocketAddress)10 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)8 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)8 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)7 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)7 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)6 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)6 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)5 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)5 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)5 ArrayList (java.util.ArrayList)4 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)4 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)4