Architecture
proxymock utilizes a proxy to capture traffic to and from your application.
Get a feel for the shape your local system with various proxymock configurations:
- No Proxymock
- Record Mocks
- Record Tests
- Mock Server
- Load Generator
This is probably close what your setup looks like. A client making requests to
your app's API (listening on port 8080
in this case) and your app making
requests to various other services, APIs, databases, etc.
With proxymock we can transparently capture outbound traffic, the requests your app makes to other services and the associated responses. Once captured these are called mocks and are written to artifacts in a local directory.
Once the necessary env vars are set in the environment where "your app" is running outbound traffic from your app is routed through proxymock and captured in the process. Is is not necessary to modify your app.
With proxymock we can capture inbound traffic, the requests your client makes to your app the associated responses. Once captured these are called tests and are written to artifacts in a local directory.
Requests from the client are routed through proxymock and captured in the
process, but unlike outbound traffic where we can just set env vars the client
will need to target the proxy port instead of the app port. In this case that
means making requests to localhost:4143
instead of localhost:8080
.
Once proxymock has created mocks from outbound traffic it can be used as a mock server to respond to requests from your app. Mock signatures are generated from the mock artifacts captured earlier.
While dependencies can be fully replace by proxymock, there is a dotted line to indicate "passthrough", which is what happens when a request to the mock server does not match a signature. In that case the request is forwarded to the real resource.
Once proxymock has created tests from inbound traffic it can be used as a load generator to send one or many requests to your app. Requests are generated from the test artifacts captured earlier.
In this configuration the client is fully replaced by proxymock which makes
requests to your app on port 8080
.