0

I am trying to mock my ServiceA using Wiremock. But seems like there is some setup missing . I am getting this error :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /__files/serviceA/endpointA Reason:
<pre>    Not Found</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.4.v20170414</a><hr/>

</body>
</html>

404 mean that its not finding the endpoint location.

Are there any step by step tutorial that can explain how to setup the service?

Thanks.

1 Answer 1

3

There some different ways:

  1. run the standalone process from the command line: java -jar wiremock-standalone-2.8.0.jar (see http://wiremock.org/docs/running-standalone/)
  2. create a simple maven project with following dependency:

    <dependency>
        <groupId>com.github.tomakehurst</groupId>
        <artifactId>wiremock</artifactId>
        <version>2.8.0</version>
    </dependency>
    

    Then create a main class that runs it:

    private static final WireMockServer server = new WireMockServer(options().port(8080));
    
    public static void main(String[] args) {
        server.stubFor(post(urlEqualTo("/localsave")).willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
        server.start();
        //do some stuff
    }
    
  3. Use a JUnit-Rule:

    @Rule
    public WireMockRule wireMockRule = new WireMockRule(options().port(8888).httpsPort(8889));
    

You can find all information here: http://wiremock.org/docs/

Please let me know if this is enough information for you.

2
  • Thank you very much . This is very helpful. What you explained was for standalone server what if I have to run my mock service with the other service at the start up time just for my tests?
    – worrynerd
    Commented Sep 11, 2017 at 18:09
  • Can you explain in more detail, what you are trying to test? Do you use JUnit for your tests?
    – Daniel P.
    Commented Sep 16, 2017 at 14:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.