public class MockHttpApiRule extends org.junit.rules.ExternalResource
Rule
that manages a simple http server. The caller registers request
handlers to URI path regexp.Modifier and Type | Class and Description |
---|---|
private static class |
MockHttpApiRule.MockHandler |
Modifier and Type | Field and Description |
---|---|
private MockHttpApiRule.MockHandler |
handler |
private static org.slf4j.Logger |
LOG |
private org.eclipse.jetty.server.Server |
server |
Constructor and Description |
---|
MockHttpApiRule() |
Modifier and Type | Method and Description |
---|---|
MockHttpApiRule |
addRegistration(String pathRegex,
BiConsumer<String,javax.servlet.http.HttpServletResponse> responder)
Register a callback handler for the specified path target.
|
protected void |
after() |
protected void |
before() |
private static org.eclipse.jetty.server.RequestLog |
buildRequestLog() |
void |
clearRegistrations() |
URI |
getURI()
Retrieve the service URI for this service.
|
MockHttpApiRule |
registerOk(String pathRegex,
String responseBody)
Shortcut method for calling
addRegistration(String, BiConsumer) with a 200 response. |
private static final org.slf4j.Logger LOG
private MockHttpApiRule.MockHandler handler
private org.eclipse.jetty.server.Server server
public MockHttpApiRule()
public MockHttpApiRule addRegistration(String pathRegex, BiConsumer<String,javax.servlet.http.HttpServletResponse> responder)
public MockHttpApiRule registerOk(String pathRegex, String responseBody)
addRegistration(String, BiConsumer)
with a 200 response.public void clearRegistrations()
protected void before() throws Exception
before
in class org.junit.rules.ExternalResource
Exception
protected void after()
after
in class org.junit.rules.ExternalResource
private static org.eclipse.jetty.server.RequestLog buildRequestLog()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.