2

I am trying to mock an external (REST) server used by my system under test. I am choosing MockServer (http://www.mock-server.com/) for mocking the external REST server.

I am running mock server standalone as in:

$ java -jar ./mockserver-netty-5.3.0-jar-with-dependencies.jar -serverPort 1080 -proxyPort 1090 -proxyRemotePort 80 -proxyRemoteHost www.mock-server.com 2018-05-23 14:05:57,703 INFO o.m.m.MockServer MockServer started on port: 1080 2018-05-23 14:05:57,747 INFO o.m.p.d.DirectProxy MockServer started on port: 1090

I am not sure, having read the documentation, where I should define the expectations (viz., the responses the mock should yield based on incoming requests).

Can anyone explain?

Thanx,

R

2 Answers2

2

It can be done by PUT, ie:

curl -v -X PUT "http://localhost:1080/expectation" -d '{
  "httpRequest" : {
    "path" : "/some/path"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'

More info https://www.mock-server.com/mock_server/creating_expectations.html and go for REST API type of expectation

Adrian
  • 482
  • 5
  • 20
0

I used Postman to create the expectation. For creating expectations send a PUT request to http://localhost:portnumber/mockserver/expectation. You can check the expectation and logs using this URL http://localhost:portnumber/mockserver/dashboard in the browser.

user2668276
  • 67
  • 13