use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class QueueTest method queueDeclareRedeclareOfExclusivelyDeclaredQueue.
@Test
@SpecificationTest(section = "10.queue.declare", description = "If the server receives a declare, bind, consume or get request for a queue that has been" + "declared as exclusive by an existing client session, it MUST raise an exception.")
public void queueDeclareRedeclareOfExclusivelyDeclaredQueue() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
ExecutionException response = interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.RESOURCE_LOCKED)));
}
}
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class QueueTest method queueDeleteQueueNotFound.
@Test
@SpecificationTest(section = "10.queue.delete", description = "The queue must exist. If the client attempts to delete a non-existing queue the server " + "MUST raise an exception.")
public void queueDeleteQueueNotFound() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
ExecutionException response = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().deleteQueue(BrokerAdmin.TEST_QUEUE_NAME).deleteId(0).delete().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.NOT_FOUND)));
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class QueueTest method queueDeclareAttemptedConsumeOfExclusivelyDeclaredQueue.
@Test
@SpecificationTest(section = "10.queue.declare", description = "If the server receives a declare, bind, consume or get request for a queue that has been" + "declared as exclusive by an existing client session, it MUST raise an exception.")
public void queueDeclareAttemptedConsumeOfExclusivelyDeclaredQueue() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
ExecutionException response = interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).message().subscribeDestination("mysub").subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(0).subscribe().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.RESOURCE_LOCKED)));
}
}
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).message().subscribeDestination("mysub").subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(0).subscribe().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class QueueTest method queueDeclarePassiveQueueNotFound.
@Test
@SpecificationTest(section = "10.queue.declare", description = "[...] If the queue does not exist, the server treats this as a failure.")
public void queueDeclarePassiveQueueNotFound() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
ExecutionException response = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declarePassive(true).declareId(0).declare().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.NOT_FOUND)));
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class QueueTest method queueQuery.
@Test
@SpecificationTest(section = "10.queue.query", description = "This command requests information about a queue.")
public void queueQuery() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
ExecutionResult result = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().queryQueue(BrokerAdmin.TEST_QUEUE_NAME).queryId(0).query().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
QueueQueryResult queryResult = (QueueQueryResult) result.getValue();
assertThat(queryResult.getQueue(), is(equalTo(BrokerAdmin.TEST_QUEUE_NAME)));
assertThat(queryResult.getAlternateExchange(), is(nullValue()));
assertThat(queryResult.getMessageCount(), is(1L));
}
}
Aggregations