Code review comment: Agreed to merge in offline discussion

Code before review:
public void requireThatConnectionIsClosedAfterXRequests() throws Exception {
final int MAX_REQUESTS = 10;
Path privateKeyFile = tmpFolder.newFile().toPath();
Path certificateFile = tmpFolder.newFile().toPath();
generatePrivateKeyAndCertificate(privateKeyFile, certificateFile);
ConnectorConfig.Builder connectorConfig = new ConnectorConfig.Builder()
.maxRequestsPerConnection(MAX_REQUESTS)
.ssl(new ConnectorConfig.Ssl.Builder()
.enabled(true)
.clientAuth(ConnectorConfig.Ssl.ClientAuth.Enum.NEED_AUTH)
.privateKeyFile(privateKeyFile.toString())
.certificateFile(certificateFile.toString())
.caCertificateFile(certificateFile.toString()));
ServerConfig.Builder serverConfig = new ServerConfig.Builder()
.connectionLog(new ServerConfig.ConnectionLog.Builder().enabled(true));
JettyTestDriver driver = JettyTestDriver.newConfiguredInstance(
new EchoRequestHandler(),
serverConfig,
connectorConfig,
binder -> {});
for (int i = 0; i < MAX_REQUESTS - 1; i++) {
driver.client().get("/status.html")
.expectStatusCode(is(OK))
.expectNoHeader(CONNECTION);
}
driver.client().get("/status.html")
.expectStatusCode(is(OK))
.expectHeader(CONNECTION, is(CLOSE));
try (CloseableHttpAsyncClient client = createHttp2Client(driver)) {
String uri = "https:
for (int i = 0; i < MAX_REQUESTS - 1; i++) {
SimpleHttpResponse response = client.execute(SimpleRequestBuilder.get(uri).build(), null).get();
assertEquals(OK, response.getCode());
}
try {
client.execute(SimpleRequestBuilder.get(uri).build(), null).get();
fail();
} catch (ExecutionException e) {
assertEquals(e.getMessage(), "org.apache.hc.core5.http2.H2StreamResetException: Stream refused");
}
}
assertTrue(driver.close());
}


Code after addressing the review:
public void requireThatConnectionIsClosedAfterXRequests() throws Exception {
final int MAX_REQUESTS = 10;
Path privateKeyFile = tmpFolder.newFile().toPath();
Path certificateFile = tmpFolder.newFile().toPath();
generatePrivateKeyAndCertificate(privateKeyFile, certificateFile);
ConnectorConfig.Builder connectorConfig = new ConnectorConfig.Builder()
.maxRequestsPerConnection(MAX_REQUESTS)
.ssl(new ConnectorConfig.Ssl.Builder()
.enabled(true)
.clientAuth(ConnectorConfig.Ssl.ClientAuth.Enum.NEED_AUTH)
.privateKeyFile(privateKeyFile.toString())
.certificateFile(certificateFile.toString())
.caCertificateFile(certificateFile.toString()));
ServerConfig.Builder serverConfig = new ServerConfig.Builder()
.connectionLog(new ServerConfig.ConnectionLog.Builder().enabled(true));
JettyTestDriver driver = JettyTestDriver.newConfiguredInstance(
new EchoRequestHandler(),
serverConfig,
connectorConfig,
binder -> {});
for (int i = 0; i < MAX_REQUESTS - 1; i++) {
driver.client().get("/status.html")
.expectStatusCode(is(OK))
.expectNoHeader(CONNECTION);
}
driver.client().get("/status.html")
.expectStatusCode(is(OK))
.expectHeader(CONNECTION, is(CLOSE));
try (CloseableHttpAsyncClient client = createHttp2Client(driver)) {
String uri = "https:
for (int i = 0; i < MAX_REQUESTS - 1; i++) {
SimpleHttpResponse response = client.execute(SimpleRequestBuilder.get(uri).build(), null).get();
assertEquals(OK, response.getCode());
}
try {
client.execute(SimpleRequestBuilder.get(uri).build(), null).get();
fail();
} catch (ExecutionException e) {
assertEquals(e.getMessage(), "org.apache.hc.core5.http2.H2StreamResetException: Stream refused");
}
}
assertTrue(driver.close());
}