We should register a test extension that returns the MockServerClient to test classes for two reasons. Firstly, the test extension can be used to setup forwarding criteria via expectations: http://www.mock-server.com/mock_server/creating_expectations.html#button_forward_exactly. Secondly, the extension should return the MockServerClient so that the tests themselves can make expectations and verifications against the server themselves.
Alternatively, the Mockserver could belong to and be accessed by the existing engine and elasticsearch extensions.
- All requests to ES and Engine instances during tests are routed through the Mockserver. Rather than configuring port forwarding on startup, this might make more sense to do in Java based on request matches: http://www.mock-server.com/mock_server/creating_expectations.html#button_forward_exactly
- tests can access the MockServer Client to make verifications and assertions
- tests with multiple engines forward requests correctly
- After each test, existing expectations are removed and forwarding is reset