Skip to content

Commit c16901f

Browse files
Removed reference in the docs to samples
1 parent aeb82b1 commit c16901f

19 files changed

+98
-262
lines changed

docs/modules/ROOT/pages/building.adoc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ The following list describes each of the top-level folders in the project struct
7171

7272
- `config`: Folder contains setup for Spring Cloud Release Tools automated release process
7373
- `docker`: Folder contains docker images
74-
- `samples`: Folder contains test samples together with standalone ones used also to build documentation
75-
- `scripts`: Contains scripts to build and test `Spring Cloud Contract` with Maven, Gradle and standalone projects
74+
- `scripts`: Contains scripts to build and test `Spring Cloud Contract` with Maven, Gradle
7675
- `specs`: Contains specifications for the Contract DSL.
7776
- `spring-cloud-contract-dependencies`: Contains Spring Cloud Contract BOM
7877
- `spring-cloud-contract-shade`: Shaded dependencies used by the plugins
@@ -95,9 +94,7 @@ command:
9594
./mvnw clean install -P integration
9695
```
9796

98-
Calling that function builds the core, the Maven plugin, and the Gradle plugin and runs
99-
end-to_end tests on the
100-
standalone samples in the proper order (both for Maven and Gradle).
97+
Calling that function builds the core, the Maven plugin, and the Gradle plugin.
10198

10299
To build only the Gradle Plugin, you can run the following commands:
103100

docs/modules/ROOT/pages/customization/wiremock-customization.adoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ With version 3.0.0 you're able to set `metadata` in your contracts. If you set a
5252
will be a valid WireMock's `StubMapping` JSON / map or an actual `StubMapping` object, Spring Cloud Contract will patch the generated
5353
stub with part of your customization. Let's look at the following example
5454

55-
[source,yaml,indent=0]
56-
----
57-
include::{standalone_samples_path}/http-server/src/test/resources/contracts/yml/fraud/shouldReturnFraudStats.yml[tags=metadata,indent=0]
58-
----
55+
{samples_code}/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldReturnFraudStats.yml[Click here to see the code]
5956

6057
In the `metadata` section we've set an entry with key `wiremock` and its value is a JSON `StubMapping` that sets a delay in the generated stub. Such code allowed us to get the following merged WireMock JSON stub.
6158

docs/modules/ROOT/pages/docker-project.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ in case of polyglot applications) then you'll have to have the following prerequ
180180

181181
The contract needs to call a `triggerMessage(...)` method. That method is already provided in the base class for all tests in the docker image and will send out a request to the HTTP endpoint on the producer side. Below you can find examples of such contracts.
182182

183-
[tabs]
184-
======
185183
Groovy::
186184
+
187185
[source,groovy,indent=0,subs="verbatim",role="primary"]
@@ -240,7 +238,7 @@ metadata:
240238
messageProperties:
241239
receivedRoutingKey: '#'
242240
----
243-
======
241+
244242

245243
[[docker-example-of-usage-messaging-endpoint]]
246244
==== HTTP Endpoint to Trigger a Message

docs/modules/ROOT/pages/getting-started/cdc.adoc

Lines changed: 17 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,15 @@ Social remarks
2424
discuss changes while going through the process.
2525
* CDC is all about communication.
2626

27-
The server-side code is available under Spring Cloud Contract's repository `samples/standalone/dsl/http-server` path, and the client-side code is available under Spring Cloud Contract's repository `samples/standalone/dsl/http-client` path.
27+
The server-side code is available under {samples_code}[Spring Cloud Contract Samples] repository `samples/standalone/dsl/http-server` path, and the client-side code is available under Spring Cloud Contract's repository `samples/standalone/dsl/http-client` path.
2828

2929
TIP: In this case, the producer owns the contracts. Physically, all the contracts are
3030
in the producer's repository.
3131

3232
[[getting-started-cdc-technical-note]]
3333
== Technical Note
3434

35-
If you use the SNAPSHOT, Milestone, or Release Candidate versions, you need to add the
36-
following section to your build:
37-
38-
[tabs]
39-
======
40-
Maven::
41-
+
42-
[source,xml,indent=0,subs="verbatim",role="primary"]
43-
----
44-
include::{samples_path}/standalone/dsl/http-server/pom.xml[tags=repos,indent=0]
45-
----
46-
======
47-
////
48-
49-
////
50-
[source,groovy,indent=0,subs="verbatim",role="secondary"]
51-
.Gradle
52-
----
53-
include::{samples_path}/standalone/dsl/http-server/build.gradle[tags=deps_repos,indent=0]
54-
----
35+
IMPORTANT:All the code is available under {samples_code}[spring Cloud Contract Samples repo].
5536

5637
For simplicity, we use the following acronyms:
5738

@@ -113,10 +94,7 @@ We start with the loan issuance flow, which the following UML diagram shows:
11394
The following listing shows a test that we might use to check whether a loan amount is too
11495
large:
11596

116-
[source,groovy,indent=0]
117-
----
118-
include::{samples_path}/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java[tags=client_tdd,indent=0]
119-
----
97+
{samples_code}/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java[Click here to see the code]
12098

12199
Assume that you have written a test of your new feature. If a loan application for a big
122100
amount is received, the system should reject that loan application with some description.
@@ -129,10 +107,7 @@ that you need to send the request containing the ID of the client and the amount
129107
client wants to borrow. You want to send it to the `/fraudcheck` URL by using the `PUT` method.
130108
To do so, you might use code similar to the following:
131109

132-
[source,groovy,indent=0]
133-
----
134-
include::{samples_path}/standalone/dsl/http-client/src/main/java/com/example/loan/LoanApplicationService.java[tags=client_call_server,indent=0]
135-
----
110+
{samples_code}/standalone/dsl/http-client/src/main/java/com/example/loan/LoanApplicationService.java[Click here to see the code]
136111

137112
For simplicity, the port of the Fraud Detection service is set to `8080`, and the
138113
application runs on `8090`.
@@ -162,16 +137,9 @@ is important because the producer's test base class name references that folder.
162137

163138
The following example shows our contract, in both Groovy and YAML:
164139

165-
[source,groovy,indent=0,role="primary"]
166-
----
167-
include::{samples_path}/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsFraud.groovy[]
168-
----
140+
{samples_code}/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsFraud.groovy[Click here to see the Groovy code]
169141

170-
[source,yaml,indent=0,role="secondary"]
171-
.yaml
172-
----
173-
include::{samples_path}/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsFraud.yml[]
174-
----
142+
{samples_code}/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsFraud.yml[Click here to see the YAML code]
175143

176144
The YML contract is quite straightforward. However, when you take a look at the contract
177145
written with a statically typed Groovy DSL, you might wonder what the
@@ -207,17 +175,11 @@ install the stubs locally.
207175
We can add either a Maven or a Gradle plugin. In this example, we show how to add Maven.
208176
First, we add the `Spring Cloud Contract` BOM, as the following example shows:
209177

210-
[source,xml,indent=0]
211-
----
212-
include::{samples_path}/standalone/dsl/http-server/pom.xml[tags=contract_bom,indent=0]
213-
----
178+
{samples_code}/standalone/dsl/http-server/pom.xml[Click here to see the code]
214179

215180
Next, add the `Spring Cloud Contract Verifier` Maven plugin, as the following example shows:
216181

217-
[source,xml,indent=0]
218-
----
219-
include::{samples_path}/standalone/dsl/http-server/pom.xml[tags=contract_maven_plugin,indent=0]
220-
----
182+
{samples_code}/standalone/dsl/http-server/pom.xml[Click here to see the code]
221183

222184
Since the plugin was added, you get the `Spring Cloud Contract Verifier` features, which,
223185
from the provided contracts:
@@ -271,26 +233,17 @@ Application service`):
271233

272234
. Add the `Spring Cloud Contract` BOM, as follows:
273235
+
274-
[source,xml,indent=0]
275-
----
276-
include::{samples_path}/standalone/dsl/http-client/pom.xml[tags=contract_bom,indent=0]
277-
----
236+
{samples_code}/standalone/dsl/http-client/pom.xml[Click here to see the code]
278237

279238
. Add the dependency to `Spring Cloud Contract Stub Runner`, as follows:
280239
+
281-
[source,xml,indent=0]
282-
----
283-
include::{samples_path}/standalone/dsl/http-client/pom.xml[tags=stub_runner,indent=0]
284-
----
240+
{samples_code}/standalone/dsl/http-client/pom.xml[Click here to see the code]
285241

286242
. Annotate your test class with `@AutoConfigureStubRunner`. In the annotation, provide the
287243
`group-id` and `artifact-id` for the Stub Runner to download the stubs of your
288244
collaborators.
289245
+
290-
[source,groovy,indent=0]
291-
----
292-
include::{samples_path}/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java[tags=autoconfigure_stubrunner,indent=0]
293-
----
246+
{samples_code}/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java[Click here to see the code]
294247

295248
. (Optional) Because you are playing with the collaborators offline, you
296249
can also provide the offline work switch (`StubRunnerProperties.StubsMode.LOCAL`).
@@ -359,12 +312,7 @@ The following UML diagram shows the fraud detection flow:
359312

360313
As a reminder, the following listing shows the initial implementation:
361314

362-
[source,java,indent=0]
363-
----
364-
include::{samples_path}/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java[tags=server_api,indent=0]
365-
include::{samples_path}/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java[tags=initial_impl,indent=0]
366-
}
367-
----
315+
{samples_code}/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java[Click here to see the code]
368316

369317
Then you can run the following commands:
370318

@@ -376,17 +324,11 @@ $ git pull https://your-git-server.com/server-side-fork.git contract-change-pr
376324

377325
You must add the dependencies needed by the autogenerated tests, as follows:
378326

379-
[source,xml,indent=0]
380-
----
381-
include::{samples_path}/standalone/dsl/http-server/pom.xml[tags=verifier_test_dependencies,indent=0]
382-
----
327+
{samples_code}/standalone/dsl/http-server/pom.xml[Click here to see the code]
383328

384329
In the configuration of the Maven plugin, you must pass the `packageWithBaseClasses` property, as follows:
385330

386-
[source,xml,indent=0]
387-
----
388-
include::{samples_path}/standalone/dsl/http-server/pom.xml[tags=contract_maven_plugin,indent=0]
389-
----
331+
{samples_code}/standalone/dsl/http-server/pom.xml[Click here to see the code]
390332

391333
IMPORTANT: This example uses "`convention-based`" naming by setting the
392334
`packageWithBaseClasses` property. Doing so means that the two last packages combine to
@@ -400,10 +342,7 @@ or whatever is necessary. In this case, you should use https://github.com/rest-a
400342
start the server side `FraudDetectionController`. The following listing shows the
401343
`FraudBase` class:
402344

403-
[source,java,indent=0]
404-
----
405-
include::{samples_path}/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudBase.java[]
406-
----
345+
{samples_code}/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudBase.java[Click here to see the code]
407346

408347
Now, if you run the `./mvnw clean install`, you get something like the following output:
409348

@@ -458,13 +397,7 @@ in the response. In other words, you have the `red` part of `red`, `green`, and
458397
Because you know the expected input and expected output, you can write the missing
459398
implementation as follows:
460399

461-
[source,java,indent=0]
462-
----
463-
include::{samples_path}/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java[tags=server_api,indent=0]
464-
include::{samples_path}/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java[tags=new_impl,indent=0]
465-
include::{samples_path}/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java[tags=initial_impl,indent=0]
466-
}
467-
----
400+
{samples_code}/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java[Click here to see the code]
468401

469402
When you run `./mvnw clean install` again, the tests pass. Since the Spring Cloud
470403
Contract Verifier plugin adds the tests to the `generated-test-sources`, you can
@@ -532,10 +465,7 @@ side are automatically downloaded from Nexus/Artifactory. You can set the value
532465
`stubsMode` to `REMOTE`. The following code shows an example of
533466
achieving the same thing by changing the properties:
534467

535-
[source,yaml,indent=0]
536-
----
537-
include::{samples_path}/standalone/dsl/http-client/src/test/resources/application-test-repo.yaml[]
538-
----
468+
{samples_code}/standalone/dsl/http-client/src/test/resources/application-test-repo.yaml[Click here to see the code]
539469

540470
That's it. You have finished the tutorial.
541471

docs/modules/ROOT/pages/getting-started/first-application.adoc

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ The following UML diagram shows the relationship of the parts of Spring Cloud Co
3939
To start working with `Spring Cloud Contract`, you can add the Spring Cloud Contract Verifier
4040
dependency and plugin to your build file, as the following example shows:
4141

42-
[source,xml,indent=0]
43-
----
44-
include::{samples_path}/standalone/dsl/http-server/pom.xml[tags=verifier_test_dependencies,indent=0]
45-
----
42+
{samples_code}/standalone/dsl/http-server/pom.xml[Click here to see the code]
4643

4744
The following listing shows how to add the plugin, which should go in the build/plugins
4845
portion of the file:
@@ -78,8 +75,6 @@ For the HTTP stubs, a contract defines what kind of response should be returned
7875
given request (taking into account the HTTP methods, URLs, headers, status codes, and so
7976
on). The following example shows an HTTP stub contract in both Groovy and YAML:
8077

81-
[tabs]
82-
======
8378
groovy::
8479
+
8580
[source,groovy,indent=0,role="primary"]
@@ -136,8 +131,6 @@ response:
136131
headers:
137132
Content-Type: application/json;charset=UTF-8
138133
----
139-
======
140-
141134
If you need to use messaging, you can define:
142135

143136
* The input and output messages (taking into account from where it
@@ -147,8 +140,6 @@ was sent, the message body, and the header).
147140

148141
The following example shows a Camel messaging contract:
149142

150-
[tabs]
151-
======
152143
groovy::
153144
+
154145
[source,groovy,indent=0,role="primary"]
@@ -162,7 +153,6 @@ yaml::
162153
----
163154
include::{verifier_root_path}/src/test/resources/yml/contract_message_scenario1.yml[indent=0]
164155
----
165-
======
166156

167157
Running `./mvnw clean install` automatically generates tests that verify the application
168158
compliance with the added contracts. By default, the generated tests are under
@@ -183,8 +173,6 @@ of the other frameworks, add its library to your classpath.
183173

184174
The following listing shows samples for all frameworks:
185175

186-
[tabs]
187-
======
188176
mockmvc::
189177
+
190178
[source,java,indent=0,role="primary"]
@@ -271,7 +259,6 @@ webtestclient::
271259
assertThatJson(parsedJson).field("['status']").isEqualTo("NOT_OK");
272260
}
273261
----
274-
======
275262

276263
As the implementation of the functionalities described by the contracts is not yet
277264
present, the tests fail.
@@ -432,10 +419,7 @@ WireMock instance or messaging route that simulates the actual service.
432419

433420
To get started, add the dependency to `Spring Cloud Contract Stub Runner`, as follows:
434421

435-
[source,xml,indent=0]
436-
----
437-
include::{samples_path}/standalone/dsl/http-client/pom.xml[tags=stub_runner,indent=0]
438-
----
422+
{samples_code}/standalone/dsl/http-client/pom.xml[Click here to see the code]
439423

440424
You can get the Producer-side stubs installed in your Maven repository in either of two
441425
ways:
@@ -455,10 +439,7 @@ in place, so the automatically-generated contract tests fail.
455439
pass the stub artifact IDs and artifact repository URL as `Spring Cloud Contract Stub
456440
Runner` properties, as the following example shows:
457441
+
458-
[source,yaml,indent=0]
459-
----
460-
include::{samples_path}/standalone/dsl/http-client/src/test/resources/application-test-repo.yaml[]
461-
----
442+
{samples_code}/standalone/dsl/http-client/src/test/resources/application-test-repo.yaml[Click here to see the code]
462443

463444
Now you can annotate your test class with `@AutoConfigureStubRunner`. In the annotation,
464445
provide the `group-id` and `artifact-id` for `Spring Cloud Contract Stub Runner` to run

docs/modules/ROOT/pages/getting-started/introducing-spring-cloud-contract.adoc

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,9 @@ amount it wants to borrow from us. You also want to send it to the `/fraudcheck`
108108
the `PUT` method. The following listing shows a contract to check whether a client should
109109
be marked as a fraud in both Groovy and YAML:
110110

111-
[tabs]
112-
======
113-
groovy::
114-
+
115-
[source,groovy,indent=0,role="primary"]
116-
----
117-
include::{samples_path}/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsFraud.groovy[]
118-
----
119-
======
120-
////
121-
122-
////
123-
[source,yaml,indent=0,role="secondary"]
124-
.yaml
125-
----
126-
include::{samples_path}/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsFraud.yml[]
127-
----
111+
{samples_code}/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsFraud.groovy[Click here to see the Groovy Code]
112+
113+
{samples_code}/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsFraud.yml[Click here to see the YAML Code]
128114

129115
IMPORTANT: It is expected that contracts are coming from a **trusted source**. You should never download nor interact with contracts coming from untrusted locations.
130116

0 commit comments

Comments
 (0)