WireMockRule cause error 500 when getInputStream from urlConnection
See original GitHub issueIs it normal that the code above cause a HTTP response code: 500 ? :
public class MyTest {
@Rule
public WireMockRule wireMockRule = new WireMockRule(7032);
@Test
public void exampleTest() throws IOException {
stubFor(get(urlEqualTo("/my/resource"))
.withHeader("Accept", equalTo("text/xml"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody("<response>Some content</response>")));
URLConnection urlConnection = new URL("http://localhost:7032/my/resource").openConnection();
Assert.assertNotNull(urlConnection.getInputStream()); // java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:7032/my/resource
}
}
It’s throw
java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:7032/my/resource
I am using Wiremock 2.5.1 with JUnit 4.12.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
WireMockRule cause error 500 when getInputStream ... - GitHub
Is it normal that the code above cause a HTTP response code: 500 ? : public class MyTest { @Rule public WireMockRule wireMockRule...
Read more >HttpURLConnection always return error 500 - Stack Overflow
i'm trying to run a soap request in a basic http request...naturally i tried with external tools the message and is correct, ...
Read more >Trouble Getting Started - Google Groups
1) WireMock is running, your client is connecting to it but something about how/where you're running it is causing it to throw a...
Read more >Getting a 500 HTTP status returned from my web service with ...
getInputStream. No errors appear in the glassfish log on the server so I'm at a loss as to what I have done wrong...
Read more >Testing server faults with Wiremock - allegro.tech blog
Due to an error in the service implementation, the server returned 200 OK instead of 500, but the response body was as for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found the problem. My projet (target 1.6) use servlet-api 2.5 as dependency to compile my sources (I am using an old application server).
But it is in conflict with Wiremock jetty servlet api version 3.1 causing this error 500… Do you have any solution to isolate wiremock test dependencies (I can’t upgrade my project to servlet api 3.1) ?
That’s a hard one to solve unfortunately, other than by running WireMock in a separate process.