diff --git a/images/sts_exception.png b/images/sts_exception.png new file mode 100644 index 0000000000..8607c38a52 Binary files /dev/null and b/images/sts_exception.png differ diff --git a/spring-cloud-contract.html b/spring-cloud-contract.html index 1819c9b2fa..0143e26e76 100644 --- a/spring-cloud-contract.html +++ b/spring-cloud-contract.html @@ -572,7 +572,6 @@ $(addBlockSwitches); @@ -606,6 +605,11 @@ $(addBlockSwitches);
  • Invoking generated tests
  • +
  • FAQ with Maven Plugin + +
  • Spring Cloud Contract Verifier on consumer side
  • @@ -657,7 +661,11 @@ $(addBlockSwitches);
  • Stub Runner Spring Cloud
  • @@ -3017,49 +3025,6 @@ dependencies {
    -
    Add maven plugin with dependencies
    -
    -
    -
    <dependencyManagement>
    -    <dependencies>
    -        <dependency>
    -            <groupId>org.springframework.cloud</groupId>
    -            <artifactId>spring-cloud-contract-dependencies</artifactId>
    -            <version>${spring-cloud-contract.version}</version>
    -            <type>pom</type>
    -            <scope>import</scope>
    -        </dependency>
    -    </dependencies>
    -</dependencyManagement>
    -
    -<dependencies>
    -    <dependency>
    -        <groupId>org.springframework.cloud</groupId>
    -        <artifactId>spring-cloud-starter-contract-verifier</artifactId>
    -        <scope>test</scope>
    -    </dependency>
    -</dependencies>
    -
    -<plugin>
    -    <groupId>org.springframework.cloud</groupId>
    -    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    -    <executions>
    -        <execution>
    -            <goals>
    -                <goal>convert</goal>
    -                <goal>generateStubs</goal>
    -                <goal>generateTests</goal>
    -            </goals>
    -        </execution>
    -    </executions>
    -</plugin>
    -
    -
    -
    -

    Read more: spring-cloud-contract-maven-plugin

    -
    -
    -
    Add stubs

    By default Spring Cloud Contract Verifier is looking for stubs in src/test/resources/contracts directory.

    @@ -3725,6 +3690,73 @@ will be extending the com.example.ComBase whereas the rest of tests
    +
    FAQ with Maven Plugin
    +
    +
    Maven Plugin and STS
    +
    +

    In case you see the following exception while using STS

    +
    +
    +
    +STS Exception +
    +
    +
    +

    when you click on the marker you should see sth like this

    +
    +
    +
    +
     plugin:1.1.0.M1:convert:default-convert:process-test-resources) org.apache.maven.plugin.PluginExecutionException: Execution default-convert of goal org.springframework.cloud:spring-
    + cloud-contract-maven-plugin:1.1.0.M1:convert failed. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) at
    + org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331) at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362) at
    +...
    + org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Caused by: java.lang.NullPointerException at
    + org.eclipse.m2e.core.internal.builder.plexusbuildapi.EclipseIncrementalBuildContext.hasDelta(EclipseIncrementalBuildContext.java:53) at
    + org.sonatype.plexus.build.incremental.ThreadBuildContext.hasDelta(ThreadBuildContext.java:59) at
    +
    +
    +
    +

    In order to fix this issue just provide the following section in your pom.xml

    +
    +
    +
    +
    <build>
    +    <pluginManagement>
    +        <plugins>
    +            <!--This plugin's configuration is used to store Eclipse m2e settings
    +                only. It has no influence on the Maven build itself. -->
    +            <plugin>
    +                <groupId>org.eclipse.m2e</groupId>
    +                <artifactId>lifecycle-mapping</artifactId>
    +                <version>1.0.0</version>
    +                <configuration>
    +                    <lifecycleMappingMetadata>
    +                        <pluginExecutions>
    +                             <pluginExecution>
    +                                <pluginExecutionFilter>
    +                                    <groupId>org.springframework.cloud</groupId>
    +                                    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    +                                    <versionRange>[1.0,)</versionRange>
    +                                    <goals>
    +                                        <goal>convert</goal>
    +                                    </goals>
    +                                </pluginExecutionFilter>
    +                                <action>
    +                                    <execute />
    +                                </action>
    +                             </pluginExecution>
    +                        </pluginExecutions>
    +                    </lifecycleMappingMetadata>
    +                </configuration>
    +            </plugin>
    +        </plugins>
    +    </pluginManagement>
    +</build>
    +
    +
    +
    +
    +
    Spring Cloud Contract Verifier on consumer side

    You can actually use the Spring Cloud Contract Verifier also for the consumer side! @@ -4888,6 +4920,19 @@ for every registered WireMock server. Example for Stub Runner ids

    Stub Runner can integrate with Spring Cloud.

    +
    +

    For real life examples you can check the

    +
    +

    Stubbing Service Discovery

    @@ -4939,6 +4984,27 @@ stubrunner: 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) +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
    +    static {
    +        System.setProperty("eureka.client.enabled", "false");
    +        System.setProperty("spring.cloud.config.failFast", "false");
    +    }
    +
    +
    +

    Additional Configuration