Search in sources :

Example 61 with FrameTransport

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

the class FlowTest method synchronousGetWithTimeoutEmptyQueue.

@Test
@SpecificationTest(section = "2.6.8", description = "Synchronous get with a timeout is accomplished by incrementing the link-credit," + " sending the updated flow state and waiting for the link-credit to be consumed." + " When the desired time has elapsed the receiver then sets the drain flag and sends" + " the newly updated flow state again, while continuing to wait for the link-credit" + " to be consumed.")
public void synchronousGetWithTimeoutEmptyQueue() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class);
        Attach remoteAttach = interaction.getLatestResponse(Attach.class);
        UnsignedInteger remoteHandle = remoteAttach.getHandle();
        assertThat(remoteHandle, is(notNullValue()));
        Flow responseFlow = interaction.flowIncomingWindow(UnsignedInteger.valueOf(1)).flowNextIncomingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.FALSE).flowEcho(Boolean.TRUE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
        assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
        assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ONE)));
        assertThat(responseFlow.getDrain(), is(equalTo(Boolean.FALSE)));
        responseFlow = interaction.flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.TRUE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
        assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
        assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 62 with FrameTransport

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

the class FlowTest method synchronousGetWithTimeoutNonEmptyQueue.

@Test
@SpecificationTest(section = "2.6.8", description = "Synchronous get with a timeout is accomplished by incrementing the link-credit," + " sending the updated flow state and waiting for the link-credit to be consumed." + " When the desired time has elapsed the receiver then sets the drain flag and sends" + " the newly updated flow state again, while continuing to wait for the link-credit" + " to be consumed.")
public void synchronousGetWithTimeoutNonEmptyQueue() throws Exception {
    BrokerAdmin brokerAdmin = getBrokerAdmin();
    brokerAdmin.createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    String messageContent = "Test";
    brokerAdmin.putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageContent);
    final InetSocketAddress addr = brokerAdmin.getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class);
        Attach remoteAttach = interaction.getLatestResponse(Attach.class);
        UnsignedInteger remoteHandle = remoteAttach.getHandle();
        assertThat(remoteHandle, is(notNullValue()));
        Object receivedMessageContent = interaction.flowIncomingWindow(UnsignedInteger.valueOf(1)).flowNextIncomingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.FALSE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().receiveDelivery().decodeLatestDelivery().getDecodedLatestDelivery();
        assertThat(receivedMessageContent, is(equalTo(messageContent)));
        assertThat(interaction.getLatestDeliveryId(), is(equalTo(UnsignedInteger.ZERO)));
        Flow responseFlow = interaction.flowNextIncomingId(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.TRUE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
        assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
        assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) BrokerAdmin(org.apache.qpid.tests.utils.BrokerAdmin) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 63 with FrameTransport

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

the class FlowTest method stoppingALink.

@Test
@SpecificationTest(section = "2.6.10", description = "Stopping the transfers on a given link is accomplished by updating the link-credit" + " to be zero and sending the updated flow state. [...]" + " The echo field of the flow frame MAY be used to request the sender’s flow state" + " be echoed back. This MAY be used to determine when the link has finally quiesced.")
public void stoppingALink() throws Exception {
    BrokerAdmin brokerAdmin = getBrokerAdmin();
    brokerAdmin.createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    String messageContent1 = "Test1";
    String messageContent2 = "Test2";
    brokerAdmin.putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageContent1);
    brokerAdmin.putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageContent2);
    final InetSocketAddress addr = brokerAdmin.getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class);
        Attach remoteAttach = interaction.getLatestResponse(Attach.class);
        UnsignedInteger remoteHandle = remoteAttach.getHandle();
        assertThat(remoteHandle, is(notNullValue()));
        Object receivedMessageContent1 = interaction.flowIncomingWindow(UnsignedInteger.valueOf(2)).flowNextIncomingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().decodeLatestDelivery().getDecodedLatestDelivery();
        assertThat(receivedMessageContent1, is(equalTo(messageContent1)));
        assertThat(interaction.getLatestDeliveryId(), is(equalTo(UnsignedInteger.ZERO)));
        Flow responseFlow = interaction.flowNextIncomingId(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ZERO).flowHandleFromLinkHandle().flowEcho(Boolean.TRUE).flow().consumeResponse().getLatestResponse(Flow.class);
        assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
        assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) BrokerAdmin(org.apache.qpid.tests.utils.BrokerAdmin) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 64 with FrameTransport

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

the class AuthenticationTimeoutTest method authenticationTimeout.

@Test
public void authenticationTimeout() throws Exception {
    InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
    try (FrameTransport transport = new FrameTransport(brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final ConnectionStart start = interaction.negotiateProtocol().consumeResponse().consumeResponse().getLatestResponse(ConnectionStart.class);
        assertThat(start.getMechanisms(), CoreMatchers.hasItem("PLAIN"));
        transport.assertNoMoreResponsesAndChannelClosed();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_10.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v0_10.Interaction) ConnectionStart(org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart) Test(org.junit.Test)

Example 65 with FrameTransport

use of org.apache.qpid.tests.protocol.v1_0.FrameTransport 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

Test (org.junit.Test)136 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)125 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)116 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)101 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)57 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)57 InetSocketAddress (java.net.InetSocketAddress)45 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)39 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)37 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)35 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)32 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)29 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)24 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)18 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)16 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)16 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)14 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)11 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)11 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)10