Search in sources :

Example 1 with SpecificationTest

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

the class ConnectionTest method authenticationBypassBySendingTuneOk.

@Test
@SpecificationTest(section = "9", description = "open-connection = C:protocol-header S:START C:START-OK *challenge S:TUNE C:TUNE-OK C:OPEN S:OPEN-OK")
public void authenticationBypassBySendingTuneOk() throws Exception {
    InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
    try (FrameTransport transport = new FrameTransport(brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateProtocol().consumeResponse().consumeResponse(ConnectionStart.class).connection().tuneOk().connection().open().consumeResponse().getLatestResponse(ConnectionClose.class);
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 2 with SpecificationTest

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

the class ConnectionTest method heartbeatingIncomingIdle.

@Test
@SpecificationTest(section = "9.connection", description = "If a connection is idle for more than twice the negotiated heartbeat delay, the peers MAY " + "be considered disconnected.")
public void heartbeatingIncomingIdle() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionTune response = interaction.negotiateProtocol().consumeResponse().consumeResponse(ConnectionStart.class).connection().startOkMechanism(ConnectionInteraction.SASL_MECHANISM_ANONYMOUS).startOk().consumeResponse().getLatestResponse(ConnectionTune.class);
        assumeThat(response.hasHeartbeatMin(), is(true));
        assumeThat(response.hasHeartbeatMax(), is(true));
        assumeThat(response.getHeartbeatMin(), is(greaterThanOrEqualTo(0)));
        assumeThat(response.getHeartbeatMax(), is(greaterThanOrEqualTo(1)));
        final int heartbeatPeriod = 1;
        interaction.connection().tuneOkChannelMax(response.getChannelMax()).tuneOkMaxFrameSize(response.getMaxFrameSize()).tuneOkHeartbeat(heartbeatPeriod).tuneOk().connection().open().consumeResponse(ConnectionOpenOk.class);
        interaction.consumeResponse().getLatestResponse(ConnectionHeartbeat.class);
        transport.assertNoMoreResponsesAndChannelClosed();
    }
}
Also used : ConnectionTune(org.apache.qpid.server.protocol.v0_10.transport.ConnectionTune) 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 3 with SpecificationTest

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

the class ExchangeTest method exchangeQuery.

@Test
@SpecificationTest(section = "10.exchange.query", description = "request information about an exchange")
public void exchangeQuery() throws Exception {
    String exchangeName = "myexch";
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionResult result = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).exchange().declareId(0).declareExchange(exchangeName).declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declare().exchange().queryId(1).queryExchange(exchangeName).query().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        ExchangeQueryResult queryResult = (ExchangeQueryResult) result.getValue();
        assertThat(queryResult.getNotFound(), is(equalTo(false)));
    }
}
Also used : ExchangeQueryResult(org.apache.qpid.server.protocol.v0_10.transport.ExchangeQueryResult) ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 4 with SpecificationTest

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

the class ExchangeTest method exchangeDelete.

@Test
@SpecificationTest(section = "10.exchange.delete", description = "delete an exchange")
public void exchangeDelete() throws Exception {
    String exchangeName = "myexch";
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).exchange().declareExchange(exchangeName).declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareId(0).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        interaction.exchange().deleteExchange(exchangeName).deleteId(1).delete().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        ExecutionResult result = interaction.exchange().queryExchange(exchangeName).queryId(2).query().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        ExchangeQueryResult queryResult = (ExchangeQueryResult) result.getValue();
        assertThat(queryResult.getNotFound(), is(equalTo(true)));
    }
}
Also used : ExchangeQueryResult(org.apache.qpid.server.protocol.v0_10.transport.ExchangeQueryResult) ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 5 with SpecificationTest

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

the class ExchangeTest method exchangeDeleteInUseAsAlternate.

@Test
@SpecificationTest(section = "10.exchange.delete", description = "An exchange MUST NOT be deleted if it is in use as an alternate-exchange by a queue or by " + "another exchange.")
public void exchangeDeleteInUseAsAlternate() throws Exception {
    String exchangeName1 = "myexch1";
    String exchangeName2 = "myexch2";
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionException response = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).exchange().declareExchange(exchangeName1).declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareId(0).declare().exchange().declareExchange(exchangeName2).declareAlternateExchange(exchangeName1).declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareId(1).declare().exchange().deleteExchange(exchangeName1).deleteId(2).delete().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
        assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.NOT_ALLOWED)));
    }
}
Also used : ExecutionException(org.apache.qpid.server.protocol.v0_10.transport.ExecutionException) 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