New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Optionally Mocking Response or Forward Request #32
Comments
code implemented but still need to complete:
This should be completed be released by Sunday 18th. |
The code implementation and testing is complete and the new API has been released in version 2.10. The only remaining work is to update the documentation. The Java API is as follows: mockServerClient
.when(
request()
.withPath("/some_path")
.withBody(new StringBody("some_request_body", Body.Type.EXACT)),
exactly(3)
)
.forward(
forward()
.withHost("some_host")
.withPort(9090)
.withScheme(HttpForward.Scheme.HTTPS)
); The scheme defaults to HTTP if not specified. The JSON API is as follows: {
"httpRequest" : {
"method" : "someMethod",
"url" : "http://www.example.com",
"path" : "/some_path",
"body" : {
"type" : "EXACT",
"value" : "some_request_body"
}
},
"httpForward" : {
"host" : "some_host",
"port" : 9090,
"scheme" : "HTTPS" },
"times" : {
"remainingTimes" : 3,
"unlimited" : false
}
} |
closing issue and opening another issue for documentation |
Request from Wilfred van der Deijl:
"Hi James. We've been using MockServer at a large client in the Netherlands for mocking (soap) web services when unit testing compound services that are supposed to invoke other services. This works great and we love the mechanism of selecting certain requests eligible for mocking. Developers run with a local MockServer, but testers want to use the central Service Bus that points to a single central MockServer installation. The configure this with a number of REST calls prior to performing their (soapUI) tests. This works fine but we want to take the next step in testing web userinterface that invoke (soap) services. Sometimes testers want to run the UI against "real" services and sometimes against MockServer. We're looking for a way to change this dynamically and preferably per request. I've been thinking about setting up MockProxy and have it forward certain requests to MockServer and certain requests to the "real" server. We could use the already great system of selecting requests. The only thing is that MockProxy doesn't support forwarding/rewriting requests to other origin servers than what was requested by the client. I hope I could explain what we're looking for. Is this something that is on your roadmap or are you willing to accept this as a contribution from our side?"
Response:
"Hi Wilfred, I'm happy to look into this as there is a proxy in the MockServer that is currently used to record requests while making requests to a real endpoint. I'm fairly sure I can connect the two parts together. To be honest I'm just had a quick look and it looks like a fairly straight forward addition if done in the correct way. I'll see what I can do I might be able to have this completed and released by the end of the weekend. If not mid next week should be doable."
The text was updated successfully, but these errors were encountered: