use of org.eclipse.jetty.http2.frames.ResetFrame in project jetty.project by eclipse.
the class HttpClientTransportOverHTTP2Test method testRequestAbortSendsResetFrame.
@Test
public void testRequestAbortSendsResetFrame() throws Exception {
CountDownLatch resetLatch = new CountDownLatch(1);
start(new ServerSessionListener.Adapter() {
@Override
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame) {
return new Stream.Listener.Adapter() {
@Override
public void onReset(Stream stream, ResetFrame frame) {
resetLatch.countDown();
}
};
}
});
try {
client.newRequest("localhost", connector.getLocalPort()).onRequestCommit(request -> request.abort(new Exception("explicitly_aborted_by_test"))).send();
Assert.fail();
} catch (ExecutionException x) {
Assert.assertTrue(resetLatch.await(5, TimeUnit.SECONDS));
}
}
use of org.eclipse.jetty.http2.frames.ResetFrame in project jetty.project by eclipse.
the class HttpClientTransportOverHTTP2Test method testConnectionIdleTimeoutSendsResetFrame.
@Test
public void testConnectionIdleTimeoutSendsResetFrame() throws Exception {
long idleTimeout = 1000;
CountDownLatch resetLatch = new CountDownLatch(1);
start(new ServerSessionListener.Adapter() {
@Override
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame) {
return new Stream.Listener.Adapter() {
@Override
public void onReset(Stream stream, ResetFrame frame) {
resetLatch.countDown();
}
};
}
});
client.stop();
client.setIdleTimeout(idleTimeout);
client.start();
try {
client.newRequest("localhost", connector.getLocalPort()).idleTimeout(2 * idleTimeout, TimeUnit.MILLISECONDS).send();
Assert.fail();
} catch (ExecutionException e) {
// Expected.
}
Assert.assertTrue(resetLatch.await(5, TimeUnit.SECONDS));
}
Aggregations