use of org.apache.qpid.server.protocol.v0_10.transport.ConnectionHeartbeat in project qpid-broker-j by apache.
the class ConnectionTest method heartbeatingIncomingIdle.
@Test
@SpecificationTest(section = "9.connection", description = "If a connection is idle for more than twice the negotiated heartbeat delay, the peers MAY " + "be considered disconnected.")
public void heartbeatingIncomingIdle() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ConnectionTune response = interaction.authenticateConnection().getLatestResponse(ConnectionTune.class);
assumeThat(response.hasHeartbeatMin(), is(true));
assumeThat(response.hasHeartbeatMax(), is(true));
assumeThat(response.getHeartbeatMin(), is(greaterThanOrEqualTo(0)));
assumeThat(response.getHeartbeatMax(), is(greaterThanOrEqualTo(1)));
final int heartbeatPeriod = 1;
interaction.connection().tuneOkChannelMax(response.getChannelMax()).tuneOkMaxFrameSize(response.getMaxFrameSize()).tuneOkHeartbeat(heartbeatPeriod).tuneOk().connection().open().consumeResponse(ConnectionOpenOk.class);
interaction.consumeResponse().getLatestResponse(ConnectionHeartbeat.class);
// the server might be able to send two heartbeats
Response latestResponse = interaction.consumeResponse().getLatestResponse();
if (latestResponse != null && latestResponse.getBody() instanceof ConnectionHeartbeat) {
latestResponse = interaction.consumeResponse().getLatestResponse();
}
assertThat(latestResponse, instanceOf(ChannelClosedResponse.class));
}
}
Aggregations