Search in sources :

Example 16 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class QueueTest method queueDeclareAutoDeleteAndExclusiveDeletedBySessionDetach.

@Test
@SpecificationTest(section = "10.queue.declare", description = "If this field [auto-delete] is set and the exclusive field is also set, then the queue " + "MUST be deleted when the session closes.")
public void queueDeclareAutoDeleteAndExclusiveDeletedBySessionDetach() 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).declareAutoDelete(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).session().detachName(SESSION_NAME).detach().consumeResponse(SessionDetached.class);
        ExecutionException response = interaction.channelId(2).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declarePassive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
        assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.NOT_FOUND)));
    }
}
Also used : ExecutionException(org.apache.qpid.server.protocol.v0_10.transport.ExecutionException) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 17 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class QueueTest method queuePurge.

@Test
@SpecificationTest(section = "10.queue.purge", description = "This command removes all messages from a queue.")
public void queuePurge() 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(1).query().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        assertThat(((QueueQueryResult) result.getValue()).getMessageCount(), is(1L));
        interaction.queue().purgeQueue(BrokerAdmin.TEST_QUEUE_NAME).purgeId(0).purge().session().flushCompleted().flush().consumeResponse(SessionFlush.class).consumeResponse(SessionCompleted.class);
        result = interaction.queue().queryQueue(BrokerAdmin.TEST_QUEUE_NAME).queryId(1).query().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        assertThat(((QueueQueryResult) result.getValue()).getMessageCount(), is(0L));
    }
}
Also used : SessionCompleted(org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted) ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) SessionFlush(org.apache.qpid.server.protocol.v0_10.transport.SessionFlush) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 18 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class SessionTest method detach.

@Test
@SpecificationTest(section = "9.session.detach", description = "Detaches the current transport from the named session.")
public void detach() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
        final int channelId = 1;
        SessionDetached sessionDetached = interaction.openAnonymousConnection().channelId(channelId).session().attachName(sessionName).attach().consumeResponse(SessionAttached.class).session().detachName(sessionName).detach().consumeResponse().getLatestResponse(SessionDetached.class);
        assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
        assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId));
    }
}
Also used : SessionAttached(org.apache.qpid.server.protocol.v0_10.transport.SessionAttached) SessionDetached(org.apache.qpid.server.protocol.v0_10.transport.SessionDetached) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 19 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class SessionTest method detachUnknownSession.

@Test
@SpecificationTest(section = "9.session", description = "The transport MUST be attached in order to use any control other than" + " \"attach\", \"attached\", \"detach\", or \"detached\"." + " A peer receiving any other control on a detached transport MUST discard it and send a" + " session.detached with the \"not-attached\" reason code.")
public void detachUnknownSession() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
        final int channelId = 1;
        SessionDetached sessionDetached = interaction.openAnonymousConnection().channelId(channelId).session().detachName(sessionName).detach().consumeResponse().getLatestResponse(SessionDetached.class);
        assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
        assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId));
    }
}
Also used : SessionDetached(org.apache.qpid.server.protocol.v0_10.transport.SessionDetached) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 20 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class BasicTest method publishUnrouteableMandatoryMessage.

@Test
@SpecificationTest(section = "1.8.3.7", description = "This flag [mandatory] tells the server how to react if the message cannot be routed to a " + "queue. If this flag is set, the server will return an unroutable message with a " + "Return method.")
public void publishUnrouteableMandatoryMessage() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        String messageContent = "Test";
        BasicReturnBody returned = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(true).content(messageContent).publishMessage().consumeResponse().getLatestResponse(BasicReturnBody.class);
        assertThat(returned.getReplyCode(), is(equalTo(ErrorCodes.NO_ROUTE)));
        ContentBody content = interaction.consumeResponse(ContentHeaderBody.class).consumeResponse().getLatestResponse(ContentBody.class);
        assertThat(getContent(content), is(equalTo(messageContent)));
        interaction.channel().close().consumeResponse(ChannelCloseOkBody.class);
    }
}
Also used : BasicReturnBody(org.apache.qpid.server.protocol.v0_8.transport.BasicReturnBody) ContentBody(org.apache.qpid.server.protocol.v0_8.transport.ContentBody) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)209 Test (org.junit.Test)209 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)106 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)82 InetSocketAddress (java.net.InetSocketAddress)52 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)52 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)45 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)37 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)35 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)29 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)28 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)28 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)26 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)22 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)19 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)16 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)15 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)14 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)14 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)14