diff --git a/2.0.x/multi/multi__migrations.html b/2.0.x/multi/multi__migrations.html index 9d777b3c08..a65fe452ff 100644 --- a/2.0.x/multi/multi__migrations.html +++ b/2.0.x/multi/multi__migrations.html @@ -49,7 +49,7 @@ structure presented in the previous snippet.

Maven.&nbs <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 https://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>stubs</id> <formats> <format>jar</format> diff --git a/2.0.x/multi/multi__spring_cloud_contract_faq.html b/2.0.x/multi/multi__spring_cloud_contract_faq.html index 03836d34ec..7dcaa21022 100644 --- a/2.0.x/multi/multi__spring_cloud_contract_faq.html +++ b/2.0.x/multi/multi__spring_cloud_contract_faq.html @@ -275,7 +275,7 @@ Those poms are necessary for the consumer side to run mvn is that the producer doesn’t own the contracts anymore. So the consumer and the producer have to work on common contracts in a common repository.

3.5.3 Consumer

When the consumer wants to work on the contracts offline, instead of cloning the producer code, the consumer team clones the common repository, goes to the required producer’s folder (e.g. com/example/server) -and runs mvn clean install -DskipTests to install locally the stubs converted from the contracts.

[Tip]Tip

You need to have Maven installed locally

3.5.4 Producer

As a producer it’s enough to alter the Spring Cloud Contract Verifier to provide the URL and the dependency +and runs mvn clean install -DskipTests to install locally the stubs converted from the contracts.

[Tip]Tip

You need to have Maven installed locally

3.5.4 Producer

As a producer it’s enough to alter the Spring Cloud Contract Verifier to provide the URL and the dependency of the JAR containing the contracts:

<plugin>
 	<groupId>org.springframework.cloud</groupId>
 	<artifactId>spring-cloud-contract-maven-plugin</artifactId>
@@ -507,7 +507,7 @@ SCM repository, prefixed with the protocol. For example

"com.example:bookstore:0.0.1.RELEASE"
 )

With such a setup:

  • Git project will be cloned to a temporary directory
  • The SCM stub downloader will go to META-INF/groupId/artifactId/version/ folder to find stub definitions and contracts. E.g. for com.example:foo:1.0.0 the path would be -META-INF/com.example/foo/1.0.0/
  • Stub servers will be started and fed with mappings
  • Messaging definitions will be read and used in the messaging tests

3.7 Can I use the Pact Broker?

When using Pact you can use the Pact Broker +META-INF/com.example/foo/1.0.0/

  • Stub servers will be started and fed with mappings
  • Messaging definitions will be read and used in the messaging tests
  • 3.7 Can I use the Pact Broker?

    When using Pact you can use the Pact Broker to store and share Pact definitions. Starting from Spring Cloud Contract 2.0.0 one can fetch Pact files from the Pact Broker to generate tests and stubs.

    As a prerequisite the Pact Converter and Pact Stub Downloader diff --git a/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html b/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html index cab7f0cf59..d0d92462d0 100644 --- a/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html +++ b/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html @@ -158,9 +158,9 @@ publishing { } }

    6.3 Stub Runner Core

    Runs stubs for service collaborators. Treating stubs as contracts of services allows to use stub-runner as an implementation of -Consumer Driven Contracts.

    Stub Runner allows you to automatically download the stubs of the provided dependencies (or pick those from the classpath), start WireMock servers for them and feed them with proper stub definitions. +Consumer Driven Contracts.

    Stub Runner allows you to automatically download the stubs of the provided dependencies (or pick those from the classpath), start WireMock servers for them and feed them with proper stub definitions. For messaging, special stub routes are defined.

    6.3.1 Retrieving stubs

    You can pick the following options of acquiring stubs

    • Aether based solution that downloads JARs with stubs from Artifactory / Nexus
    • Classpath scanning solution that searches classpath via pattern to retrieve stubs
    • Write your own implementation of the org.springframework.cloud.contract.stubrunner.StubDownloaderBuilder for full customization

    The latter example is described in the Custom Stub Runner section.

    Stub downloading

    You can control the stub downloading via the stubsMode switch. It picks value from the -StubRunnerProperties.StubsMode enum. You can use the following options

    • StubRunnerProperties.StubsMode.CLASSPATH (default value) - will pick stubs from the classpath
    • StubRunnerProperties.StubsMode.LOCAL - will pick stubs from a local storage (e.g. .m2)
    • StubRunnerProperties.StubsMode.REMOTE - will pick stubs from a remote location

    Example:

    @AutoConfigureStubRunner(repositoryRoot="http://foo.bar", ids = "com.example:beer-api-producer:+:stubs:8095", stubsMode = StubRunnerProperties.StubsMode.LOCAL)

    Classpath scanning

    If you set the stubsMode property to StubRunnerProperties.StubsMode.CLASSPATH +StubRunnerProperties.StubsMode enum. You can use the following options

    • StubRunnerProperties.StubsMode.CLASSPATH (default value) - will pick stubs from the classpath
    • StubRunnerProperties.StubsMode.LOCAL - will pick stubs from a local storage (e.g. .m2)
    • StubRunnerProperties.StubsMode.REMOTE - will pick stubs from a remote location

    Example:

    @AutoConfigureStubRunner(repositoryRoot="https://foo.bar", ids = "com.example:beer-api-producer:+:stubs:8095", stubsMode = StubRunnerProperties.StubsMode.LOCAL)

    Classpath scanning

    If you set the stubsMode property to StubRunnerProperties.StubsMode.CLASSPATH (or set nothing since CLASSPATH is the default value) then classpath will get scanned. Let’s look at the following example:

    @AutoConfigureStubRunner(ids = {
         "com.example:beer-api-producer:+:stubs:8095",
    @@ -513,7 +513,7 @@ via the following system properties or environment variables

    Spring Cloud Pipelines project for more information.

    6.6.1 How to use it?

    Stub Runner Server

    Just add the

    compile "org.springframework.cloud:spring-cloud-starter-stub-runner"

    Annotate a class with @EnableStubRunnerServer, build a fat-jar and you’re ready to go!

    For the properties check the Stub Runner Spring section.

    Stub Runner Server Fat Jar

    You can download a standalone JAR from Maven (for example, for version 1.2.3.RELEASE), as follows:

    $ wget -O stub-runner.jar 'https://search.maven.org/remote_content?g=org.springframework.cloud&a=spring-cloud-contract-stub-runner-boot&v=1.2.3.RELEASE'
    -$ java -jar stub-runner.jar --stubrunner.ids=... --stubrunner.repositoryRoot=...

    Spring Cloud CLI

    Starting from 1.4.0.RELEASE version of the Spring Cloud CLI +$ java -jar stub-runner.jar --stubrunner.ids=... --stubrunner.repositoryRoot=...

    Spring Cloud CLI

    Starting from 1.4.0.RELEASE version of the Spring Cloud CLI project you can start Stub Runner Boot by executing spring cloud stubrunner.

    In order to pass the configuration just create a stubrunner.yml file in the current working directory or a subdirectory called config or in ~/.spring-cloud. The file could look like this (example for running stubs installed locally)

    stubrunner.yml.  @@ -630,7 +630,7 @@ the Stub Runner server. It will be available at port 8750< }

    As you can see we want to start a Stub Runner Boot server @EnableStubRunnerServer, enable Eureka client @EnableEurekaClient and we want to have the stub runner feature turned on @AutoConfigureStubRunner.

    Now let’s assume that we want to start this application so that the stubs get automatically registered. We can do it by running the app java -jar ${SYSTEM_PROPS} stub-runner-boot-eureka-example.jar where - ${SYSTEM_PROPS} would contain the following list of properties

    -Dstubrunner.repositoryRoot=http://repo.spring.io/snapshots (1)
    + ${SYSTEM_PROPS} would contain the following list of properties

    -Dstubrunner.repositoryRoot=https://repo.spring.io/snapshots (1)
     -Dstubrunner.cloud.stubbed.discovery.enabled=false (2)
     -Dstubrunner.ids=org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer,org.springframework.cloud.contract.verifier.stubs:bootService (3)
     -Dstubrunner.idsToServiceIds.fraudDetectionServer=someNameThatShouldMapFraudDetectionServer (4)
    diff --git a/2.0.x/multi/multi__spring_cloud_contract_verifier_introduction.html b/2.0.x/multi/multi__spring_cloud_contract_verifier_introduction.html
    index 0b0f29c12c..80b39ee594 100644
    --- a/2.0.x/multi/multi__spring_cloud_contract_verifier_introduction.html
    +++ b/2.0.x/multi/multi__spring_cloud_contract_verifier_introduction.html
    @@ -62,7 +62,7 @@ in place yet, so the automatically-generated contract tests fail.

    < pass the stub artifact IDs and artifact repository URL as Spring Cloud Contract Stub Runner properties, as shown in the following example:

    stubrunner:
       ids: 'com.example:http-server-dsl:+:stubs:8080'
    -  repositoryRoot: http://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, + repositoryRoot: https://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, provide the group-id and artifact-id values for Spring Cloud Contract Stub Runner to run the collaborators' stubs for you, as shown in the following example:

    @RunWith(SpringRunner.class)
     @SpringBootTest(webEnvironment=WebEnvironment.NONE)
    @@ -223,7 +223,7 @@ in place, so the automatically-generated contract tests fail.

    Spring Cloud Contract Stub Runner
    properties, as shown in the following example:

    stubrunner:
       ids: 'com.example:http-server-dsl:+:stubs:8080'
    -  repositoryRoot: http://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, + repositoryRoot: https://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, provide the group-id and artifact-id for Spring Cloud Contract Stub Runner to run the collaborators' stubs for you, as shown in the following example:

    @RunWith(SpringRunner.class)
     @SpringBootTest(webEnvironment=WebEnvironment.NONE)
    @@ -767,8 +767,8 @@ side are automatically downloaded from Nexus/Artifactory. You can set the value
     stubsMode to REMOTE. The following code shows an example of
     achieving the same thing by changing the properties.

    stubrunner:
       ids: 'com.example:http-server-dsl:+:stubs:8080'
    -  repositoryRoot: http://repo.spring.io/libs-snapshot

    That’s it!

    2.5 Dependencies

    The best way to add dependencies is to use the proper starter dependency.

    For stub-runner, use spring-cloud-starter-stub-runner. When you use a plugin, add + repositoryRoot: https://repo.spring.io/libs-snapshot

    That’s it!

    2.5 Dependencies

    The best way to add dependencies is to use the proper starter dependency.

    For stub-runner, use spring-cloud-starter-stub-runner. When you use a plugin, add spring-cloud-starter-contract-verifier.

    2.6 Additional Links

    Here are some resources related to Spring Cloud Contract Verifier and Stub Runner. Note that some may be outdated, because the Spring Cloud Contract Verifier project is under -constant development.

    2.6.1 Spring Cloud Contract video

    You can check out the video from the Warsaw JUG about Spring Cloud Contract:

    2.6.2 Readings

    2.7 Samples

    You can find some samples at +constant development.

    2.6.1 Spring Cloud Contract video

    You can check out the video from the Warsaw JUG about Spring Cloud Contract:

    2.6.2 Readings

    2.7 Samples

    You can find some samples at samples.

    \ No newline at end of file diff --git a/2.0.x/multi/multi__spring_cloud_contract_verifier_setup.html b/2.0.x/multi/multi__spring_cloud_contract_verifier_setup.html index f90a8ccdc5..a989ebb84d 100644 --- a/2.0.x/multi/multi__spring_cloud_contract_verifier_setup.html +++ b/2.0.x/multi/multi__spring_cloud_contract_verifier_setup.html @@ -3,7 +3,7 @@ 4. Spring Cloud Contract Verifier Setup

    4. Spring Cloud Contract Verifier Setup

    You can set up Spring Cloud Contract Verifier in the following ways:

    4.1 Gradle Project

    To learn how to set up the Gradle project for Spring Cloud Contract Verifier, read the following sections:

    4.1.1 Prerequisites

    In order to use Spring Cloud Contract Verifier with WireMock, you muse use either a Gradle or a Maven plugin.

    [Warning]Warning

    If you want to use Spock in your projects, you must add separately the -spock-core and spock-spring modules. Check Spock +spock-core and spock-spring modules. Check Spock docs for more information

    4.1.2 Add Gradle Plugin with Dependencies

    To add a Gradle plugin with dependencies, use code similar to this:

    buildscript {
     	repositories {
     		mavenCentral()
    @@ -646,7 +646,7 @@ like them to be available for others to download / reference or reuse. In case
     of the JVM world those artifacts would be JARs, for Ruby these are gems
     and for Docker those would be Docker images. You can store those artifacts
     in a manager. Examples of such managers can be Artifactory
    -or Nexus.

    4.6.2 How it works

    The image searches for contracts under the /contracts folder. +or Nexus.

    4.6.2 How it works

    The image searches for contracts under the /contracts folder. The output from running the tests will be available under /spring-cloud-contract/build folder (it’s useful for debugging purposes).

    It’s enough for you to mount your contracts, pass the environment variables diff --git a/2.0.x/multi/multi__spring_cloud_contract_wiremock.html b/2.0.x/multi/multi__spring_cloud_contract_wiremock.html index 9b28ba3765..cfa75d78be 100644 --- a/2.0.x/multi/multi__spring_cloud_contract_wiremock.html +++ b/2.0.x/multi/multi__spring_cloud_contract_wiremock.html @@ -129,7 +129,7 @@ a Spring MockRestServiceServer. The following code public void contextLoads() throws Exception { // will read stubs classpath MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate) - .baseUrl("http://example.org").stubs("classpath:/stubs/resource.json") + .baseUrl("https://example.org").stubs("classpath:/stubs/resource.json") .build(); // We're asserting if WireMock responded properly assertThat(this.service.go()).isEqualTo("Hello World"); @@ -138,7 +138,7 @@ a Spring MockRestServiceServer. The following code }

    The baseUrl value is prepended to all mock calls, and the stubs() method takes a stub path resource pattern as an argument. In the preceding example, the stub defined at /stubs/resource.json is loaded into the mock server. If the RestTemplate is asked to -visit http://example.org/, it gets the responses as being declared at that URL. More +visit https://example.org/, it gets the responses as being declared at that URL. More than one stub pattern can be specified, and each one can be a directory (for a recursive list of all ".json"), a fixed filename (as in the example above), or an Ant-style pattern. The JSON format is the normal WireMock format, which you can read about in the diff --git a/2.0.x/multi/multi_contract-dsl.html b/2.0.x/multi/multi_contract-dsl.html index e5ac5e51f6..86bec3df68 100644 --- a/2.0.x/multi/multi_contract-dsl.html +++ b/2.0.x/multi/multi_contract-dsl.html @@ -41,7 +41,7 @@ the Contract class: import or "id":"01fbe706f872cb32", "name":"Washington", "place_type":"city", - "url": "http://api.twitter.com/1/geo/id/01fbe706f872cb32.json" + "url": "https://api.twitter.com/1/geo/id/01fbe706f872cb32.json" } }] ''' @@ -918,7 +918,7 @@ you reference a bunch of elements from the HTTP request. You can use the followi options:

    • fromRequest().url(): Returns the request URL and query parameters.
    • fromRequest().query(String key): Returns the first query parameter with a given name.
    • fromRequest().query(String key, int index): Returns the nth query parameter with a given name.
    • fromRequest().path(): Returns the full path.
    • fromRequest().path(int index): Returns the nth path element.
    • fromRequest().header(String key): Returns the first header with a given name.
    • fromRequest().header(String key, int index): Returns the nth header with a given name.
    • fromRequest().body(): Returns the full request body.
    • fromRequest().body(String jsonPath): Returns the element from the request that matches the JSON Path.

    If you’re using the YAML contract definition you have to use the -Handlebars {{{ }}} notation with custom, Spring Cloud Contract +Handlebars {{{ }}} notation with custom, Spring Cloud Contract functions to achieve this.

    • {{{ request.url }}}: Returns the request URL and query parameters.
    • {{{ request.query.key.[index] }}}: Returns the nth query parameter with a given name. E.g. for key foo, first entry {{{ request.query.foo.[0] }}}
    • {{{ request.path }}}: Returns the full path.
    • {{{ request.path.[index] }}}: Returns the nth path element. E.g. for first entry `{{{ request.path.[0] }}}
    • {{{ request.headers.key }}}: Returns the first header with a given name.
    • {{{ request.headers.key.[index] }}}: Returns the nth header with a given name.
    • {{{ request.body }}}: Returns the full request body.
    • {{{ jsonpath this 'your.json.path' }}}: Returns the element from the request that diff --git a/2.0.x/single/spring-cloud-contract.html b/2.0.x/single/spring-cloud-contract.html index 0bd3142c19..a573483862 100644 --- a/2.0.x/single/spring-cloud-contract.html +++ b/2.0.x/single/spring-cloud-contract.html @@ -67,7 +67,7 @@ in place yet, so the automatically-generated contract tests fail.

      < pass the stub artifact IDs and artifact repository URL as Spring Cloud Contract Stub Runner properties, as shown in the following example:

      stubrunner:
         ids: 'com.example:http-server-dsl:+:stubs:8080'
      -  repositoryRoot: http://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, + repositoryRoot: https://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, provide the group-id and artifact-id values for Spring Cloud Contract Stub Runner to run the collaborators' stubs for you, as shown in the following example:

    @RunWith(SpringRunner.class)
     @SpringBootTest(webEnvironment=WebEnvironment.NONE)
    @@ -228,7 +228,7 @@ in place, so the automatically-generated contract tests fail.

    Spring Cloud Contract Stub Runner
    properties, as shown in the following example:

    stubrunner:
       ids: 'com.example:http-server-dsl:+:stubs:8080'
    -  repositoryRoot: http://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, + repositoryRoot: https://repo.spring.io/libs-snapshot

    Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, provide the group-id and artifact-id for Spring Cloud Contract Stub Runner to run the collaborators' stubs for you, as shown in the following example:

    @RunWith(SpringRunner.class)
     @SpringBootTest(webEnvironment=WebEnvironment.NONE)
    @@ -772,10 +772,10 @@ side are automatically downloaded from Nexus/Artifactory. You can set the value
     stubsMode to REMOTE. The following code shows an example of
     achieving the same thing by changing the properties.

    stubrunner:
       ids: 'com.example:http-server-dsl:+:stubs:8080'
    -  repositoryRoot: http://repo.spring.io/libs-snapshot

    That’s it!

    2.5 Dependencies

    The best way to add dependencies is to use the proper starter dependency.

    For stub-runner, use spring-cloud-starter-stub-runner. When you use a plugin, add + repositoryRoot: https://repo.spring.io/libs-snapshot

    That’s it!

    2.5 Dependencies

    The best way to add dependencies is to use the proper starter dependency.

    For stub-runner, use spring-cloud-starter-stub-runner. When you use a plugin, add spring-cloud-starter-contract-verifier.

    2.6 Additional Links

    Here are some resources related to Spring Cloud Contract Verifier and Stub Runner. Note that some may be outdated, because the Spring Cloud Contract Verifier project is under -constant development.

    2.6.1 Spring Cloud Contract video

    You can check out the video from the Warsaw JUG about Spring Cloud Contract:

    2.7 Samples

    You can find some samples at +constant development.

    2.6.1 Spring Cloud Contract video

    You can check out the video from the Warsaw JUG about Spring Cloud Contract:

    2.7 Samples

    You can find some samples at samples.

    3. Spring Cloud Contract FAQ

    3.1 Why use Spring Cloud Contract Verifier and not X ?

    For the time being Spring Cloud Contract is a JVM based tool. So it could be your first pick when you’re already creating software for the JVM. This project has a lot of really interesting features but especially quite a few of them definitely make Spring Cloud Contract Verifier stand out on the "market" of Consumer Driven Contract (CDC) tooling. Out of many the most interesting are:

    • Possibility to do CDC with messaging
    • Clear and easy to use, statically typed DSL
    • Possibility to copy paste your current JSON file to the contract and only edit its elements
    • Automatic generation of tests from the defined Contract
    • Stub Runner functionality - the stubs are automatically downloaded at runtime from Nexus / Artifactory
    • Spring Cloud integration - no discovery service is needed for integration tests
    • Spring Cloud Contract integrates with Pact out of the box and provides easy hooks to extend its functionality
    • Via Docker adds support for any language & framework used

    3.2 I don’t want to write a contract in Groovy!

    No problem. You can write a contract in YAML!

    3.3 What is this value(consumer(), producer()) ?

    One of the biggest challenges related to stubs is their reusability. Only if they can be vastly used, will they serve their purpose. @@ -1051,7 +1051,7 @@ Those poms are necessary for the consumer side to run mvn is that the producer doesn’t own the contracts anymore. So the consumer and the producer have to work on common contracts in a common repository.

    3.5.3 Consumer

    When the consumer wants to work on the contracts offline, instead of cloning the producer code, the consumer team clones the common repository, goes to the required producer’s folder (e.g. com/example/server) -and runs mvn clean install -DskipTests to install locally the stubs converted from the contracts.

    [Tip]Tip

    You need to have Maven installed locally

    3.5.4 Producer

    As a producer it’s enough to alter the Spring Cloud Contract Verifier to provide the URL and the dependency +and runs mvn clean install -DskipTests to install locally the stubs converted from the contracts.

    [Tip]Tip

    You need to have Maven installed locally

    3.5.4 Producer

    As a producer it’s enough to alter the Spring Cloud Contract Verifier to provide the URL and the dependency of the JAR containing the contracts:

    <plugin>
     	<groupId>org.springframework.cloud</groupId>
     	<artifactId>spring-cloud-contract-maven-plugin</artifactId>
    @@ -1283,7 +1283,7 @@ SCM repository, prefixed with the protocol. For example

    "com.example:bookstore:0.0.1.RELEASE"
     )

    With such a setup:

    • Git project will be cloned to a temporary directory
    • The SCM stub downloader will go to META-INF/groupId/artifactId/version/ folder to find stub definitions and contracts. E.g. for com.example:foo:1.0.0 the path would be -META-INF/com.example/foo/1.0.0/
    • Stub servers will be started and fed with mappings
    • Messaging definitions will be read and used in the messaging tests

    3.7 Can I use the Pact Broker?

    When using Pact you can use the Pact Broker +META-INF/com.example/foo/1.0.0/

  • Stub servers will be started and fed with mappings
  • Messaging definitions will be read and used in the messaging tests
  • 3.7 Can I use the Pact Broker?

    When using Pact you can use the Pact Broker to store and share Pact definitions. Starting from Spring Cloud Contract 2.0.0 one can fetch Pact files from the Pact Broker to generate tests and stubs.

    As a prerequisite the Pact Converter and Pact Stub Downloader @@ -1423,7 +1423,7 @@ DSL and provide a path relative to where the contract lays. If you’re using YAML just use the bodyFromFile property.

    4. Spring Cloud Contract Verifier Setup

    You can set up Spring Cloud Contract Verifier in the following ways:

    4.1 Gradle Project

    To learn how to set up the Gradle project for Spring Cloud Contract Verifier, read the following sections:

    4.1.1 Prerequisites

    In order to use Spring Cloud Contract Verifier with WireMock, you muse use either a Gradle or a Maven plugin.

    [Warning]Warning

    If you want to use Spock in your projects, you must add separately the -spock-core and spock-spring modules. Check Spock +spock-core and spock-spring modules. Check Spock docs for more information

    4.1.2 Add Gradle Plugin with Dependencies

    To add a Gradle plugin with dependencies, use code similar to this:

    buildscript {
     	repositories {
     		mavenCentral()
    @@ -2066,7 +2066,7 @@ like them to be available for others to download / reference or reuse. In case
     of the JVM world those artifacts would be JARs, for Ruby these are gems
     and for Docker those would be Docker images. You can store those artifacts
     in a manager. Examples of such managers can be Artifactory
    -or Nexus.

    4.6.2 How it works

    The image searches for contracts under the /contracts folder. +or Nexus.

    4.6.2 How it works

    The image searches for contracts under the /contracts folder. The output from running the tests will be available under /spring-cloud-contract/build folder (it’s useful for debugging purposes).

    It’s enough for you to mount your contracts, pass the environment variables @@ -2529,9 +2529,9 @@ publishing { } }

    6.3 Stub Runner Core

    Runs stubs for service collaborators. Treating stubs as contracts of services allows to use stub-runner as an implementation of -Consumer Driven Contracts.

    Stub Runner allows you to automatically download the stubs of the provided dependencies (or pick those from the classpath), start WireMock servers for them and feed them with proper stub definitions. +Consumer Driven Contracts.

    Stub Runner allows you to automatically download the stubs of the provided dependencies (or pick those from the classpath), start WireMock servers for them and feed them with proper stub definitions. For messaging, special stub routes are defined.

    6.3.1 Retrieving stubs

    You can pick the following options of acquiring stubs

    • Aether based solution that downloads JARs with stubs from Artifactory / Nexus
    • Classpath scanning solution that searches classpath via pattern to retrieve stubs
    • Write your own implementation of the org.springframework.cloud.contract.stubrunner.StubDownloaderBuilder for full customization

    The latter example is described in the Custom Stub Runner section.

    Stub downloading

    You can control the stub downloading via the stubsMode switch. It picks value from the -StubRunnerProperties.StubsMode enum. You can use the following options

    • StubRunnerProperties.StubsMode.CLASSPATH (default value) - will pick stubs from the classpath
    • StubRunnerProperties.StubsMode.LOCAL - will pick stubs from a local storage (e.g. .m2)
    • StubRunnerProperties.StubsMode.REMOTE - will pick stubs from a remote location

    Example:

    @AutoConfigureStubRunner(repositoryRoot="http://foo.bar", ids = "com.example:beer-api-producer:+:stubs:8095", stubsMode = StubRunnerProperties.StubsMode.LOCAL)

    Classpath scanning

    If you set the stubsMode property to StubRunnerProperties.StubsMode.CLASSPATH +StubRunnerProperties.StubsMode enum. You can use the following options

    • StubRunnerProperties.StubsMode.CLASSPATH (default value) - will pick stubs from the classpath
    • StubRunnerProperties.StubsMode.LOCAL - will pick stubs from a local storage (e.g. .m2)
    • StubRunnerProperties.StubsMode.REMOTE - will pick stubs from a remote location

    Example:

    @AutoConfigureStubRunner(repositoryRoot="https://foo.bar", ids = "com.example:beer-api-producer:+:stubs:8095", stubsMode = StubRunnerProperties.StubsMode.LOCAL)

    Classpath scanning

    If you set the stubsMode property to StubRunnerProperties.StubsMode.CLASSPATH (or set nothing since CLASSPATH is the default value) then classpath will get scanned. Let’s look at the following example:

    @AutoConfigureStubRunner(ids = {
         "com.example:beer-api-producer:+:stubs:8095",
    @@ -2884,7 +2884,7 @@ via the following system properties or environment variables

    Spring Cloud Pipelines project for more information.

    6.6.1 How to use it?

    Stub Runner Server

    Just add the

    compile "org.springframework.cloud:spring-cloud-starter-stub-runner"

    Annotate a class with @EnableStubRunnerServer, build a fat-jar and you’re ready to go!

    For the properties check the Stub Runner Spring section.

    Stub Runner Server Fat Jar

    You can download a standalone JAR from Maven (for example, for version 1.2.3.RELEASE), as follows:

    $ wget -O stub-runner.jar 'https://search.maven.org/remote_content?g=org.springframework.cloud&a=spring-cloud-contract-stub-runner-boot&v=1.2.3.RELEASE'
    -$ java -jar stub-runner.jar --stubrunner.ids=... --stubrunner.repositoryRoot=...

    Spring Cloud CLI

    Starting from 1.4.0.RELEASE version of the Spring Cloud CLI +$ java -jar stub-runner.jar --stubrunner.ids=... --stubrunner.repositoryRoot=...

    Spring Cloud CLI

    Starting from 1.4.0.RELEASE version of the Spring Cloud CLI project you can start Stub Runner Boot by executing spring cloud stubrunner.

    In order to pass the configuration just create a stubrunner.yml file in the current working directory or a subdirectory called config or in ~/.spring-cloud. The file could look like this (example for running stubs installed locally)

    stubrunner.yml.  @@ -3001,7 +3001,7 @@ the Stub Runner server. It will be available at port 8750< }

    As you can see we want to start a Stub Runner Boot server @EnableStubRunnerServer, enable Eureka client @EnableEurekaClient and we want to have the stub runner feature turned on @AutoConfigureStubRunner.

    Now let’s assume that we want to start this application so that the stubs get automatically registered. We can do it by running the app java -jar ${SYSTEM_PROPS} stub-runner-boot-eureka-example.jar where - ${SYSTEM_PROPS} would contain the following list of properties

    -Dstubrunner.repositoryRoot=http://repo.spring.io/snapshots (1)
    + ${SYSTEM_PROPS} would contain the following list of properties

    -Dstubrunner.repositoryRoot=https://repo.spring.io/snapshots (1)
     -Dstubrunner.cloud.stubbed.discovery.enabled=false (2)
     -Dstubrunner.ids=org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer,org.springframework.cloud.contract.verifier.stubs:bootService (3)
     -Dstubrunner.idsToServiceIds.fraudDetectionServer=someNameThatShouldMapFraudDetectionServer (4)
    @@ -3434,7 +3434,7 @@ the Contract class: import or
     				"id":"01fbe706f872cb32",
     				"name":"Washington",
     				"place_type":"city",
    -				"url": "http://api.twitter.com/1/geo/id/01fbe706f872cb32.json"
    +				"url": "https://api.twitter.com/1/geo/id/01fbe706f872cb32.json"
     			}
     		}]
     	'''
    @@ -4311,7 +4311,7 @@ you reference a bunch of elements from the HTTP request. You can use the followi
     options:

    • fromRequest().url(): Returns the request URL and query parameters.
    • fromRequest().query(String key): Returns the first query parameter with a given name.
    • fromRequest().query(String key, int index): Returns the nth query parameter with a given name.
    • fromRequest().path(): Returns the full path.
    • fromRequest().path(int index): Returns the nth path element.
    • fromRequest().header(String key): Returns the first header with a given name.
    • fromRequest().header(String key, int index): Returns the nth header with a given name.
    • fromRequest().body(): Returns the full request body.
    • fromRequest().body(String jsonPath): Returns the element from the request that matches the JSON Path.

    If you’re using the YAML contract definition you have to use the -Handlebars {{{ }}} notation with custom, Spring Cloud Contract +Handlebars {{{ }}} notation with custom, Spring Cloud Contract functions to achieve this.

    • {{{ request.url }}}: Returns the request URL and query parameters.
    • {{{ request.query.key.[index] }}}: Returns the nth query parameter with a given name. E.g. for key foo, first entry {{{ request.query.foo.[0] }}}
    • {{{ request.path }}}: Returns the full path.
    • {{{ request.path.[index] }}}: Returns the nth path element. E.g. for first entry `{{{ request.path.[0] }}}
    • {{{ request.headers.key }}}: Returns the first header with a given name.
    • {{{ request.headers.key.[index] }}}: Returns the nth header with a given name.
    • {{{ request.body }}}: Returns the full request body.
    • {{{ jsonpath this 'your.json.path' }}}: Returns the element from the request that @@ -6232,7 +6232,7 @@ a Spring MockRestServiceServer. The following code public void contextLoads() throws Exception { // will read stubs classpath MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate) - .baseUrl("http://example.org").stubs("classpath:/stubs/resource.json") + .baseUrl("https://example.org").stubs("classpath:/stubs/resource.json") .build(); // We're asserting if WireMock responded properly assertThat(this.service.go()).isEqualTo("Hello World"); @@ -6241,7 +6241,7 @@ a Spring MockRestServiceServer. The following code }

    The baseUrl value is prepended to all mock calls, and the stubs() method takes a stub path resource pattern as an argument. In the preceding example, the stub defined at /stubs/resource.json is loaded into the mock server. If the RestTemplate is asked to -visit http://example.org/, it gets the responses as being declared at that URL. More +visit https://example.org/, it gets the responses as being declared at that URL. More than one stub pattern can be specified, and each one can be a directory (for a recursive list of all ".json"), a fixed filename (as in the example above), or an Ant-style pattern. The JSON format is the normal WireMock format, which you can read about in the @@ -6458,7 +6458,7 @@ structure presented in the previous snippet.

    Maven.&nbs <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 https://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>stubs</id> <formats> <format>jar</format> diff --git a/2.0.x/spring-cloud-contract-maven-plugin/license.html b/2.0.x/spring-cloud-contract-maven-plugin/license.html index c10cde60a8..3c8bf8342d 100644 --- a/2.0.x/spring-cloud-contract-maven-plugin/license.html +++ b/2.0.x/spring-cloud-contract-maven-plugin/license.html @@ -344,103 +344,268 @@ limitations under the License.

    - - - - -
    -
    -
    - Apache Logo -
    -
    - - - -
    -
    -
    - - +
    -
    -
    + + + +
    +
    + ApacheCon is Coming 9-12 Sept. 2019 - Las Vegas + The Apache Software Foundation +
    + +
    + Apache Support Logo +
    +
    +

    Apache License

    Version 2.0, January 2004

    http://www.apache.org/licenses/

    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

    @@ -710,8 +886,8 @@ limitations under the License.
    -

    Copyright © 2018 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.

    -

    Apache and the Apache feather logo are trademarks of The Apache Software Foundation.

    +

    Copyright © 2019 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.

    +

    Apache and the Apache feather logo are trademarks of The Apache Software Foundation.

    @@ -720,8 +896,21 @@ limitations under the License. - - + + +
    diff --git a/2.0.x/spring-cloud-contract.xml b/2.0.x/spring-cloud-contract.xml index d54a7b7374..223fc40eea 100644 --- a/2.0.x/spring-cloud-contract.xml +++ b/2.0.x/spring-cloud-contract.xml @@ -246,7 +246,7 @@ pass the stub artifact IDs and artifact repository URL as Spring Cloud Stub Runner properties, as shown in the following example: stubrunner: ids: 'com.example:http-server-dsl:+:stubs:8080' - repositoryRoot: http://repo.spring.io/libs-snapshot + repositoryRoot: https://repo.spring.io/libs-snapshot Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, @@ -492,7 +492,7 @@ pass the stub artifact IDs and artifact repository URl as Spring Cloud Runner properties, as shown in the following example: stubrunner: ids: 'com.example:http-server-dsl:+:stubs:8080' - repositoryRoot: http://repo.spring.io/libs-snapshot + repositoryRoot: https://repo.spring.io/libs-snapshot Now you can annotate your test class with @AutoConfigureStubRunner. In the annotation, @@ -1276,7 +1276,7 @@ side are automatically downloaded from Nexus/Artifactory. You can set the value achieving the same thing by changing the properties. stubrunner: ids: 'com.example:http-server-dsl:+:stubs:8080' - repositoryRoot: http://repo.spring.io/libs-snapshot + repositoryRoot: https://repo.spring.io/libs-snapshot That’s it! @@ -1300,7 +1300,7 @@ constant development. Readings -Slides from Marcin Grzejszczak’s talk about Accurest +Slides from Marcin Grzejszczak’s talk about Accurest Accurest related articles from Marcin Grzejszczak’s blog @@ -1725,7 +1725,7 @@ Those poms are necessary for the consumer side to run mvn clean install consumer team clones the common repository, goes to the required producer’s folder (e.g. com/example/server) and runs mvn clean install -DskipTests to install locally the stubs converted from the contracts. -You need to have Maven installed locally +You need to have Maven installed locally
    @@ -2143,7 +2143,7 @@ to find stub definitions and contracts. E.g. for com.example:foo:1.0.0<
    Can I use the Pact Broker? -When using Pact you can use the Pact Broker +When using Pact you can use the Pact Broker to store and share Pact definitions. Starting from Spring Cloud Contract 2.0.0 one can fetch Pact files from the Pact Broker to generate tests and stubs. @@ -2427,7 +2427,7 @@ following sections: Gradle or a Maven plugin. If you want to use Spock in your projects, you must add separately the -spock-core and spock-spring modules. Check Spock +spock-core and spock-spring modules. Check Spock docs for more information
    @@ -3508,7 +3508,7 @@ like them to be available for others to download / reference or reuse. In case of the JVM world those artifacts would be JARs, for Ruby these are gems and for Docker those would be Docker images. You can store those artifacts in a manager. Examples of such managers can be Artifactory -or Nexus. +or Nexus.
    @@ -4266,7 +4266,7 @@ publishing {
    Stub Runner Core Runs stubs for service collaborators. Treating stubs as contracts of services allows to use stub-runner as an implementation of -Consumer Driven Contracts. +Consumer Driven Contracts. Stub Runner allows you to automatically download the stubs of the provided dependencies (or pick those from the classpath), start WireMock servers for them and feed them with proper stub definitions. For messaging, special stub routes are defined.
    @@ -4300,7 +4300,7 @@ For messaging, special stub routes are defined. Example: -@AutoConfigureStubRunner(repositoryRoot="http://foo.bar", ids = "com.example:beer-api-producer:+:stubs:8095", stubsMode = StubRunnerProperties.StubsMode.LOCAL) +@AutoConfigureStubRunner(repositoryRoot="https://foo.bar", ids = "com.example:beer-api-producer:+:stubs:8095", stubsMode = StubRunnerProperties.StubsMode.LOCAL)
    Classpath scanning @@ -4890,7 +4890,7 @@ $ java -jar stub-runner.jar --stubrunner.ids=... --stubrunner.repositoryRoot=...
    Spring Cloud CLI -Starting from 1.4.0.RELEASE version of the Spring Cloud CLI +Starting from 1.4.0.RELEASE version of the Spring Cloud CLI project you can start Stub Runner Boot by executing spring cloud stubrunner. In order to pass the configuration just create a stubrunner.yml file in the current working directory or a subdirectory called config or in ~/.spring-cloud. The file could look like this @@ -5056,7 +5056,7 @@ and we want to have the stub runner feature turned on @AutoConfigureStu Now let’s assume that we want to start this application so that the stubs get automatically registered. We can do it by running the app java -jar ${SYSTEM_PROPS} stub-runner-boot-eureka-example.jar where ${SYSTEM_PROPS} would contain the following list of properties --Dstubrunner.repositoryRoot=http://repo.spring.io/snapshots (1) +-Dstubrunner.repositoryRoot=https://repo.spring.io/snapshots (1) -Dstubrunner.cloud.stubbed.discovery.enabled=false (2) -Dstubrunner.ids=org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer,org.springframework.cloud.contract.verifier.stubs:bootService (3) -Dstubrunner.idsToServiceIds.fraudDetectionServer=someNameThatShouldMapFraudDetectionServer (4) @@ -5896,7 +5896,7 @@ the Contract class: import org.springframework.cloud "id":"01fbe706f872cb32", "name":"Washington", "place_type":"city", - "url": "http://api.twitter.com/1/geo/id/01fbe706f872cb32.json" + "url": "https://api.twitter.com/1/geo/id/01fbe706f872cb32.json" } }] ''' @@ -7131,7 +7131,7 @@ matches the JSON Path. If you’re using the YAML contract definition you have to use the -Handlebars {{{ }}} notation with custom, Spring Cloud Contract +Handlebars {{{ }}} notation with custom, Spring Cloud Contract functions to achieve this. @@ -9784,7 +9784,7 @@ public class WiremockForDocsMockServerApplicationTests { public void contextLoads() throws Exception { // will read stubs classpath MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate) - .baseUrl("http://example.org").stubs("classpath:/stubs/resource.json") + .baseUrl("https://example.org").stubs("classpath:/stubs/resource.json") .build(); // We're asserting if WireMock responded properly assertThat(this.service.go()).isEqualTo("Hello World"); @@ -9794,7 +9794,7 @@ public class WiremockForDocsMockServerApplicationTests { The baseUrl value is prepended to all mock calls, and the stubs() method takes a stub path resource pattern as an argument. In the preceding example, the stub defined at /stubs/resource.json is loaded into the mock server. If the RestTemplate is asked to -visit http://example.org/, it gets the responses as being declared at that URL. More +visit https://example.org/, it gets the responses as being declared at that URL. More than one stub pattern can be specified, and each one can be a directory (for a recursive list of all ".json"), a fixed filename (as in the example above), or an Ant-style pattern. The JSON format is the normal WireMock format, which you can read about in the @@ -10083,7 +10083,7 @@ structure presented in the previous snippet. <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 https://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>stubs</id> <formats> <format>jar</format>