Skip to content

Commit

Permalink
Fix #10229 EE10 Idle Timeout
Browse files Browse the repository at this point in the history
Added test that idle works between requests
  • Loading branch information
gregw committed Aug 4, 2023
1 parent fe1aabc commit 3cb3b7a
Showing 1 changed file with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class ServletTest
{
Expand Down Expand Up @@ -79,7 +80,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
}

@Test
public void testSimpleIdle() throws Exception
public void testSimpleIdleIgnored() throws Exception
{
_context.addServlet(new HttpServlet()
{
Expand Down Expand Up @@ -108,4 +109,41 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
assertThat(response, containsString(" 200 OK"));
assertThat(response, containsString("Hello!"));
}

@Test
public void testIdle() throws Exception
{
_context.addServlet(new HttpServlet()
{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
resp.getWriter().println("Hello!");
}
}, "/get");

_connector.setIdleTimeout(250);
_server.start();

try (LocalConnector.LocalEndPoint endPoint = _connector.connect())
{
String request = """
GET /ctx/get HTTP/1.1
Host: local
""";
endPoint.addInput(request);
String response = endPoint.getResponse();
assertThat(response, containsString(" 200 OK"));
assertThat(response, containsString("Hello!"));
endPoint.addInput(request);
response = endPoint.getResponse();
assertThat(response, containsString(" 200 OK"));
assertThat(response, containsString("Hello!"));

Thread.sleep(500);

assertFalse(endPoint.isOpen());
}
}
}

0 comments on commit 3cb3b7a

Please sign in to comment.