use of org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeclare.
@Test
@SpecificationTest(section = "10.exchange.declare", description = "verify exchange exists, create if needed.")
public void exchangeDeclare() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
SessionCompleted completed = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).exchange().declareExchange("myexch").declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareId(0).declare().session().flushCompleted().flush().consumeResponse().getLatestResponse(SessionCompleted.class);
assertThat(completed.getCommands().includes(0), is(equalTo(true)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted in project qpid-broker-j by apache.
the class QueueTest method queueDeclare.
@Test
@SpecificationTest(section = "10.queue.declare", description = "This command creates or checks a queue.")
public void queueDeclare() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
SessionCompleted completed = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declare().session().flushCompleted().flush().consumeResponse().getLatestResponse(SessionCompleted.class);
assertThat(completed.getCommands().includes(0), is(equalTo(true)));
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted in project qpid-broker-j by apache.
the class TransactionTest method messageSendCommit.
@Test
@SpecificationTest(section = "10.tx.commit", description = "This command commits all messages published and accepted in the current transaction.")
public void messageSendCommit() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
byte[] sessionName = "test".getBytes(UTF_8);
interaction.openAnonymousConnection().channelId(1).attachSession(sessionName).tx().selectId(0).select().message().transferDestination(BrokerAdmin.TEST_QUEUE_NAME).transferId(1).transfer().session().flushCompleted().flush();
SessionCompleted completed;
do {
completed = interaction.consumeResponse().getLatestResponse(SessionCompleted.class);
} while (!completed.getCommands().includes(1));
int queueDepthMessages = getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME);
assertThat(queueDepthMessages, is(equalTo(0)));
interaction.tx().commitId(2).commit().session().flushCompleted().flush();
completed = interaction.consumeResponse().getLatestResponse(SessionCompleted.class);
assertThat(completed.getCommands().includes(2), is(equalTo(true)));
queueDepthMessages = getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME);
assertThat(queueDepthMessages, is(equalTo(1)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted in project qpid-broker-j by apache.
the class TransactionTimeoutTest method publishTransactionTimeout.
@Test
public void publishTransactionTimeout() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
byte[] sessionName = "test".getBytes(UTF_8);
interaction.openAnonymousConnection().channelId(1).attachSession(sessionName).tx().selectId(0).select().message().transferDestination(BrokerAdmin.TEST_QUEUE_NAME).transferId(1).transfer().session().flushCompleted().flush();
SessionCompleted completed;
do {
completed = interaction.consumeResponse().getLatestResponse(SessionCompleted.class);
} while (!completed.getCommands().includes(1));
int queueDepthMessages = getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME);
assertThat(queueDepthMessages, is(equalTo(0)));
ConnectionClose close = receiveResponse(interaction, ConnectionClose.class);
assertThat(close.getReplyCode(), is(equalTo(ConnectionCloseCode.CONNECTION_FORCED)));
assertThat(close.getReplyText(), containsString("transaction timed out"));
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
}
Aggregations