use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queueBindWithoutRoutingKey.
@Test
@SpecificationTest(section = "1.7.2.3", description = "If the queue name is provided but the routing key is empty," + " the server does the binding with that empty routing key.")
public void queueBindWithoutRoutingKey() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
String testExchange = "testExchange";
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse(QueueBindOkBody.class);
ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(testExchange).boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundRoutingKey("").bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class AuthenticationTimeoutTest method authenticationTimeout.
@Test
public void authenticationTimeout() throws Exception {
assumeThat(getBrokerAdmin().isSASLMechanismSupported("PLAIN"), is(true));
try (FrameTransport transport = new FrameTransport(getBrokerAdmin(), BrokerAdmin.PortType.AMQP).connect()) {
final Interaction interaction = transport.newInteraction();
final ConnectionStartBody start = interaction.negotiateProtocol().consumeResponse().getLatestResponse(ConnectionStartBody.class);
assertThat(Arrays.asList(new String(start.getMechanisms()).split(" ")), hasItem("PLAIN"));
interaction.connection().startOkMechanism("PLAIN").startOk().consumeResponse(ConnectionSecureBody.class);
transport.assertNoMoreResponsesAndChannelClosed();
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class ExchangeDeclareInvalidOptionBehaviourTest method exchangeDeclareInvalidWireArguments.
@Test
public void exchangeDeclareInvalidWireArguments() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declareArguments(Collections.singletonMap("foo", "bar")).declare().consumeResponse(ExchangeDeclareOkBody.class);
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class MaximumMessageSizeTest method limitExceeded.
@Test
public void limitExceeded() throws Exception {
String content = Stream.generate(() -> String.valueOf('.')).limit(1001).collect(Collectors.joining());
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().contentHeaderPropertiesContentType("text/plain").contentHeaderPropertiesDeliveryMode((byte) 1).contentHeaderPropertiesPriority((byte) 1).publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content(content).publishMessage();
ChannelCloseBody channelClose = interaction.consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(channelClose.getReplyCode(), is(equalTo(ErrorCodes.MESSAGE_TOO_LARGE)));
interaction.channel().closeOk().connection().close().consumeResponse(ConnectionCloseOkBody.class, ChannelClosedResponse.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport 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(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().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)));
}
}
Aggregations