|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.kristofa.test.http.LoggingHttpProxy
public class LoggingHttpProxy
Http proxy that supports logging requests/reponses. Its purpose is to be a 'man in the middle' which can be used to capture request/responses that can be mocked later on for testing purposes. It forwards requests it gets to another service and returns the result of that service unmodified to the requester. While doing that it also allows logging request/response pairs.
Those persisted request/response pairs can be mocked by MockHttpServer.
Using the LoggingHttpProxy to persist request/responses and using them with the MockHttpServer is
especially useful for complex responses that are not that easy to mock by hand. It allows building a hermetic server.
The LoggingHttpProxy will return following HTTP return codes when things go wrong:
ForwardHttpRequestBuilder.
| Constructor Summary | |
|---|---|
LoggingHttpProxy(int port,
Collection<ForwardHttpRequestBuilder> requestBuilders,
HttpRequestResponseLoggerFactory loggerFactory)
Create a new instance. |
|
| Method Summary | |
|---|---|
void |
start()
Starts proxy. |
void |
stop()
Stops proxy. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LoggingHttpProxy(int port,
Collection<ForwardHttpRequestBuilder> requestBuilders,
HttpRequestResponseLoggerFactory loggerFactory)
port - Port at which proxy will be running.requestBuilders - Forward request builders. Should not be null and at least 1 should be specified.loggerFactory - Request/Response logger factory.. Should not be null.| Method Detail |
|---|
public void start()
throws IOException
Exception - In case starting fails.
IOException
public void stop()
throws IOException
IOException - In case closing connection fails.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||