Issue #7979 - add test for processes thrown & fix test expectations
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
6ef432ad25
commit
d51d78205c
|
@ -256,13 +256,13 @@ public class StatisticsHandler extends Handler.Wrapper
|
|||
@ManagedAttribute("number of requests that threw an exception during processing")
|
||||
public int getProcessThrows()
|
||||
{
|
||||
return _handleThrows.intValue();
|
||||
return _processThrows.intValue();
|
||||
}
|
||||
|
||||
@ManagedAttribute("")
|
||||
public int getHandlings()
|
||||
{
|
||||
return (int)_handleStats.getCurrent();
|
||||
return (int)_handleStats.getTotal();
|
||||
}
|
||||
|
||||
@ManagedAttribute("")
|
||||
|
|
|
@ -661,7 +661,7 @@ public class StatisticsHandlerTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testThrownResponse() throws Exception
|
||||
public void testThrownHandles() throws Exception
|
||||
{
|
||||
_statsHandler.setHandler(new Handler.Abstract(Invocable.InvocationType.BLOCKING)
|
||||
{
|
||||
|
@ -693,7 +693,48 @@ public class StatisticsHandlerTest
|
|||
assertEquals(0, _statsHandler.getResponses3xx());
|
||||
assertEquals(0, _statsHandler.getResponses4xx());
|
||||
assertEquals(0, _statsHandler.getResponses5xx());
|
||||
assertEquals(1, _statsHandler.getResponsesThrown());
|
||||
assertEquals(1, _statsHandler.getHandleThrows());
|
||||
assertEquals(0, _statsHandler.getProcessThrows());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThrownProcesses() throws Exception
|
||||
{
|
||||
_statsHandler.setHandler(new Handler.Abstract(Invocable.InvocationType.BLOCKING)
|
||||
{
|
||||
@Override
|
||||
public Request.Processor handle(Request request)
|
||||
{
|
||||
return (req, resp, cp) ->
|
||||
{
|
||||
throw new IllegalStateException("expected");
|
||||
};
|
||||
}
|
||||
});
|
||||
_server.start();
|
||||
|
||||
try (StacklessLogging ignored = new StacklessLogging(Response.class))
|
||||
{
|
||||
String request = "GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n";
|
||||
String response = _connector.getResponse(request);
|
||||
assertThat(response, containsString("HTTP/1.1 500 Server Error"));
|
||||
}
|
||||
|
||||
assertEquals(1, _statsHandler.getHandlings());
|
||||
assertEquals(1, _statsHandler.getRequests());
|
||||
assertEquals(0, _statsHandler.getRequestsActive());
|
||||
assertEquals(1, _statsHandler.getRequestsActiveMax());
|
||||
|
||||
// We get no recorded status, but we get a recorded thrown response.
|
||||
assertEquals(0, _statsHandler.getResponses1xx());
|
||||
assertEquals(0, _statsHandler.getResponses2xx());
|
||||
assertEquals(0, _statsHandler.getResponses3xx());
|
||||
assertEquals(0, _statsHandler.getResponses4xx());
|
||||
assertEquals(1, _statsHandler.getResponses5xx());
|
||||
assertEquals(0, _statsHandler.getHandleThrows());
|
||||
assertEquals(1, _statsHandler.getProcessThrows());
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue