Search in sources :

Example 81 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class AsyncTransactionTest method createConsumerInteraction.

private Interaction createConsumerInteraction(final FrameTransport transport) throws Exception {
    final Interaction interaction = transport.newInteraction();
    interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().qosPrefetchCount(MESSAGE_COUNT).qos().consumeResponse(BasicQosOkBody.class).channel().flow(true).consumeResponse(ChannelFlowOkBody.class).basic().consumeConsumerTag("A").consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consume().consumeResponse(BasicConsumeOkBody.class);
    return interaction;
}
Also used : Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) ChannelFlowOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelFlowOkBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)

Example 82 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class ConnectionTest method connectionStartOkUnsupportedMechanism.

@Test
@SpecificationTest(section = "1.4.2.2", description = "If the mechanism field does not contain one of the security mechanisms proposed by the " + "server in the Start method, the server MUST close the connection without sending any " + "further data.")
public void connectionStartOkUnsupportedMechanism() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateProtocol().consumeResponse(ConnectionStartBody.class).connection().startOkMechanism("NOT-A-MECHANISM").startOk();
        final ConnectionCloseBody res = interaction.consumeResponse().getLatestResponse(ConnectionCloseBody.class);
        assertThat(res.getReplyCode(), is(equalTo(ErrorCodes.CONNECTION_FORCED)));
    }
}
Also used : ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) ConnectionStartBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 83 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class ConnectionTest method heartbeatingNoIncomingTraffic.

@Test
@SpecificationTest(section = "4.2.7", description = " If a peer detects no incoming traffic (i.e. received octets) for two heartbeat intervals " + "or longer, it should close the connection without following the Connection.Close/Close-Ok handshaking")
public void heartbeatingNoIncomingTraffic() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionTuneBody response = interaction.authenticateConnection().getLatestResponse(ConnectionTuneBody.class);
        final Long heartbeatPeriod = 1L;
        interaction.connection().tuneOkChannelMax(response.getChannelMax()).tuneOkFrameMax(response.getFrameMax()).tuneOkHeartbeat(heartbeatPeriod.intValue()).tuneOk().connection().open().consumeResponse(ConnectionOpenOkBody.class).consumeResponse(HeartbeatBody.class);
        // Do not reflect a heartbeat so incoming line will be silent thus
        // requiring the broker to close the connection.
        Class[] classes = new Class[] { ChannelClosedResponse.class, HeartbeatBody.class };
        do {
            Response<?> latestResponse = interaction.consumeResponse(classes).getLatestResponse();
            if (latestResponse instanceof ChannelClosedResponse) {
                break;
            }
            classes = new Class[] { ChannelClosedResponse.class };
        } while (true);
    }
}
Also used : HeartbeatBody(org.apache.qpid.server.protocol.v0_8.transport.HeartbeatBody) ConnectionTuneBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody) ChannelClosedResponse(org.apache.qpid.tests.protocol.ChannelClosedResponse) ConnectionOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 84 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class ConnectionTest method heartbeatingIncomingTrafficIsNonHeartbeat.

@Test
@SpecificationTest(section = "4.2.7", description = "Any sent octet is a valid substitute for a heartbeat")
public void heartbeatingIncomingTrafficIsNonHeartbeat() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionTuneBody response = interaction.authenticateConnection().getLatestResponse(ConnectionTuneBody.class);
        final Long heartbeatPeriod = 1L;
        interaction.connection().tuneOkChannelMax(response.getChannelMax()).tuneOkFrameMax(response.getFrameMax()).tuneOkHeartbeat(heartbeatPeriod.intValue()).tuneOk().connection().open().consumeResponse(ConnectionOpenOkBody.class).channel().open().consumeResponse(ChannelOpenOkBody.class).consumeResponse(HeartbeatBody.class).exchange().declarePassive(true).declareNoWait(true).declare().consumeResponse(HeartbeatBody.class).sendPerformative(new HeartbeatBody()).exchange().declarePassive(true).declareNoWait(true).declare();
        interaction.connection().close().consumeResponse().getLatestResponse(ConnectionCloseOkBody.class);
    }
}
Also used : HeartbeatBody(org.apache.qpid.server.protocol.v0_8.transport.HeartbeatBody) ConnectionTuneBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 85 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class MalformedMessageTest method publishMalformedMessageToQueueBoundWithSelector.

@Test
public void publishMalformedMessageToQueueBoundWithSelector() throws Exception {
    final FieldTable malformedHeader = createMalformedHeadersWithMissingValue("prop");
    final BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setHeaders(malformedHeader);
    basicContentHeaderProperties.setContentType("text/plain");
    basicContentHeaderProperties.setDeliveryMode(BasicContentHeaderProperties.PERSISTENT);
    byte[] contentBytes = CONTENT_TEXT.getBytes(StandardCharsets.UTF_8);
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().bindName(ExchangeDefaults.TOPIC_EXCHANGE_NAME).bindRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindArguments(Collections.singletonMap(AMQPFilterTypes.JMS_SELECTOR.getValue(), "prop = 1")).bind().consumeResponse(QueueBindOkBody.class).basic().publishExchange(ExchangeDefaults.TOPIC_EXCHANGE_NAME).publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).contentHeaderPropertiesHeaders(malformedHeader).content(contentBytes).publishMessage().consumeResponse().getLatestResponse(ChannelClosedResponse.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) FieldTable(org.apache.qpid.server.protocol.v0_8.FieldTable) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)88 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)72 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)44 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)32 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)21 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)20 Matchers.emptyString (org.hamcrest.Matchers.emptyString)18 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)17 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)15 ConnectionCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody)13 ConnectionTuneBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody)12 ExchangeBoundOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody)11 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)11 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)9 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)8 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)8 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)8 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)7 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)7 BasicQosOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody)6