use of org.apache.qpid.server.protocol.v0_8.transport 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(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.negotiateOpen().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(getBrokerAdmin()).connect()) {
final Interaction interaction2 = transport2.newInteraction();
ConnectionCloseBody closeResponse = interaction2.negotiateOpen().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(getBrokerAdmin()).connect()) {
final Interaction interaction2 = transport2.newInteraction();
QueueDeclareOkBody response = interaction2.negotiateOpen().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 in project qpid-broker-j by apache.
the class QueueTest method topicExchangeInstancesAllowRebindWithDifferentArguments.
/**
* Qpid specific extension
*/
@Test
public void topicExchangeInstancesAllowRebindWithDifferentArguments() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
final String content = "content";
final String routingKey = "rk1";
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
final Map<String, Object> messageProps = Collections.singletonMap("prop", 0);
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).queue().bindName(ExchangeDefaults.TOPIC_EXCHANGE_NAME).bindRoutingKey(routingKey).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindArguments(Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "prop = 1")).bind().consumeResponse(QueueBindOkBody.class).basic().publishExchange(ExchangeDefaults.TOPIC_EXCHANGE_NAME).publishRoutingKey(routingKey).content(content).contentHeaderPropertiesHeaders(messageProps).publishMessage().tx().commit().consumeResponse(TxCommitOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
interaction.queue().bindName(ExchangeDefaults.TOPIC_EXCHANGE_NAME).bindRoutingKey(routingKey).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindArguments(Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "prop = 0")).bind().consumeResponse(QueueBindOkBody.class).basic().publishExchange(ExchangeDefaults.TOPIC_EXCHANGE_NAME).publishRoutingKey(routingKey).content(content).contentHeaderPropertiesHeaders(messageProps).publishMessage().tx().commit().consumeResponse(TxCommitOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queueDeclareAutoDeletePreexistingQueue.
@Test
@SpecificationTest(section = "1.7.2.1", description = "The server MUST ignore the auto-delete field if the queue already exists.")
@Ignore("The server does not ignore the auto-delete field if the queue already exists.")
public void queueDeclareAutoDeletePreexistingQueue() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.negotiateOpen().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))));
QueueDeclareOkBody passiveResponse = interaction.queue().declareAutoDelete(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(passiveResponse.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueDeclareInvalidOptionBehaviourTest method queueDeclareInvalidWireArguments.
@Test
public void queueDeclareInvalidWireArguments() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(TEST_QUEUE).declareArguments(Collections.singletonMap("foo", "bar")).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(TEST_QUEUE))));
assertThat(response.getMessageCount(), is(equalTo(0L)));
assertThat(response.getConsumerCount(), is(equalTo(0L)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class TransactionTimeoutTest method consumeTransactionTimeout.
@Test
public void consumeTransactionTimeout() throws Exception {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().qosPrefetchCount(1).qos().consumeResponse(BasicQosOkBody.class).channel().flow(true).consumeResponse(ChannelFlowOkBody.class).basic().consumeConsumerTag("A").consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consume().consumeResponse(BasicConsumeOkBody.class).consumeResponse(BasicDeliverBody.class);
BasicDeliverBody delivery = interaction.getLatestResponse(BasicDeliverBody.class);
interaction.consumeResponse(ContentHeaderBody.class).consumeResponse(ContentBody.class);
interaction.basic().ackDeliveryTag(delivery.getDeliveryTag()).ack().exchange().declarePassive(true).declare().consumeResponse(ExchangeDeclareOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
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(1)));
}
}
Aggregations