Sync docs from master to gh-pages
This commit is contained in:
@@ -322,6 +322,12 @@ $(addBlockSwitches);
|
||||
<li><a href="#features-messaging-stub-runner-amqp-example">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#features-messaging-stub-runner-jms">4.4.9. Consumer Side Messaging With Spring JMS</a>
|
||||
<ul class="sectlevel4">
|
||||
<li><a href="#features-messaging-stub-runner-jms-adding">Adding the Runner to the Project</a></li>
|
||||
<li><a href="#features-messaging-stub-runner-jms-example">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#features-stub-runner">4.5. Spring Cloud Contract Stub Runner</a>
|
||||
@@ -8657,7 +8663,7 @@ and the appropriate <code>MatchingType</code> as second. All the body matchers a
|
||||
<div class="listingblock secondary">
|
||||
<div class="title">yml</div>
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-yml hljs" data-lang="yml">include::/opt/jenkins/data/workspace/spring-cloud-contract-master-releaser/spring-cloud-contract-verifier/src/test/resources/yml/contract_rest_xml.yml</code></pre>
|
||||
<pre class="highlightjs highlight"><code class="language-yml hljs" data-lang="yml">include::/opt/jenkins/data/workspace/spring-cloud-contract-master-ci/spring-cloud-contract-verifier/src/test/resources/yml/contract_rest_xml.yml</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="listingblock secondary">
|
||||
@@ -9907,6 +9913,9 @@ in the generated test.</p>
|
||||
<li>
|
||||
<p>Spring AMQP</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Spring JMS</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -11691,6 +11700,222 @@ configure a mock <code>ConnectionFactory</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="features-messaging-stub-runner-jms"><a class="anchor" href="#features-messaging-stub-runner-jms"></a><a class="link" href="#features-messaging-stub-runner-jms">4.4.9. Consumer Side Messaging With Spring JMS</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Contract Stub Runner’s messaging module provides an easy way to
|
||||
integrate with Spring JMS.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The integration assumes that you have a running instance of a JMS broker (e.g. <code>activemq</code> embedded broker).</p>
|
||||
</div>
|
||||
<div class="sect4">
|
||||
<h5 id="features-messaging-stub-runner-jms-adding"><a class="anchor" href="#features-messaging-stub-runner-jms-adding"></a><a class="link" href="#features-messaging-stub-runner-jms-adding">Adding the Runner to the Project</a></h5>
|
||||
<div class="paragraph">
|
||||
<p>You need to have both Spring JMS and Spring Cloud Contract Stub Runner on the classpath. Remember to annotate your test class
|
||||
with <code>@AutoConfigureStubRunner</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect4">
|
||||
<h5 id="features-messaging-stub-runner-jms-example"><a class="anchor" href="#features-messaging-stub-runner-jms-example"></a><a class="link" href="#features-messaging-stub-runner-jms-example">Examples</a></h5>
|
||||
<div class="paragraph">
|
||||
<p>Assume that the stub structure looks as follows:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">├── stubs
|
||||
├── bookDeleted.groovy
|
||||
├── bookReturned1.groovy
|
||||
└── bookReturned2.groovy</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Further assume the following test configuration:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-yml hljs" data-lang="yml">stubrunner:
|
||||
repository-root: stubs:classpath:/stubs/
|
||||
ids: my:stubs
|
||||
stubs-mode: remote
|
||||
spring:
|
||||
activemq:
|
||||
send-timeout: 1000
|
||||
jms:
|
||||
template:
|
||||
receive-timeout: 1000</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Now consider the following contracts (we number them 1 and 2):</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">Contract.make {
|
||||
label 'return_book_1'
|
||||
input {
|
||||
triggeredBy('bookReturnedTriggered()')
|
||||
}
|
||||
outputMessage {
|
||||
sentTo('output')
|
||||
body('''{ "bookName" : "foo" }''')
|
||||
headers {
|
||||
header('BOOK-NAME', 'foo')
|
||||
}
|
||||
}
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">Contract.make {
|
||||
label 'return_book_2'
|
||||
input {
|
||||
messageFrom('input')
|
||||
messageBody([
|
||||
bookName: 'foo'
|
||||
])
|
||||
messageHeaders {
|
||||
header('sample', 'header')
|
||||
}
|
||||
}
|
||||
outputMessage {
|
||||
sentTo('output')
|
||||
body([
|
||||
bookName: 'foo'
|
||||
])
|
||||
headers {
|
||||
header('BOOK-NAME', 'foo')
|
||||
}
|
||||
}
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect5">
|
||||
<h6 id="features-messaging-stub-runner-jms-scenario1"><a class="anchor" href="#features-messaging-stub-runner-jms-scenario1"></a><a class="link" href="#features-messaging-stub-runner-jms-scenario1">Scenario 1 (No Input Message)</a></h6>
|
||||
<div class="paragraph">
|
||||
<p>To trigger a message from the <code>return_book_1</code> label, we use the <code>StubTigger</code> interface, as follows:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">stubFinder.trigger('return_book_1')</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Next, we want to listen to the output of the message sent to <code>output</code>:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">TextMessage receivedMessage = (TextMessage) jmsTemplate.receive('output')</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The received message would then pass the following assertions:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">receivedMessage != null
|
||||
assertThatBodyContainsBookNameFoo(receivedMessage.getText())
|
||||
receivedMessage.getStringProperty('BOOK-NAME') == 'foo'</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect5">
|
||||
<h6 id="features-messaging-stub-runner-jms-scenario2"><a class="anchor" href="#features-messaging-stub-runner-jms-scenario2"></a><a class="link" href="#features-messaging-stub-runner-jms-scenario2">Scenario 2 (Output Triggered by Input)</a></h6>
|
||||
<div class="paragraph">
|
||||
<p>Since the route is set for you, you can send a message to the <code>output</code> destination.</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">jmsTemplate.
|
||||
convertAndSend('input', new BookReturned('foo'), new MessagePostProcessor() {
|
||||
@Override
|
||||
Message postProcessMessage(Message message) throws JMSException {
|
||||
message.setStringProperty("sample", "header")
|
||||
return message
|
||||
}
|
||||
})</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Next, we want to listen to the output of the message sent to <code>output</code>, as follows:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">TextMessage receivedMessage = (TextMessage) jmsTemplate.receive('output')</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The received message would pass the following assertions:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">receivedMessage != null
|
||||
assertThatBodyContainsBookNameFoo(receivedMessage.getText())
|
||||
receivedMessage.getStringProperty('BOOK-NAME') == 'foo'</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect5">
|
||||
<h6 id="features-messaging-stub-runner-jms-scenario3"><a class="anchor" href="#features-messaging-stub-runner-jms-scenario3"></a><a class="link" href="#features-messaging-stub-runner-jms-scenario3">Scenario 3 (Input with No Output)</a></h6>
|
||||
<div class="paragraph">
|
||||
<p>Since the route is set for you, you can send a message to the <code>output</code> destination, as follows:</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="content">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">jmsTemplate.
|
||||
convertAndSend('delete', new BookReturned('foo'), new MessagePostProcessor() {
|
||||
@Override
|
||||
Message postProcessMessage(Message message) throws JMSException {
|
||||
message.setStringProperty("sample", "header")
|
||||
return message
|
||||
}
|
||||
})</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="features-stub-runner"><a class="anchor" href="#features-stub-runner"></a><a class="link" href="#features-stub-runner">4.5. Spring Cloud Contract Stub Runner</a></h3>
|
||||
|
||||
Reference in New Issue
Block a user