diff --git a/multi/multi__customization.html b/multi/multi__customization.html index 6e067f360c..80d3ac0313 100644 --- a/multi/multi__customization.html +++ b/multi/multi__customization.html @@ -1,6 +1,6 @@ - 9. Customization

9. Customization

[Important]Important

This section is valid only for Groovy DSL

You can customize the Spring Cloud Contract Verifier by extending the DSL, as shown in + 9. Customization

9. Customization

[Important]Important

This section is valid only for Groovy DSL

You can customize the Spring Cloud Contract Verifier by extending the DSL, as shown in the remainder of this section.

9.1 Extending the DSL

You can provide your own functions to the DSL. The key requirement for this feature is to maintain the static compatibility. Later in this document, you can see examples of:

  • Creating a JAR with reusable classes.
  • Referencing of these classes in the DSLs.

You can find the full example here.

9.1.1 Common JAR

The following examples show three classes that can be reused in the DSLs.

PatternUtils contains functions used by both the consumer and the producer.

package com.example;
@@ -135,7 +135,7 @@ maintain the static compatibility. Later in this document, you can see examples
 	}
 }
 //end::impl[]

9.1.2 Adding the Dependency to the Project

In order for the plugins and IDE to be able to reference the common JAR classes, you need -to pass the dependency to your project.

9.1.3 Test the Dependency in the Project’s Dependencies

First, add the common jar dependency as a test dependency. Because your contracts files +to pass the dependency to your project.

9.1.3 Test the Dependency in the Project’s Dependencies

First, add the common jar dependency as a test dependency. Because your contracts files are available on the test resources path, the common jar classes automatically become visible in your Groovy files. The following examples show how to test the dependency:

Maven. 

<dependency>
@@ -146,7 +146,7 @@ visible in your Groovy files. The following examples show how to test the depend
 </dependency>

Gradle. 

testCompile("com.example:beer-common:0.0.1-SNAPSHOT")

-

9.1.4 Test a Dependency in the Plugin’s Dependencies

Now, you must add the dependency for the plugin to reuse at runtime, as shown in the +

9.1.4 Test a Dependency in the Plugin’s Dependencies

Now, you must add the dependency for the plugin to reuse at runtime, as shown in the following example:

Maven. 

<plugin>
 	<groupId>org.springframework.cloud</groupId>
diff --git a/multi/multi__links.html b/multi/multi__links.html
index b8e41fb657..fb9dc1b235 100644
--- a/multi/multi__links.html
+++ b/multi/multi__links.html
@@ -1,6 +1,6 @@
 
       
-   13. Links

13. Links

The following links may be helpful when working with Spring Cloud Contract:

  • Spring Cloud Contract Github + 13. Links \ No newline at end of file diff --git a/multi/multi__migrations.html b/multi/multi__migrations.html index 9d777b3c08..1151a82dcb 100644 --- a/multi/multi__migrations.html +++ b/multi/multi__migrations.html @@ -1,6 +1,6 @@ - 12. Migrations

    12. Migrations

    - - + + @@ -356,20 +356,20 @@ - - + + - - + + - - + + @@ -380,8 +380,8 @@ - - + + @@ -411,8 +411,8 @@ - - + + diff --git a/spring-cloud-contract-maven-plugin/project-info.html b/spring-cloud-contract-maven-plugin/project-info.html index d3fa45ae6f..2f475b7299 100644 --- a/spring-cloud-contract-maven-plugin/project-info.html +++ b/spring-cloud-contract-maven-plugin/project-info.html @@ -1,13 +1,13 @@ - + Spring Cloud Contract Maven Plugin – Project Information @@ -146,7 +146,7 @@
    [Tip]Tip

    For up to date migration guides please visit + 12. Migrations

    12. Migrations

    [Tip]Tip

    For up to date migration guides please visit the project’s wiki page.

    This section covers migrating from one version of Spring Cloud Contract Verifier to the next version. It covers the following versions upgrade paths:

    12.1 1.0.x → 1.1.x

    This section covers upgrading from version 1.0 to version 1.1.

    12.1.1 New structure of generated stubs

    In 1.1.x we have introduced a change to the structure of generated stubs. If you have been using the @AutoConfigureWireMock notation to use the stubs from the classpath, @@ -80,7 +80,7 @@ structure presented in the previous snippet.

    Maven.&nbs from "${project.buildDir}/resources/main/customer-stubs/META-INF/${project.group}/${project.name}/${project.version}" into "${project.buildDir}/resources/main/customer-stubs" }

    -

    12.2 1.1.x → 1.2.x

    This section covers upgrading from version 1.1 to version 1.2.

    12.2.1 Custom HttpServerStub

    HttpServerStub includes a method that was not in version 1.1. The method is +

    12.2 1.1.x → 1.2.x

    This section covers upgrading from version 1.1 to version 1.2.

    12.2.1 Custom HttpServerStub

    HttpServerStub includes a method that was not in version 1.1. The method is String registeredMappings() If you have classes that implement HttpServerStub, you now have to implement the registeredMappings() method. It should return a String representing all mappings available in a single HttpServerStub.

    See issue 355 for more diff --git a/multi/multi__spring_cloud_contract.html b/multi/multi__spring_cloud_contract.html index 5bc65829c1..548bc7417a 100644 --- a/multi/multi__spring_cloud_contract.html +++ b/multi/multi__spring_cloud_contract.html @@ -1,6 +1,6 @@ - 1. Spring Cloud Contract

    1. Spring Cloud Contract

    You need confidence when pushing new features to a new application or service in a + 1. Spring Cloud Contract

    1. Spring Cloud Contract

    You need confidence when pushing new features to a new application or service in a distributed system. This project provides support for Consumer Driven Contracts and service schemas in Spring applications (for both HTTP and message-based interactions), covering a range of options for writing tests, publishing them as assets, and asserting diff --git a/multi/multi__spring_cloud_contract_faq.html b/multi/multi__spring_cloud_contract_faq.html index 42f390b2e1..d1e592fc75 100644 --- a/multi/multi__spring_cloud_contract_faq.html +++ b/multi/multi__spring_cloud_contract_faq.html @@ -1,8 +1,8 @@ - 3. Spring Cloud Contract FAQ

    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 + 3. Spring Cloud Contract FAQ

    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. +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. What typically makes that difficult are the hard-coded values of request / response elements. For example dates or ids. Imagine the following JSON request

    {
         "time" : "2016-10-10 20:10:15",
    @@ -357,7 +357,7 @@ configurations {
     deleteUnwantedContracts.dependsOn("unzipContracts")
     build.dependsOn("deleteUnwantedContracts")
    • Configure plugin by specifying the directory containing contracts using contractsDslDir property
    contracts {
         contractsDslDir = new File("${buildDir}/unpackedContracts")
    -}

    3.6 Do I need a Binary Storage? Can’t I use Git?

    In the polyglot world, there are languages that don’t use binary storages like +}

    3.6 Do I need a Binary Storage? Can’t I use Git?

    In the polyglot world, there are languages that don’t use binary storages like Artifactory or Nexus. Starting from Spring Cloud Contract version 2.0.0 we provide mechanisms to store contracts and stubs in a SCM repository. Currently the only supported SCM is Git.

    The repository would have to the following setup @@ -599,7 +599,7 @@ with pact:// protocol. E.g. p @StubRunnerPort("beer-api-producer-pact") int producerPort; //... }

    With such a setup:

    • Pact files will be downloaded from the Pact Broker
    • Spring Cloud Contract will convert the Pact files into stub definitions
    • The stub servers will be started and fed with stubs

    For more information about Pact support you can go to -the Section 10.7, “Using the Pact Stub Downloader” section.

    3.8 How can I debug the request/response being sent by the generated tests client?

    The generated tests all boil down to RestAssured in some form or fashion which relies on Apache HttpClient. HttpClient has a facility called wire logging which logs the entire request and response to HttpClient. Spring Boot has a logging common application property for doing this sort of thing, just add this to your application properties

    logging.level.org.apache.http.wire=DEBUG

    3.8.1 How can I debug the mapping/request/response being sent by WireMock?

    Starting from version 1.2.0 we turn on WireMock logging to +the Section 10.7, “Using the Pact Stub Downloader” section.

    3.8 How can I debug the request/response being sent by the generated tests client?

    The generated tests all boil down to RestAssured in some form or fashion which relies on Apache HttpClient. HttpClient has a facility called wire logging which logs the entire request and response to HttpClient. Spring Boot has a logging common application property for doing this sort of thing, just add this to your application properties

    logging.level.org.apache.http.wire=DEBUG

    3.8.1 How can I debug the mapping/request/response being sent by WireMock?

    Starting from version 1.2.0 we turn on WireMock logging to info and the WireMock notifier to being verbose. Now you will exactly know what request was received by WireMock server and which matching response definition was picked.

    To turn off this feature just bump WireMock logging to ERROR

    logging.level.com.github.tomakehurst.wiremock=ERROR

    3.8.2 How can I see what got registered in the HTTP server stub?

    You can use the mappingsOutputFolder property on @AutoConfigureStubRunner or StubRunnerRule diff --git a/multi/multi__spring_cloud_contract_stub_runner.html b/multi/multi__spring_cloud_contract_stub_runner.html index f821d04835..4b7720c6f5 100644 --- a/multi/multi__spring_cloud_contract_stub_runner.html +++ b/multi/multi__spring_cloud_contract_stub_runner.html @@ -1,6 +1,6 @@ - 6. Spring Cloud Contract Stub Runner

    6. Spring Cloud Contract Stub Runner

    One of the issues that you might encounter while using Spring Cloud Contract Verifier is + 6. Spring Cloud Contract Stub Runner

    6. Spring Cloud Contract Stub Runner

    One of the issues that you might encounter while using Spring Cloud Contract Verifier is passing the generated WireMock JSON stubs from the server side to the client side (or to various clients). The same takes place in terms of client-side generation for messaging.

    Copying the JSON files and setting the client side for messaging manually is out of the question. That is why we introduced Spring Cloud Contract Stub Runner. It can @@ -465,7 +465,8 @@ its methods as presented below:

    @Configuration
     	@EnableAutoConfiguration
     	static class Config {}
    -}

    for the following configuration file:

    stubrunner:
    +}
    +// end::test[]

    for the following configuration file:

    stubrunner:
       repositoryRoot: classpath:m2repo/repository/
       ids:
         - org.springframework.cloud.contract.verifier.stubs:loanIssuance
    @@ -496,7 +497,8 @@ or DiscoveryClient directly, to call those stubbed
     }

    for the following configuration file

    stubrunner:
       idsToServiceIds:
         ivyNotation: someValueInsideYourCode
    -    fraudDetectionServer: someNameThatShouldMapFraudDetectionServer

    Test profiles and service discovery

    In your integration tests you typically don’t want to call neither a discovery service (e.g. Eureka) + fraudDetectionServer: someNameThatShouldMapFraudDetectionServer +# end::ids[]

    Test profiles and service discovery

    In your integration tests you typically don’t want to call neither a discovery service (e.g. Eureka) or Config Server. That’s why you create an additional test configuration in which you want to disable these features.

    Due to certain limitations of spring-cloud-commons to achieve this you have disable these properties via a static block like presented below (example for Eureka)

        //Hack to work around https://github.com/spring-cloud/spring-cloud-commons/issues/156
    @@ -695,10 +697,10 @@ Or set the test as follows:

    foo-consumer in its name (i.e. those from the
     src/test/resources/contracts/foo-consumer/some/contracts/…​ folder) will be allowed to be referenced.

    You can check out issue 224 for more information about the reasons behind this change.

    6.8 Common

    This section briefly describes common properties, including:

    6.8.1 Common Properties for JUnit and Spring

    You can set repetitive properties by using system properties or Spring configuration -properties. Here are their names with their default values:

    Property nameDefault valueDescription

    stubrunner.minPort

    10000

    Minimum value of a port for a started WireMock with stubs.

    stubrunner.maxPort

    15000

    Maximum value of a port for a started WireMock with stubs.

    stubrunner.repositoryRoot

     

    Maven repo URL. If blank, then call the local maven repo.

    stubrunner.classifier

    stubs

    Default classifier for the stub artifacts.

    stubrunner.stubsMode

    CLASSPATH

    The way you want to fetch and register the stubs

    stubrunner.ids

     

    Array of Ivy notation stubs to download.

    stubrunner.username

     

    Optional username to access the tool that stores the JARs with -stubs.

    stubrunner.password

     

    Optional password to access the tool that stores the JARs with -stubs.

    stubrunner.stubsPerConsumer

    false

    Set to true if you want to use different stubs for -each consumer instead of registering all stubs for every consumer.

    stubrunner.consumerName

     

    If you want to use a stub for each consumer and want to +properties. Here are their names with their default values:

    Property nameDefault valueDescription

    stubrunner.minPort

    10000

    Minimum value of a port for a started WireMock with stubs.

    stubrunner.maxPort

    15000

    Maximum value of a port for a started WireMock with stubs.

    stubrunner.repositoryRoot

     

    Maven repo URL. If blank, then call the local maven repo.

    stubrunner.classifier

    stubs

    Default classifier for the stub artifacts.

    stubrunner.stubsMode

    CLASSPATH

    The way you want to fetch and register the stubs

    stubrunner.ids

     

    Array of Ivy notation stubs to download.

    stubrunner.username

     

    Optional username to access the tool that stores the JARs with +stubs.

    stubrunner.password

     

    Optional password to access the tool that stores the JARs with +stubs.

    stubrunner.stubsPerConsumer

    false

    Set to true if you want to use different stubs for +each consumer instead of registering all stubs for every consumer.

    stubrunner.consumerName

     

    If you want to use a stub for each consumer and want to override the consumer name just change this value.

    6.8.2 Stub Runner Stubs IDs

    You can provide the stubs to download via the stubrunner.ids system property. They follow this pattern:

    groupId:artifactId:version:classifier:port

    Note that version, classifier and port are optional.

    2.2.4
    diff --git a/spring-cloud-contract-maven-plugin/plugins.html b/spring-cloud-contract-maven-plugin/plugins.html index 0b033798e5..9e1b392139 100644 --- a/spring-cloud-contract-maven-plugin/plugins.html +++ b/spring-cloud-contract-maven-plugin/plugins.html @@ -1,13 +1,13 @@ - + Spring Cloud Contract Maven Plugin – Project Plugins @@ -146,7 +146,7 @@
    1.12.0
    org.apache.maven.pluginsmaven-checkstyle-plugin2.17
    maven-checkstyle-plugin3.0.0
    org.apache.maven.plugins maven-clean-plugin2.4
    org.apache.maven.pluginsmaven-jar-plugin3.0.0
    maven-jar-plugin3.1.0
    org.apache.maven.pluginsmaven-javadoc-plugin2.10.4
    maven-javadoc-plugin3.0.1
    org.apache.maven.plugins maven-plugin-plugin 3.5
    org.apache.maven.pluginsmaven-resources-plugin2.6
    maven-resources-plugin3.1.0
    org.apache.maven.plugins maven-scm-publish-plugin3.4
    org.apache.maven.pluginsmaven-source-plugin2.4
    maven-source-plugin3.0.1
    org.apache.maven.plugins maven-surefire-pluginVersion
    org.apache.maven.pluginsmaven-checkstyle-plugin2.17
    maven-checkstyle-plugin3.0.0
    org.apache.maven.plugins maven-plugin-plugin