Skip to content

Commit

Permalink
Fixes #5931 - SslConnection should implement getBytesIn()/getBytesOut().
Browse files Browse the repository at this point in the history
Make sure the connection is closed before the assertions.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed May 30, 2021
1 parent f55fb60 commit 3d9b196
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ConnectionStatistics;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
Expand Down Expand Up @@ -1009,21 +1010,40 @@ public void testForcedNonDomainSNI() throws Exception
@Test
public void testBytesInBytesOut() throws Exception
{
CountDownLatch latch = new CountDownLatch(1);
SslContextFactory serverTLSFactory = createServerSslContextFactory();
startServer(serverTLSFactory, new EmptyServerHandler());
ConnectionStatistics serverStats = new ConnectionStatistics();
ConnectionStatistics serverStats = new ConnectionStatistics()
{
@Override
public void onClosed(Connection connection)
{
super.onClosed(connection);
latch.countDown();
}
};
connector.addManaged(serverStats);

SslContextFactory clientTLSFactory = createClientSslContextFactory();
startClient(clientTLSFactory);
ConnectionStatistics clientStats = new ConnectionStatistics();
ConnectionStatistics clientStats = new ConnectionStatistics()
{
@Override
public void onClosed(Connection connection)
{
super.onClosed(connection);
latch.countDown();
}
};
client.addManaged(clientStats);

ContentResponse response = client.newRequest("https://localhost:" + connector.getLocalPort())
.header(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString())
.send();
assertEquals(HttpStatus.OK_200, response.getStatus());

assertTrue(latch.await(5, TimeUnit.SECONDS));

assertThat(clientStats.getSentBytes(), Matchers.greaterThan(0L));
assertEquals(clientStats.getSentBytes(), serverStats.getReceivedBytes());
assertThat(clientStats.getReceivedBytes(), Matchers.greaterThan(0L));
Expand Down

0 comments on commit 3d9b196

Please sign in to comment.