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;
}
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)));
}
}
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);
}
}
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);
}
}
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)));
}
}
Aggregations