diff --git a/README.adoc b/README.adoc
index 74ff837f40..09a0ee07f8 100644
--- a/README.adoc
+++ b/README.adoc
@@ -590,7 +590,7 @@ org.springframework.cloud.contract.spec.Contract.make {
loanAmount: 99999
])
headers { // (5)
- header('Content-Type', 'application/vnd.fraud.v1+json')
+ contentType("application/vnd.fraud.v1+json")
}
}
response { // (6)
@@ -600,10 +600,7 @@ org.springframework.cloud.contract.spec.Contract.make {
rejectionReason: "Amount too high"
])
headers { // (9)
- header('Content-Type': value(
- producer(regex('application/vnd.fraud.v1.json.*')),
- consumer('application/vnd.fraud.v1+json'))
- )
+ contentType("application/vnd.fraud.v1+json")
}
}
}
@@ -871,16 +868,28 @@ That's because all the generated tests will extend that class. Over there you ca
----
package com.example.fraud;
-import com.example.fraud.FraudDetectionController;
-import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
-
import org.junit.Before;
+import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
+
public class FraudBase {
@Before
public void setup() {
- RestAssuredMockMvc.standaloneSetup(new FraudDetectionController());
+ RestAssuredMockMvc.standaloneSetup(new FraudDetectionController(),
+ new FraudStatsController(stubbedStatsProvider()));
+ }
+
+ private StatsProvider stubbedStatsProvider() {
+ return fraudType -> {
+ switch (fraudType) {
+ case DRUNKS:
+ return 100;
+ case ALL:
+ return 200;
+ }
+ return 0;
+ };
}
public void assertThatRejectionReasonIsNull(Object rejectionReason) {
diff --git a/pom.xml b/pom.xml
index 51ddaecdaf..abec0751fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,14 +25,14 @@
5.12.1
2.17.0
- 1.4.2.RELEASE
+ 1.5.0.BUILD-SNAPSHOT
2.17
- 1.2.2.BUILD-SNAPSHOT
- 1.0.4.BUILD-SNAPSHOT
+ 1.3.0.BUILD-SNAPSHOT
+ 1.1.0.BUILD-SNAPSHOT
Brooklyn.BUILD-SNAPSHOT
- 1.2.4.BUILD-SNAPSHOT
- 1.1.2.BUILD-SNAPSHOT
- 1.1.7.BUILD-SNAPSHOT
+ 1.3.0.BUILD-SNAPSHOT
+ 1.2.0.BUILD-SNAPSHOT
+ 1.2.0.BUILD-SNAPSHOT
diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/server/StubRunnerBootSpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/server/StubRunnerBootSpec.groovy
index 25178aff4a..1ab61e7969 100644
--- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/server/StubRunnerBootSpec.groovy
+++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/server/StubRunnerBootSpec.groovy
@@ -19,7 +19,6 @@ package org.springframework.cloud.contract.stubrunner.server
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
import groovy.json.JsonSlurper
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.IntegrationTest
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.contract.stubrunner.StubRunning
import org.springframework.test.context.ActiveProfiles
@@ -30,7 +29,6 @@ import spock.lang.Specification
*/
// tag::boot_usage[]
@ContextConfiguration(classes = StubRunnerBoot, loader = SpringBootContextLoader)
-@IntegrationTest("spring.cloud.zookeeper.enabled=false")
@ActiveProfiles("test")
class StubRunnerBootSpec extends Specification {
diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy
index 0fa26395a7..b4300338c5 100644
--- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy
+++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy
@@ -16,11 +16,10 @@
package org.springframework.cloud.contract.stubrunner.spring
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.AfterClass
+import org.junit.BeforeClass
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
-import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.contract.stubrunner.StubFinder
import org.springframework.cloud.contract.stubrunner.StubNotFoundException
@@ -29,9 +28,7 @@ import org.springframework.core.env.Environment
import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.ContextConfiguration
-
import spock.lang.Specification
-
/**
* @author Marcin Grzejszczak
*/
@@ -39,7 +36,6 @@ import spock.lang.Specification
// Not necessary if Spring Cloud is used. TODO: make it work without this.
// tag::test[]
@ContextConfiguration(classes = Config, loader = SpringBootContextLoader)
-@IntegrationTest(["stubrunner.cloud.enabled=false", "stubrunner.camel.enabled=false"])
@AutoConfigureStubRunner
@DirtiesContext
@ActiveProfiles("test")
diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy
index de969c8546..82034d028f 100644
--- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy
+++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy
@@ -21,7 +21,6 @@ import org.junit.BeforeClass
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.test.context.SpringBootContextLoader
-import org.springframework.boot.test.context.SpringBootTest
import org.springframework.cloud.client.loadbalancer.LoadBalanced
import org.springframework.cloud.consul.ConsulAutoConfiguration
import org.springframework.cloud.contract.stubrunner.StubFinder
@@ -32,6 +31,7 @@ import org.springframework.cloud.zookeeper.discovery.RibbonZookeeperAutoConfigur
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.test.annotation.DirtiesContext
+import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.ContextConfiguration
import org.springframework.web.client.RestTemplate
import spock.lang.Specification
@@ -40,14 +40,7 @@ import spock.lang.Specification
*/
//TODO: Document that ribbon.eureka.enabled=false needs to be set or override it somehow
@ContextConfiguration(classes = Config, loader = SpringBootContextLoader)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
- properties = ["stubrunner.camel.enabled=false",
- "spring.cloud.zookeeper.enabled=false",
- "spring.cloud.consul.enabled=false",
- "eureka.client.enabled=false",
- "stubrunner.cloud.stubbed.discovery.enabled=true",
- "spring.cloud.consul.discovery.enabled=false",
- "spring.cloud.zookeeper.discovery.enabled=false"])
+@ActiveProfiles("cloudtest")
// tag::autoconfigure[]
@AutoConfigureStubRunner(
ids = ["org.springframework.cloud.contract.verifier.stubs:loanIssuance",
diff --git a/spring-cloud-contract-stub-runner/src/test/resources/application-cloudtest.yml b/spring-cloud-contract-stub-runner/src/test/resources/application-cloudtest.yml
new file mode 100644
index 0000000000..e748b714b5
--- /dev/null
+++ b/spring-cloud-contract-stub-runner/src/test/resources/application-cloudtest.yml
@@ -0,0 +1,12 @@
+stubrunner:
+ camel.enabled: false
+ cloud.stubbed.discovery.enabled: true
+spring.cloud:
+ zookeeper:
+ enabled: false
+ discovery.enabled: false
+ consul:
+ enabled: false
+ discovery.enabled: false
+ service-registry.enabled: false
+eureka.client.enabled: false
\ No newline at end of file
diff --git a/spring-cloud-contract-stub-runner/src/test/resources/application-test.yml b/spring-cloud-contract-stub-runner/src/test/resources/application-test.yml
index 3342bec09d..9f6948c9e1 100644
--- a/spring-cloud-contract-stub-runner/src/test/resources/application-test.yml
+++ b/spring-cloud-contract-stub-runner/src/test/resources/application-test.yml
@@ -3,4 +3,12 @@ stubrunner:
ids:
- org.springframework.cloud.contract.verifier.stubs:loanIssuance
- org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer
- - org.springframework.cloud.contract.verifier.stubs:bootService
\ No newline at end of file
+ - org.springframework.cloud.contract.verifier.stubs:bootService
+ cloud:
+ enabled: false
+ camel:
+ enabled: false
+
+spring.cloud:
+ consul.enabled: false
+ service-registry.enabled: false
\ No newline at end of file
diff --git a/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy b/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy
index a05c495dd3..88499d4a37 100644
--- a/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy
+++ b/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy
@@ -20,7 +20,6 @@ import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import com.toomuchcoding.jsonassert.JsonAssertion
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.IntegrationTest
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier
@@ -33,7 +32,6 @@ import javax.inject.Inject
// Context configuration would end up in base class
@ContextConfiguration(classes = [AmqpMessagingApplication], loader = SpringBootContextLoader)
@AutoConfigureMessageVerifier
-@IntegrationTest("stubrunner.amqp.enabled=true")
class AmqpMessagingApplicationSpec extends Specification {
// ALL CASES
diff --git a/tests/samples-messaging-amqp/src/test/resources/application.yml b/tests/samples-messaging-amqp/src/test/resources/application.yml
new file mode 100644
index 0000000000..aff69ac8b9
--- /dev/null
+++ b/tests/samples-messaging-amqp/src/test/resources/application.yml
@@ -0,0 +1 @@
+stubrunner.amqp.enabled: true
\ No newline at end of file
diff --git a/tests/samples-messaging-stream/src/test/groovy/com/example/StreamMessagingApplicationSpec.groovy b/tests/samples-messaging-stream/src/test/groovy/com/example/StreamMessagingApplicationSpec.groovy
index ecd35ba885..ac085b7275 100644
--- a/tests/samples-messaging-stream/src/test/groovy/com/example/StreamMessagingApplicationSpec.groovy
+++ b/tests/samples-messaging-stream/src/test/groovy/com/example/StreamMessagingApplicationSpec.groovy
@@ -16,31 +16,27 @@
package com.example
-import javax.inject.Inject
-
+import com.jayway.jsonpath.DocumentContext
+import com.jayway.jsonpath.JsonPath
+import com.toomuchcoding.jsonassert.JsonAssertion
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.IntegrationTest
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.messaging.MessageVerifier
import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier
-import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper;
-import org.springframework.messaging.Message;
+import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
+import org.springframework.messaging.Message
import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.ContextConfiguration
-
import spock.lang.Specification
-import com.jayway.jsonpath.DocumentContext
-import com.jayway.jsonpath.JsonPath
-import com.toomuchcoding.jsonassert.JsonAssertion
+import javax.inject.Inject
/**
* SPIKE ON TESTS FROM NOTES IN MessagingSpec
*/
// Context configuration would end up in base class
@ContextConfiguration(classes = [StreamMessagingApplication], loader = SpringBootContextLoader)
@DirtiesContext
-@IntegrationTest("debug=true")
@AutoConfigureMessageVerifier
public class StreamMessagingApplicationSpec extends Specification {
diff --git a/tests/spring-cloud-contract-stub-runner-camel/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy b/tests/spring-cloud-contract-stub-runner-camel/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy
index 840bb44471..219ba928ee 100644
--- a/tests/spring-cloud-contract-stub-runner-camel/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy
+++ b/tests/spring-cloud-contract-stub-runner-camel/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy
@@ -18,7 +18,6 @@ package org.springframework.cloud.contract.stubrunner.messaging.camel
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
-
import org.apache.activemq.camel.component.ActiveMQComponent
import org.apache.activemq.spring.ActiveMQConnectionFactory
import org.apache.camel.CamelContext
@@ -27,7 +26,6 @@ import org.apache.camel.component.jms.JmsConfiguration
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
-import org.springframework.boot.test.IntegrationTest
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.stubrunner.StubFinder
@@ -38,12 +36,10 @@ import org.springframework.context.annotation.Configuration
import org.springframework.test.context.ContextConfiguration
import spock.lang.IgnoreIf
import spock.lang.Specification
-
/**
* @author Marcin Grzejszczak
*/
@ContextConfiguration(classes = Config, loader = SpringBootContextLoader)
-@IntegrationTest("debug=true")
@AutoConfigureStubRunner
@IgnoreIf({ os.windows })
class CamelStubRunnerSpec extends Specification {
diff --git a/tests/spring-cloud-contract-stub-runner-camel/src/test/resources/application.yml b/tests/spring-cloud-contract-stub-runner-camel/src/test/resources/application.yml
index e851ff3af0..7ba218ad58 100644
--- a/tests/spring-cloud-contract-stub-runner-camel/src/test/resources/application.yml
+++ b/tests/spring-cloud-contract-stub-runner-camel/src/test/resources/application.yml
@@ -1,4 +1,5 @@
stubrunner.repositoryRoot: classpath:m2repo/repository/
stubrunner.ids: org.springframework.cloud.contract.verifier.stubs:camelService
server:
- port: 0
\ No newline at end of file
+ port: 0
+debug: true
\ No newline at end of file
diff --git a/tests/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StreamStubRunnerSpec.groovy b/tests/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StreamStubRunnerSpec.groovy
index 733fd4a0ca..84722c308b 100644
--- a/tests/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StreamStubRunnerSpec.groovy
+++ b/tests/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StreamStubRunnerSpec.groovy
@@ -20,7 +20,6 @@ import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
-import org.springframework.boot.test.IntegrationTest
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.stubrunner.StubFinder
@@ -41,7 +40,6 @@ import java.util.concurrent.TimeUnit
* @author Marcin Grzejszczak
*/
@ContextConfiguration(classes = Config, loader = SpringBootContextLoader)
-@IntegrationTest("debug=true")
@AutoConfigureStubRunner
@AutoConfigureMessageVerifier
@IgnoreIf({ os.windows })
diff --git a/tests/spring-cloud-contract-stub-runner-stream/src/test/resources/application.yml b/tests/spring-cloud-contract-stub-runner-stream/src/test/resources/application.yml
index ba7c0e3ab1..2c67409772 100644
--- a/tests/spring-cloud-contract-stub-runner-stream/src/test/resources/application.yml
+++ b/tests/spring-cloud-contract-stub-runner-stream/src/test/resources/application.yml
@@ -11,4 +11,6 @@ spring:
destination: bookStorage
server:
- port: 0
\ No newline at end of file
+ port: 0
+
+debug: true
\ No newline at end of file