use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeclareAmqDisallowed.
@Test
@SpecificationTest(section = "1.6.2.1", description = "Exchange names starting with \"amq.\" are reserved for pre-declared and standardised " + "exchanges. The client MAY declare an exchange starting with \"amq.\" if the passive " + "option is set, or the exchange already exists.")
public void exchangeDeclareAmqDisallowed() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declarePassive(true).declareName(ExchangeDefaults.DIRECT_EXCHANGE_NAME).declare().consumeResponse(ExchangeDeclareOkBody.class).exchange().declarePassive(false).declareName(ExchangeDefaults.DIRECT_EXCHANGE_NAME).declare().consumeResponse(ExchangeDeclareOkBody.class);
ConnectionCloseBody response = interaction.exchange().declarePassive(false).declareName("amq.illegal").declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
/* TODO: 0-91 specification requires 'access-refused' (403) but server uses 'not-allowed' (530) */
assertThat(response.getReplyCode(), anyOf(equalTo(ErrorCodes.NOT_ALLOWED), equalTo(ErrorCodes.ACCESS_REFUSED)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeRedeclareDifferentType.
@Test
@SpecificationTest(section = "1.6.2.1", description = "The client MUST not attempt to redeclare an existing exchange with a different type than " + "used in the original Exchange.Declare method")
public void exchangeRedeclareDifferentType() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class);
ConnectionCloseBody response = interaction.exchange().declareType(ExchangeDefaults.TOPIC_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeclareWithUnknownAlternateExchange.
/**
* Qpid specific extension
*/
@Test
public void exchangeDeclareWithUnknownAlternateExchange() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
ConnectionCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declareArguments(Collections.singletonMap("alternateExchange", "notKnown")).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
// TODO server fails - jira required
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class QueueTest method queueDeclareExclusive.
@Test
@SpecificationTest(section = "1.7.2.1", description = "The client MAY NOT attempt to use a queue that was declared as exclusive by another " + "still-open connection.")
public void queueDeclareExclusive() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(true).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
ConnectionCloseBody closeResponse = interaction2.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
/* TODO: 0-91 specification requires 'resource-locked' (405) but server uses (530) */
assertThat(closeResponse.getReplyCode(), anyOf(equalTo(ErrorCodes.NOT_ALLOWED), equalTo(405)));
}
}
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
QueueDeclareOkBody response = interaction2.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class QueueTest method queueDeclareWithUnknownAlternateExchange.
/**
* Qpid specific extension
*/
@Test
public void queueDeclareWithUnknownAlternateExchange() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
ConnectionCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declareArguments(Collections.singletonMap("alternateExchange", "notKnown")).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
Aggregations