Skip to content

Spring Cloud Contract 1.0.0 M2 Release Notes

Marcin Grzejszczak edited this page Aug 26, 2016 · 8 revisions

For changes in earlier milestones, please refer to:

v1.0.0.M1

Upgrading from Spring Cloud Contract 1.0.0 M1

Stubs configuration in YAML

With this feature the @AutoConfigureStubRunner annotation can pass additional information. Example

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureStubRunner(ids = {"com.example:http-server-dsl:+:stubs:8080"}, workOffline = true)
public class LoanApplicationServiceTests {

What needs to be migrated when going from M1 -> M2 are the property values. We used to have the subproperty stubs in the props:

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

Now this subproperty is removed

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

So *wherever you have the property stubrunner.stubs you have to migrate it to stubrunner.

Stub registration in Service Discovery

The downloaded WireMock stubs could be registered in any Spring Cloud discovery we support. Due to this one could start the Stub Runner Boot server for the end to end tests of the tested application and all stubs of its collaborators would be automatically downloaded and registered in a Service Discovery. Related issue

Example of a class with proper annotations

@SpringBootApplication
@EnableStubRunnerServer
@EnableEurekaClient
@AutoConfigureStubRunner
public class StubRunnerBootEurekaExample {

	public static void main(String[] args) {
		SpringApplication.run(StubRunnerBootEurekaExample.class, args);
	}

}

Once executed with the following props:

-Dstubrunner.repositoryRoot=http://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)

(1) - we tell Stub Runner where all the stubs reside
(2) - we don't want the default behaviour where the discovery service is stubbed. That's why the stub registration will be picked
(3) - we provide a list of stubs to download
(4) - we provide a list of artifactId to serviceId mapping

You will download the stubs and register them in Eureka.

Array size assertion property change

It turned out that in M1 there was a bug related to array size assertion of the output JSON. Not only was it turned on by default but to turn it off you had to provide a system property spring.cloud.contract.verifier.assert.size equal to true. Which obviously makes no sense. That was fixed in M2 so not only by default it is disabled but if you had the aforementioned flag turned on to turn the feature off then you have to to set spring.cloud.contract.verifier.assert.size to false to turn it off in M2.

Related issue #60

All features

In orther to see a list of features available for M2 please check out the following page