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);
}
}
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();
}
}
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)));
}
}
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)));
}
}
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)));
}
}
Aggregations