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
Apache HttpClient + WireMock #41
Comments
I'm lacking access to a computer at the moment so I can't test this but it could be because your stub definition has a trailing slash but your http post doesn't BTW, your @before block is unnecessary as reset() is called by the rule. |
I've added the trailing slash to the HttpPost HttpPost httpPost = new HttpPost("http://localhost:9999/"); Unfortunately this does not solve the problem. |
If you add a log4j notifier to the options passed to the rule and set it to verbose it'll log out why it didn't match at INFO. |
After adding the log4j Notifier as follows @Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(testPort).notifier(
new Log4jNotifier())); I got no more information, but several NullPointerExceptions :) Perhaps a bug?
|
I think that exception is probably because you've got an additional, different version of the servlet API on your classpath. If you try excluding this (temporarily at least) so that only the Servlet API version pulled in via WireMock is present, this should go away. |
Looks like the same exception as in this issue (for which excluding the other Servlet API solved the issue): |
Ok. the servlet issue solved the problem for debugging.
thats all.... no additional information. verify(postRequestedFor(urlEqualTo("/"))
.withHeader("Content-Type", equalTo("text/xml; charset=UTF-8"))
.withHeader("SOAPAction", equalTo("")).withRequestBody(equalTo(request))); |
Probably because you're running with log4j defaults. Try calling Log4jConfigurer.configure (true); in your @before |
I do not use the default log4j properties, but I saw there is a restriction for com.* packages set to WARN :) So I changed this and get the following:
|
Ok, it looks like you've configured your stub for a GET only but are hitting it with a POST. |
Which version are you running? |
I am running v1.33 of WireMock. Where do I can configure the stub for POST requests? |
Wow, some hours of sleep make the job :) post(urlEqualTo("/") As the term 'get', which is used in each example in the documentation, is some kind of overloaded in this case, in my opinion, the documentation should be a little bit clearer here :) Nevertheless, thanks for you quick and helpful feedback and also thanks for WireMock! I love it! 👍 |
Hello, @tomakehurst ! Looks like I have the same problem - conflicted Http Client dependency.
should solve the problem, but it is not. How can I fix it? |
Yes, the docs aren't great in this regard. The POM with the standalone version still (currently) pulls in the transitive dependencies, so you need to explicitly exclude the ones that are causing you problems e.g. <exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions> |
No, this doesn't help. I'm still getting |
Sorry, I was thoughtless :) Thank you! |
@tomakehurst Is it possible to exclude certain query parameter while running wiremock standalone? |
Hi,
I have observed strange behavior when accessing a mocked server instance of WireMock with the Apache HttpClient.
When I debug the test, and go to the mocked server address in my browser, I got the expected response. However accessing the same address with the Apache HttpClient leads to a 404 response.
Necessary Information about the Test (not the whole test, only WireMock related configurations):
Nice to know is, that the verification is valid. So the mock is obviously called correctly.
HttpClient-Code calling the mocked server address:
Now I got the 404 Error html page from jetty, although the browser shows the right mocked response:
Any suggestions why I got the right answer in my firefox browser and got a 404 via the Apache HttpClient? Perhaps are there any headers which are assumed to be in the request in order to let WireMock match the called URL and provide a declared response?
The text was updated successfully, but these errors were encountered: