From 2194b609d2a6ec58554045aed7081ff6a34e23bc Mon Sep 17 00:00:00 2001
From: buildmaster
To turn off this feature just bum `StubRunnerExtension`to dump all mappings per artifact id. Also the port at which the given stub server was started will be attached.
Yes! With version 1.2.0 we’ve added such a possibility. It’s enough to call file(…) method in the
DSL and provide a path relative to where the contract lays.
-If you’re using YAML just use the bodyFromFile property.
When using an HTTP client (e.g. RestTemplate) and running several tests that share a Spring context, you might sometimes get the following exception:
java.net.SocketException: Unexpected end of file from server
Tom Akehurst, the creator of WireMock did the following analysis of this issue.
I looked at tcpdump while running the failing test.
HttpUrlConnectionis doing something weird - it’s creating a connection in a previous test case, which works fine, then the usualfin→fin acketc. ending handshake happens. But it seems it isn’t discarded, but reused after that. Because the server thinks (rightly) that the connection is closed, it just sends a RST packet. Calling the/__adminendpoint just happened to remove the dead connection from the pool. This also fixes the problem (which using the Java HTTP client): System.setProperty("http.keepAlive", "false");
There are the ways to solve this problem.
First, just use a different HTTP client for RestTemplate. Example for using Apache HTTP client:
pom.xml. -
<dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <scope>compile</scope> -</dependency>
-
this.restTemplate - .setRequestFactory(new HttpComponentsClientHttpRequestFactory());
Second option is to set the system property. You can set it either in code or pass it to your tests via a plugin.
static { - System.setProperty("http.keepAlive", "false"); -}