Skip to content

Commit

Permalink
Added test for #10805 Zero Dynamic Table
Browse files Browse the repository at this point in the history
  • Loading branch information
gregw committed Feb 20, 2024
1 parent 80f4681 commit 1333e27
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,57 @@ public void onHeaders(Stream stream, HeadersFrame frame)

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

@ParameterizedTest
@CsvSource({"0,-1", "-1,0", "0,0"})
public void testMaxTableCapacityZero(int clientMaxCapacity, int serverMaxCapacity) throws Exception
{
start(new HttpServlet()
{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
resp.setStatus(200);
resp.getOutputStream().close();
}
});

if (clientMaxCapacity >= 0)
{
client.setMaxDecoderTableCapacity(0);
client.setMaxEncoderTableCapacity(0);
}
if (serverMaxCapacity >= 0)
{
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxEncoderTableCapacity(serverMaxCapacity);
connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).setMaxDecoderTableCapacity(serverMaxCapacity);
}

CountDownLatch serverPreface = new CountDownLatch(1);
Session session = newClient(new Session.Listener.Adapter()
{
@Override
public void onSettings(Session session, SettingsFrame frame)
{
serverPreface.countDown();
}
});
assertTrue(serverPreface.await(5, TimeUnit.SECONDS));

MetaData.Request metaData = newRequest("GET", new HttpFields());
HeadersFrame frame = new HeadersFrame(metaData, null, true);
CountDownLatch latch = new CountDownLatch(1);
session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter()
{
@Override
public void onHeaders(Stream stream, HeadersFrame frame)
{
MetaData.Response response = (MetaData.Response)frame.getMetaData();
assertEquals(200, response.getStatus());
latch.countDown();
}
});

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

0 comments on commit 1333e27

Please sign in to comment.