I am trying to use http://ift.tt/1iJmeii to mock a REST service. My source code is trying to make a GET on: http://ift.tt/1Hi2RaD
I would like to mock this service. I have currently written in my code:
mockServer = startClientAndServer(1080);
proxy = startClientAndProxy(1090);
new MockServerClient("127.0.0.1", 1080)
.when(
request()
.withMethod("GET")
.withPath("/computeMetadata/v1/project/project-id"),
exactly(1)
)
.respond(
response()
.withStatusCode(200)
.withBody("the_project_id")
);
When I run the mock server client and I then the source code which makes the request, I am still getting a socket exception instead of the reply of the mock server. How can I fix my code to mock http://ift.tt/1Hi2RaD? I have fully read the mock-server documentation but I do not understand it very well.
Aucun commentaire:
Enregistrer un commentaire