Search in sources :

Example 21 with Interaction

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

the class RefuseConnectionPolicy method newConnectionRefused.

@Test
public void newConnectionRefused() throws Exception {
    try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction1 = transport1.newInteraction();
        interaction1.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse(Open.class);
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            final Open responseOpen2 = interaction2.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse().getLatestResponse(Open.class);
            assertThat(Arrays.asList(responseOpen2.getOfferedCapabilities()), hasItem(SOLE_CONNECTION_FOR_CONTAINER));
            assertThat(responseOpen2.getProperties(), hasKey(Symbol.valueOf("amqp:connection-establishment-failed")));
            assertThat(responseOpen2.getProperties().get(Symbol.valueOf("amqp:connection-establishment-failed")), is(true));
            final Close close2 = interaction2.consumeResponse().getLatestResponse(Close.class);
            assertThat(close2.getError(), is(notNullValue()));
            assertThat(close2.getError().getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
            assertThat(close2.getError().getInfo(), is(equalTo(Collections.singletonMap(Symbol.valueOf("invalid-field"), Symbol.valueOf("container-id")))));
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) 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)

Example 22 with Interaction

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

the class WebSocketTest method amqpFramesSplitOverManyWebSocketFrames.

@Test
@SpecificationTest(section = "2.4", description = "[...] a single AMQP frame MAY be split over one or more consecutive WebSocket messages. ")
public void amqpFramesSplitOverManyWebSocketFrames() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQPWS);
    try (FrameTransport transport = new WebSocketFrameTransport(addr).splitAmqpFrames().connect()) {
        Interaction interaction = transport.newInteraction();
        final Open responseOpen = interaction.negotiateProtocol().consumeResponse().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)

Example 23 with Interaction

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

the class DeleteOnCloseTest method deleteOnCloseOnTarget.

@Test
@SpecificationTest(section = "3.5.10", description = "A node dynamically created with this lifetime policy will be deleted at the point that the link which caused its\n" + "creation ceases to exist.")
public void deleteOnCloseOnTarget() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        Target target = new Target();
        target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
        target.setDynamic(true);
        final Interaction interaction = transport.newInteraction();
        final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
        assertThat(attachResponse.getTarget(), is(notNullValue()));
        final String newTempQueueAddress = ((Target) attachResponse.getTarget()).getAddress();
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
        interaction.consumeResponse().getLatestResponse(Flow.class);
        interaction.detachClose(true).detach().consumeResponse().getLatestResponse(Detach.class);
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(false));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) 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 24 with Interaction

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

the class DeleteOnCloseTest method doesNotDeleteOnDetach.

@Test
@SpecificationTest(section = "3.5.10", description = "A node dynamically created with this lifetime policy will be deleted at the point that the link which caused its\n" + "creation ceases to exist.")
public void doesNotDeleteOnDetach() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        Source source = new Source();
        source.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
        source.setDynamic(true);
        final Interaction interaction = transport.newInteraction();
        final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSource(source).attach().consumeResponse().getLatestResponse(Attach.class);
        assertThat(attachResponse.getSource(), is(notNullValue()));
        final String newTempQueueAddress = ((Source) attachResponse.getSource()).getAddress();
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
        interaction.detach().consumeResponse().getLatestResponse(Detach.class);
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) 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 25 with Interaction

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

the class MultiTransferTest method abortMultiTransferMessage.

// 
@Test
@SpecificationTest(section = "2.6.14", description = "The sender MAY indicate an aborted attempt to deliver a message by setting the abort flag on the last transfer." + "In this case the receiver MUST discard the message data that was transferred prior to the abort.")
public void abortMultiTransferMessage() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        QpidByteBuffer[] payloads = Utils.splitPayload("testData", 2);
        final UnsignedInteger deliveryId = UnsignedInteger.ZERO;
        final Binary deliveryTag = new Binary("testTransfer".getBytes(UTF_8));
        Interaction interaction = transport.newInteraction();
        interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(payloads[0]).transferDeliveryId(deliveryId).transferDeliveryTag(deliveryTag).transferMore(true).transfer().sync().transferPayload(null).transferMore(null).transferAborted(true).transfer();
        for (final QpidByteBuffer payload : payloads) {
            payload.dispose();
        }
        Response<?> latestResponse = interaction.consumeResponse(new Class<?>[] { null }).getLatestResponse();
        assertThat(latestResponse, is(nullValue()));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) 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