Search in sources :

Example 6 with SessionCompleted

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)));
    }
}
Also used : SessionCompleted(org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 7 with SessionCompleted

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)));
    }
}
Also used : SessionCompleted(org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 8 with SessionCompleted

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)));
    }
}
Also used : SessionCompleted(org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 9 with SessionCompleted

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)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_10.FrameTransport) SessionCompleted(org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted) Interaction(org.apache.qpid.tests.protocol.v0_10.Interaction) ConnectionClose(org.apache.qpid.server.protocol.v0_10.transport.ConnectionClose) Test(org.junit.Test)

Aggregations

SessionCompleted (org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted)9 Test (org.junit.Test)9 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)7 MessageTransfer (org.apache.qpid.server.protocol.v0_10.transport.MessageTransfer)3 RangeSet (org.apache.qpid.server.protocol.v0_10.transport.RangeSet)3 ConnectionClose (org.apache.qpid.server.protocol.v0_10.transport.ConnectionClose)2 FrameTransport (org.apache.qpid.tests.protocol.v0_10.FrameTransport)2 Interaction (org.apache.qpid.tests.protocol.v0_10.Interaction)2 Acquired (org.apache.qpid.server.protocol.v0_10.transport.Acquired)1 ExecutionResult (org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult)1 SessionCommandPoint (org.apache.qpid.server.protocol.v0_10.transport.SessionCommandPoint)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1