use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queueBindUnknownQueue.
@Test
@SpecificationTest(section = "1.7.2.3", description = "The client MUST NOT attempt to bind a queue that does not exist.")
public void queueBindUnknownQueue() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
String testExchange = "testExchange";
final Interaction interaction = transport.newInteraction();
ChannelCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class MalformedMessageValidation method malformedHeaderValue.
@Test
public void malformedHeaderValue() throws Exception {
final FieldTable malformedHeader = createMalformedHeaders();
byte[] contentBytes = CONTENT_TEXT.getBytes(StandardCharsets.UTF_8);
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).contentHeaderPropertiesHeaders(malformedHeader).content(contentBytes).publishMessage().consumeResponse(ConnectionCloseBody.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 TransactionTimeoutTest method publishTransactionTimeout.
@Test
public void publishTransactionTimeout() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().contentHeaderPropertiesContentType("text/plain").contentHeaderPropertiesHeaders(Collections.singletonMap("test", "testValue")).contentHeaderPropertiesDeliveryMode((byte) 1).contentHeaderPropertiesPriority((byte) 1).publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content("Test").publishMessage().exchange().declarePassive(true).declare().consumeResponse(ExchangeDeclareOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
final ConnectionCloseBody close = interaction.consumeResponse().getLatestResponse(ConnectionCloseBody.class);
assertThat(close.getReplyCode(), is(equalTo(ErrorCodes.RESOURCE_ERROR)));
assertThat(close.getReplyText().toString(), containsString("transaction timed out"));
interaction.connection().closeOk();
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 ConnectionTest method authenticationBypassAfterSendingStartOk.
@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 authenticationBypassAfterSendingStartOk() throws Exception {
InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
try (FrameTransport transport = new FrameTransport(brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateProtocol().consumeResponse(ConnectionStartBody.class).connection().startOkMechanism(PLAIN).startOk().consumeResponse(ConnectionSecureBody.class).connection().tuneOk().connection().open().consumeResponse(ConnectionCloseBody.class, ChannelClosedResponse.class);
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class BasicTest method messagePersistence.
@Test
@SpecificationTest(section = "1.8", description = "The server SHOULD respect the persistent property of basic messages and SHOULD make a best " + "effort to hold persistent basic messages on a reliable storage mechanism.")
public void messagePersistence() throws Exception {
String queueName = "durableQueue";
String messageContent = "Test";
String messageContentType = "text/plain";
byte deliveryMode = (byte) 2;
Map<String, Object> messageHeaders = Collections.singletonMap("test", "testValue");
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(queueName).declareDurable(true).declare().consumeResponse(QueueDeclareOkBody.class).basic().contentHeaderPropertiesContentType(messageContentType).contentHeaderPropertiesHeaders(messageHeaders).contentHeaderPropertiesDeliveryMode(deliveryMode).publishExchange("").publishRoutingKey(queueName).content(messageContent).publishMessage().channel().close().consumeResponse(ChannelCloseOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(queueName), is(equalTo(1)));
}
assumeThat(getBrokerAdmin().supportsRestart(), Matchers.is(true));
getBrokerAdmin().restart();
assertThat(getBrokerAdmin().getQueueDepthMessages(queueName), is(equalTo(1)));
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().getQueueName(queueName).getNoAck(true).get().consumeResponse(BasicGetOkBody.class);
ContentHeaderBody header = interaction.consumeResponse().getLatestResponse(ContentHeaderBody.class);
ContentBody content = interaction.consumeResponse().getLatestResponse(ContentBody.class);
String receivedContent = getContent(content);
BasicContentHeaderProperties properties = header.getProperties();
assertThat(receivedContent, is(equalTo(messageContent)));
Map<String, Object> receivedHeaders = new HashMap<>(properties.getHeadersAsMap());
assertThat(receivedHeaders, is(equalTo(new HashMap<>(messageHeaders))));
assertThat(properties.getContentTypeAsString(), is(equalTo(messageContentType)));
assertThat(properties.getDeliveryMode(), is(equalTo(deliveryMode)));
interaction.channel().close().consumeResponse(ChannelCloseOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(queueName), is(equalTo(0)));
}
}
Aggregations