Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2018-12-16 13:25:13 +00:00
parent d5a99b1fc6
commit ad45921ed5
5 changed files with 53 additions and 8 deletions

View File

@@ -606,4 +606,13 @@ matching response definition was picked.</p><p>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.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_can_i_reference_text_from_file" href="#_can_i_reference_text_from_file"></a>3.8.3&nbsp;Can I reference text from file?</h3></div></div></div><p>Yes! With version 1.2.0 we&#8217;ve added such a possibility. It&#8217;s enough to call <code class="literal">file(&#8230;&#8203;)</code> method in the
DSL and provide a path relative to where the contract lays.
If you&#8217;re using YAML just use the <code class="literal">bodyFromFile</code> property.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__spring_cloud_contract_verifier_introduction.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__spring_cloud_contract_verifier_setup.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.&nbsp;Spring Cloud Contract Verifier Introduction&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-contract.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;4.&nbsp;Spring Cloud Contract Verifier Setup</td></tr></table></div></body></html>
If you&#8217;re using YAML just use the <code class="literal">bodyFromFile</code> property.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_why_do_i_sometimes_get_socketexception" href="#_why_do_i_sometimes_get_socketexception"></a>3.8.4&nbsp;Why do I sometimes get <code class="literal">SocketException</code></h3></div></div></div><p>When using an HTTP client (e.g. <code class="literal">RestTemplate</code>) and running several tests that share a Spring context, you might sometimes get the following exception:</p><pre class="screen">java.net.SocketException: Unexpected end of file from server</pre><p>Tom Akehurst, the creator of WireMock did the following analysis of this issue.</p><div class="blockquote"><blockquote class="blockquote"><p>I looked at tcpdump while running the failing test. <code class="literal">HttpUrlConnection</code> is doing something weird - it&#8217;s creating a connection in a previous test case, which works fine, then the usual <code class="literal">fin</code> &#8594; <code class="literal">fin ack</code> etc. ending handshake happens. But it seems it isn&#8217;t discarded, but reused after that. Because the server thinks (rightly) that the connection is closed, it just sends a RST packet. Calling the <code class="literal">/__admin</code> endpoint 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");</p></blockquote></div><p>There are the ways to solve this problem.</p><p>First, just use a different HTTP client for <code class="literal">RestTemplate</code>. Example for using Apache HTTP client:</p><p><b>pom.xml.&nbsp;</b>
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;dependency&gt;</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;groupId&gt;</span>org.apache.httpcomponents<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;/groupId&gt;</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;artifactId&gt;</span>httpclient<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;/artifactId&gt;</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;scope&gt;</span>compile<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;/scope&gt;</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag">&lt;/dependency&gt;</span></pre><p>
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">this</span>.restTemplate
.setRequestFactory(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> HttpComponentsClientHttpRequestFactory());</pre><p>Second option is to set the system property. You can set it either in code or pass it to your tests via a plugin.</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> {
System.setProperty(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http.keepAlive"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"false"</span>);
}</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__spring_cloud_contract_verifier_introduction.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__spring_cloud_contract_verifier_setup.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.&nbsp;Spring Cloud Contract Verifier Introduction&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-contract.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;4.&nbsp;Spring Cloud Contract Verifier Setup</td></tr></table></div></body></html>