Search in sources :

Example 96 with Interaction

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

the class TransactionalTransferTest method sendTransactionalPostingReceiverSettlesSecond.

@Test
@SpecificationTest(section = "4.4.4", description = "Transactional Posting[...]the transaction controller wishes to associate an outgoing" + " transfer with a transaction, it MUST set the state of the transfer with a" + "transactional-state carrying the appropriate transaction identifier.")
public void sendTransactionalPostingReceiverSettlesSecond() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final UnsignedInteger linkHandle = UnsignedInteger.ONE;
        final Interaction interaction = transport.newInteraction();
        final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
        Disposition responseDisposition = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachHandle(linkHandle).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferHandle(linkHandle).transferPayloadData(TEST_MESSAGE_CONTENT).transferTransactionalState(txnState.getCurrentTransactionId()).transfer().consumeResponse(Disposition.class).getLatestResponse(Disposition.class);
        assertThat(responseDisposition.getRole(), is(Role.RECEIVER));
        assertThat(responseDisposition.getSettled(), is(Boolean.FALSE));
        assertThat(responseDisposition.getState(), is(instanceOf(TransactionalState.class)));
        assertThat(((TransactionalState) responseDisposition.getState()).getOutcome(), is(instanceOf(Accepted.class)));
        interaction.dispositionRole(Role.SENDER).dispositionSettled(true).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition();
        interaction.txnDischarge(txnState, false);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 97 with Interaction

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

the class OpenTest method failOpenOnChannelNotZero.

@Test
@SpecificationTest(section = "2.4.1", description = "The open frame can only be sent on channel 0. ยง2.7.1: A peer that receives a channel number outside the supported range MUST close the connection with the framing-error error-code.")
public void failOpenOnChannelNotZero() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        final Interaction interaction = transport.newInteraction();
        Open responseOpen = interaction.negotiateProtocol().consumeResponse().openContainerId("testContainerId").connectionChannel(UnsignedShort.valueOf((short) 1)).open().consumeResponse().getLatestResponse(Open.class);
        assertThat(responseOpen.getContainerId(), is(notNullValue()));
        Close responseClose = interaction.consumeResponse().getLatestResponse(Close.class);
        assertThat(responseClose.getError(), is(notNullValue()));
        assertThat(responseClose.getError().getCondition(), equalTo(ConnectionError.FRAMING_ERROR));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 98 with Interaction

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

the class OpenTest method emptyFrame.

@Test
@SpecificationTest(section = "2.4.5", description = "Implementations MUST be prepared to handle empty frames arriving on any valid channel")
public void emptyFrame() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction();
        interaction.negotiateProtocol().consumeResponse().openContainerId("testContainerId").open().consumeResponse(Open.class).emptyFrame().doCloseConnection();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 99 with Interaction

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

the class OpenTest method idleTimeout.

@Test
@SpecificationTest(section = "2.4.5", description = "Connections are subject to an idle timeout threshold.")
public void idleTimeout() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction();
        final int idleTimeOut = 1000;
        Open responseOpen = interaction.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openIdleTimeOut(idleTimeOut).open().consumeResponse().getLatestResponse(Open.class);
        final int peerIdleTimeOut = responseOpen.getIdleTimeOut().intValue();
        assertThat(peerIdleTimeOut, is(either(equalTo(0)).or(greaterThanOrEqualTo(idleTimeOut))));
        final long startTime = System.currentTimeMillis();
        interaction.consumeResponse(EmptyResponse.class);
        final long actualHeartbeatDelay = System.currentTimeMillis() - startTime;
        assertThat("Empty frame not received within expected time frame", ((int) actualHeartbeatDelay / 1000), is(both(greaterThanOrEqualTo(peerIdleTimeOut)).and(lessThanOrEqualTo(peerIdleTimeOut * 2))));
        if (peerIdleTimeOut > 0) {
            interaction.emptyFrame();
        }
        interaction.doCloseConnection();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 100 with Interaction

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

the class OpenTest method successfulOpen.

@Test
@SpecificationTest(section = "2.4.1", description = "Each AMQP connection begins with an exchange of capabilities and limitations, " + "including the maximum frame size.")
public void successfulOpen() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Interaction interaction = transport.newInteraction();
        Open responseOpen = interaction.negotiateProtocol().consumeResponse().openContainerId("testContainerId").open().consumeResponse().getLatestResponse(Open.class);
        assertThat(responseOpen.getContainerId(), is(notNullValue()));
        assertThat(responseOpen.getMaxFrameSize().longValue(), is(both(greaterThanOrEqualTo(0L)).and(lessThan(UnsignedInteger.MAX_VALUE.longValue()))));
        assertThat(responseOpen.getChannelMax().intValue(), is(both(greaterThanOrEqualTo(0)).and(lessThan(UnsignedShort.MAX_VALUE.intValue()))));
        interaction.doCloseConnection();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Test (org.junit.Test)112 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)101 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)100 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)91 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)53 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)48 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)33 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)31 InetSocketAddress (java.net.InetSocketAddress)28 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)28 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)28 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)28 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)24 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)16 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)13 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)12 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)12 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)11 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)10 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)10