Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2018-03-15 09:24:11 +00:00
parent 90508c1a9c
commit 42d1ba36ad
32 changed files with 202 additions and 181 deletions

View File

@@ -4,7 +4,7 @@
<book xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
<info>
<title>Spring Cloud Contract</title>
<date>2018-03-12</date>
<date>2018-03-13</date>
</info>
<preface>
<title></title>
@@ -53,7 +53,7 @@ Spring Cloud Contract Verifier.</simpara>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/master/docs/src/main/asciidoc/images/Deps.png"/>
<imagedata fileref="https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/1.2.x/docs/src/main/asciidoc/images/Deps.png"/>
</imageobject>
<textobject><phrase>Microservices Architecture</phrase></textobject>
</mediaobject>
@@ -128,7 +128,7 @@ are those that your application directly uses.</simpara>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/master/docs/src/main/asciidoc/images/Stubs2.png"/>
<imagedata fileref="https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/1.2.x/docs/src/main/asciidoc/images/Stubs2.png"/>
</imageobject>
<textobject><phrase>Stubbed Services</phrase></textobject>
</mediaobject>
@@ -302,7 +302,7 @@ org.springframework.cloud.contract.spec.Contract.make {
}
}
response {
status 200
status OK()
body([
fraudCheckStatus: "FRAUD",
"rejection.reason": "Amount too high"
@@ -546,7 +546,7 @@ org.springframework.cloud.contract.spec.Contract.make {
}
}
response { // (6)
status 200 // (7)
status OK() // (7)
body([ // (8)
fraudCheckStatus: "FRAUD",
"rejection.reason": "Amount too high"
@@ -710,8 +710,8 @@ we mark the client as a fraud.</simpara>
Issuance has an artifact-id of <literal>http-client</literal>, and both have a <literal>group-id</literal> of <literal>com.example</literal>.</simpara>
<simpara>Social remark - both client and server development teams need to communicate directly and
discuss changes while going through the process. CDC is all about communication.</simpara>
<simpara>The <link xl:href="https://github.com/spring-cloud/spring-cloud-contract/tree/master/samples/standalone/dsl/http-server">server
side code is available here</link> and <link xl:href="https://github.com/spring-cloud/spring-cloud-contract/tree/master/samples/standalone/dsl/http-client">the
<simpara>The <link xl:href="https://github.com/spring-cloud/spring-cloud-contract/tree/1.2.x/samples/standalone/dsl/http-server">server
side code is available here</link> and <link xl:href="https://github.com/spring-cloud/spring-cloud-contract/tree/1.2.x/samples/standalone/dsl/http-client">the
client code here</link>.</simpara>
<tip>
<simpara>In this case, the producer owns the contracts. Physically, all the contract are
@@ -888,7 +888,7 @@ org.springframework.cloud.contract.spec.Contract.make {
}
}
response { // (6)
status 200 // (7)
status OK() // (7)
body([ // (8)
fraudCheckStatus: "FRAUD",
"rejection.reason": "Amount too high"
@@ -1442,7 +1442,7 @@ for time and UUID are simplified and most likely invalid but we want to keep thi
])
}
response {
status 200
status OK()
body([
time : value(producer(regex('[0-9]{4}-[0-9]{2}-[0-9]{2} [0-2][0-9]-[0-5][0-9]-[0-5][0-9]')),
id: value([producer(regex('[0-9a-zA-z]{8}-[0-9a-zA-z]{4}-[0-9a-zA-z]{4}-[0-9a-zA-z]{12}'))
@@ -1549,15 +1549,15 @@ one to one to the contents of the repo.</simpara>
&lt;parent&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
&lt;version&gt;2.0.0.BUILD-SNAPSHOT&lt;/version&gt;
&lt;version&gt;1.5.10.RELEASE&lt;/version&gt;
&lt;relativePath /&gt;
&lt;/parent&gt;
&lt;properties&gt;
&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
&lt;java.version&gt;1.8&lt;/java.version&gt;
&lt;spring-cloud-contract.version&gt;2.0.0.BUILD-SNAPSHOT&lt;/spring-cloud-contract.version&gt;
&lt;spring-cloud-dependencies.version&gt;Finchley.BUILD-SNAPSHOT&lt;/spring-cloud-dependencies.version&gt;
&lt;spring-cloud-contract.version&gt;1.2.4.BUILD-SNAPSHOT&lt;/spring-cloud-contract.version&gt;
&lt;spring-cloud-dependencies.version&gt;Edgware.BUILD-SNAPSHOT&lt;/spring-cloud-dependencies.version&gt;
&lt;excludeBuildFolders&gt;true&lt;/excludeBuildFolders&gt;
&lt;/properties&gt;
@@ -1735,7 +1735,6 @@ of the JAR containing the contracts:</simpara>
&lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
&lt;artifactId&gt;spring-cloud-contract-maven-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;contractsMode&gt;REMOTE&lt;/contractsMode&gt;
&lt;contractsRepositoryUrl&gt;http://link/to/your/nexus/or/artifactory/or/sth&lt;/contractsRepositoryUrl&gt;
&lt;contractDependency&gt;
&lt;groupId&gt;com.example.standalone&lt;/groupId&gt;
@@ -2800,7 +2799,7 @@ goal.</simpara>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/master/docs/src/main/asciidoc/images/sts_exception.png"/>
<imagedata fileref="https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/1.2.x/docs/src/main/asciidoc/images/sts_exception.png"/>
</imageobject>
<textobject><phrase>STS Exception</phrase></textobject>
</mediaobject>
@@ -3849,8 +3848,8 @@ producer stubs.</simpara>
      └── nested
      └── contract3.groovy</programlisting>
<simpara>To achieve proper stub packaging.</simpara>
<simpara>Or using the <link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer_with_restdocs/pom.xml">Maven <literal>assembly</literal> plugin</link> or
<link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer_with_restdocs/build.gradle">Gradle Jar</link> task you have to create the following
<simpara>Or using the <link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/2.0.x/producer_with_restdocs/pom.xml">Maven <literal>assembly</literal> plugin</link> or
<link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/2.0.x/producer_with_restdocs/build.gradle">Gradle Jar</link> task you have to create the following
structure in your stubs jar.</simpara>
<programlisting language="bash" linenumbering="unnumbered">└── META-INF
└── com.example
@@ -4230,10 +4229,10 @@ for every registered WireMock server. Example for Stub Runner ids
<simpara>For real life examples you can check the</simpara>
<itemizedlist>
<listitem>
<simpara><link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/master/producer">producer app sample</link></simpara>
<simpara><link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/2.0.x/producer">producer app sample</link></simpara>
</listitem>
<listitem>
<simpara><link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/master/consumer_with_discovery">consumer app sample</link></simpara>
<simpara><link xl:href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/2.0.x/consumer_with_discovery">consumer app sample</link></simpara>
</listitem>
</itemizedlist>
<section xml:id="_stubbing_service_discovery">
@@ -4512,7 +4511,7 @@ There are 2 consumers: <literal>foo-consumer</literal> and <literal>bar-consumer
method GET()
}
response {
status 200
status OK()
body(
foo: "foo"
}
@@ -4523,7 +4522,7 @@ response {
method GET()
}
response {
status 200
status OK()
body(
bar: "bar"
}
@@ -5324,7 +5323,7 @@ the <literal>Contract</literal> class: <literal>import org.springframework.cloud
'''
}
response {
status 200
status OK()
}
}</programlisting>
<simpara>The following is a complete example of a YAML contract definition:</simpara>
@@ -5558,7 +5557,7 @@ Contract.make {
url("/1")
}
response {
status 200
status OK()
body(file("response.json"))
headers {
contentType(textPlain())
@@ -5870,7 +5869,7 @@ body:
)
}
response {
status 200
status OK()
}
}</programlisting>
</para>
@@ -6004,7 +6003,7 @@ following code shows an example:</simpara>
response {
// Status code sent by the server
// in response to request specified above.
status 200
status OK()
}
}</programlisting>
</para>
@@ -6019,6 +6018,11 @@ status: 200</programlisting>
</formalpara>
<simpara>Besides status, the response may contain <emphasis role="strong">headers</emphasis> and a <emphasis role="strong">body</emphasis>, both of which are
specified the same way as in the request (see the previous paragraph).</simpara>
<tip>
<simpara>Via the Groovy DSL you can reference the <literal>org.springframework.cloud.contract.spec.internal.HttpStatus</literal>
methods to provide a meaningful status instead of a digit. E.g. you can call
<literal>OK()</literal> for a status <literal>200</literal> or <literal>BAD_REQUEST()</literal> for <literal>400</literal>.</simpara>
</tip>
</section>
<section xml:id="_dynamic_properties">
<title>Dynamic properties</title>
@@ -6067,7 +6071,7 @@ need to use patterns and not exact values both for your test and your server sid
url $(consumer(~/\/[0-9]{2}/), producer('/12'))
}
response {
status 200
status OK()
body(
id: $(anyNumber()),
surname: $(
@@ -6100,7 +6104,7 @@ the provided regular expression. The following code shows an example:</simpara>
}
}
response {
status 200
status OK()
body([
responseElement: $(producer(regex('[0-9]{7}')))
])
@@ -6116,6 +6120,7 @@ use in your contracts, as shown in the following example:</simpara>
<programlisting language="groovy" linenumbering="unnumbered">protected static final Pattern TRUE_OR_FALSE = Pattern.compile(/(true|false)/)
protected static final Pattern ONLY_ALPHA_UNICODE = Pattern.compile(/[\p{L}]*/)
protected static final Pattern NUMBER = Pattern.compile('-?(\\d*\\.\\d+|\\d+)')
protected static final Pattern DOUBLE = Pattern.compile('-?(\\d*\\.\\d+)')
protected static final Pattern IP_ADDRESS = Pattern.compile('([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])')
protected static final Pattern HOSTNAME_PATTERN = Pattern.compile('((http[s]?|ftp):/)/?([^:/\\s]+)(:[0-9]{1,5})?')
protected static final Pattern EMAIL = Pattern.compile('[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}')
@@ -6144,6 +6149,10 @@ Pattern anyBoolean() {
return TRUE_OR_FALSE
}
Pattern aDouble() {
return DOUBLE
}
Pattern ipAddress() {
return IP_ADDRESS
}
@@ -6328,7 +6337,7 @@ following code shows an example of the contract portion of the test case:</simpa
path: $(consumer('/api/12'), producer(regex('^/api/[0-9]{2}$'))),
correlationId: $(consumer('1223456'), producer(execute('isProperCorrelationId($it)')))
)
status 200
status OK()
}
}</programlisting>
<simpara>The following code shows the base class portion of the test case:</simpara>
@@ -6388,7 +6397,7 @@ is applied for the whole body - not for parts of it.</simpara>
)
}
response {
status 200
status OK()
}
}</programlisting>
<simpara>The preceding example results in calling the <literal>hashCode()</literal> method in the request body.
@@ -6494,7 +6503,7 @@ matches the JSON Path. E.g. for json path <literal>$.foo</literal> - <literal>{{
body(foo: "bar", baz: 5)
}
response {
status 200
status OK()
headers {
header(authorization(), "foo ${fromRequest().header(authorization())} bar")
}
@@ -6895,7 +6904,7 @@ email, url, uuid, iso_date, iso_date_time, iso_time, iso_8601_with_offset, non_e
}
}
response {
status 200
status OK()
body([
duck: 123,
alpha: "abc",
@@ -7237,7 +7246,7 @@ collection.</simpara>
url("/foo")
}
response {
status 200
status OK()
body(events: [[
operation : 'EXPORT',
eventId : '16f1ed75-0bcc-4f0d-a04d-3121798faf99',
@@ -7320,7 +7329,7 @@ provide a <literal>sync()</literal> method in the <literal>response</literal> se
url '/get'
}
response {
status 200
status OK()
body 'Passed'
async()
}
@@ -7376,7 +7385,7 @@ socket.</simpara>
url '/my-context-path/url'
}
response {
status 200
status OK()
}
}</programlisting>
<simpara>The following example shows how to set up a base class and Rest Assured:</simpara>
@@ -7607,7 +7616,7 @@ following example:</simpara>
url('/users/1')
}
response {
status 200
status OK()
}
},
Contract.make {
@@ -7616,7 +7625,7 @@ following example:</simpara>
url('/users/2')
}
response {
status 200
status OK()
}
}
]</programlisting>
@@ -8832,7 +8841,7 @@ Contract.make {
}
}
response {
status 200
status OK()
body('''
bar
''')