Search in sources :

Example 1 with ConnectionStart

use of org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart in project qpid-broker-j by apache.

the class ProtocolTest method versionNegotiation.

@Test
@SpecificationTest(section = "4.3. Version Negotiation", description = "When the client opens a new socket connection to an AMQP server," + " it MUST send a protocol header with the client's preferred protocol version." + "If the requested protocol version is supported, the server MUST send its own protocol" + " header with the requested version to the socket, and then implement the protocol accordingly")
public void versionNegotiation() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        Response<?> response = interaction.negotiateProtocol().consumeResponse().getLatestResponse();
        assertThat(response, is(instanceOf(HeaderResponse.class)));
        assertThat(response.getBody(), is(IsEqual.equalTo(transport.getProtocolHeader())));
        ConnectionStart connectionStart = interaction.consumeResponse().getLatestResponse(ConnectionStart.class);
        assertThat(connectionStart.getMechanisms(), is(notNullValue()));
        assertThat(connectionStart.getMechanisms(), contains(ConnectionInteraction.SASL_MECHANISM_ANONYMOUS));
        assertThat(connectionStart.getLocales(), is(notNullValue()));
        assertThat(connectionStart.getLocales(), contains(DEFAULT_LOCALE));
    }
}
Also used : ConnectionStart(org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 2 with ConnectionStart

use of org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart in project qpid-broker-j by apache.

the class AuthenticationTimeoutTest method authenticationTimeout.

@Test
public void authenticationTimeout() throws Exception {
    InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
    try (FrameTransport transport = new FrameTransport(brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final ConnectionStart start = interaction.negotiateProtocol().consumeResponse().consumeResponse().getLatestResponse(ConnectionStart.class);
        assertThat(start.getMechanisms(), CoreMatchers.hasItem("PLAIN"));
        transport.assertNoMoreResponsesAndChannelClosed();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_10.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v0_10.Interaction) ConnectionStart(org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart) Test(org.junit.Test)

Aggregations

ConnectionStart (org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart)2 Test (org.junit.Test)2 InetSocketAddress (java.net.InetSocketAddress)1 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)1 FrameTransport (org.apache.qpid.tests.protocol.v0_10.FrameTransport)1 Interaction (org.apache.qpid.tests.protocol.v0_10.Interaction)1