Search in sources :

Example 31 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class SaslTest method clientSendsSaslChallenge.

@Test
@SpecificationTest(section = "5.3.2", description = "SASL Negotiation")
public void clientSendsSaslChallenge() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
    try (FrameTransport transport = new FrameTransport(addr, true).connect()) {
        SaslChallenge saslChallenge = new SaslChallenge();
        saslChallenge.setChallenge(new Binary(new byte[] {}));
        transport.newInteraction().protocolHeader(SASL_AMQP_HEADER_BYTES).negotiateProtocol().consumeResponse().consumeResponse(SaslMechanisms.class).sendPerformative(saslChallenge).sync();
        transport.assertNoMoreResponsesAndChannelClosed();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) SaslChallenge(org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge) InetSocketAddress(java.net.InetSocketAddress) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 32 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class BeginTest method emptyBegin.

@Test
@SpecificationTest(section = "1.3.4", description = "Begin without mandatory fields should result in a decoding error.")
public void emptyBegin() throws Exception {
    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).beginNextOutgoingId(null).beginIncomingWindow(null).beginOutgoingWindow(null).begin().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) 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)

Example 33 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class ConnectionTest method tooLargeFrameSize.

@Test
@SpecificationTest(section = "1.4.2.6.2.", description = "If the client specifies a frame max that is higher than" + " the value provided by the server, the server MUST" + " close the connection without attempting a negotiated" + " close. The server may report the error in some fashion" + " to assist implementors.")
public void tooLargeFrameSize() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionTuneBody response = interaction.negotiateProtocol().consumeResponse(ConnectionStartBody.class).connection().startOkMechanism(ANONYMOUS).startOk().consumeResponse().getLatestResponse(ConnectionTuneBody.class);
        interaction.connection().tuneOkChannelMax(response.getChannelMax()).tuneOkFrameMax(Long.MAX_VALUE).tuneOkHeartbeat(response.getHeartbeat()).tuneOk().connection().open().consumeResponse(ConnectionCloseBody.class, ChannelClosedResponse.class);
    }
}
Also used : ConnectionTuneBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody) ConnectionStartBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 34 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class ConnectionTest method connectionStart.

@Test
@SpecificationTest(section = "1.4.2.1", description = "start connection negotiation")
public void connectionStart() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionStartBody response = interaction.negotiateProtocol().consumeResponse().getLatestResponse(ConnectionStartBody.class);
        assertThat(response.getVersionMajor(), is(equalTo((short) transport.getProtocolVersion().getMajorVersion())));
        assertThat(response.getVersionMinor(), is(equalTo((short) transport.getProtocolVersion().getActualMinorVersion())));
    }
}
Also used : ConnectionStartBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 35 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class ConnectionTest method tooSmallFrameSize.

@Test
@SpecificationTest(section = "1.4.2.6", description = "[...] the minimum negotiated value for frame-max is also" + " frame-min-size [4096].")
public void tooSmallFrameSize() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionTuneBody response = interaction.negotiateProtocol().consumeResponse(ConnectionStartBody.class).connection().startOkMechanism(ANONYMOUS).startOk().consumeResponse().getLatestResponse(ConnectionTuneBody.class);
        interaction.connection().tuneOkChannelMax(response.getChannelMax()).tuneOkFrameMax(1024).tuneOkHeartbeat(response.getHeartbeat()).tuneOk().connection().open().consumeResponse(ConnectionCloseBody.class, ChannelClosedResponse.class);
    }
}
Also used : ConnectionTuneBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody) ConnectionStartBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody) 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)209 Test (org.junit.Test)209 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)106 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)82 InetSocketAddress (java.net.InetSocketAddress)52 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)52 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)45 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)37 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)35 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)29 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)28 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)28 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)26 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)22 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)19 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)16 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)15 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)14 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)14 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)14