Bumped to Boot 1.5
This commit is contained in:
27
README.adoc
27
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) {
|
||||
|
||||
12
pom.xml
12
pom.xml
@@ -25,14 +25,14 @@
|
||||
<properties>
|
||||
<activemq.version>5.12.1</activemq.version>
|
||||
<camel.version>2.17.0</camel.version>
|
||||
<spring-boot.version>1.4.2.RELEASE</spring-boot.version>
|
||||
<spring-boot.version>1.5.0.BUILD-SNAPSHOT</spring-boot.version>
|
||||
<checkstyle.version>2.17</checkstyle.version>
|
||||
<spring-cloud-build.version>1.2.2.BUILD-SNAPSHOT</spring-cloud-build.version>
|
||||
<spring-cloud-zookeeper.version>1.0.4.BUILD-SNAPSHOT</spring-cloud-zookeeper.version>
|
||||
<spring-cloud-build.version>1.3.0.BUILD-SNAPSHOT</spring-cloud-build.version>
|
||||
<spring-cloud-zookeeper.version>1.1.0.BUILD-SNAPSHOT</spring-cloud-zookeeper.version>
|
||||
<spring-cloud-stream.version>Brooklyn.BUILD-SNAPSHOT</spring-cloud-stream.version>
|
||||
<spring-cloud-netflix.version>1.2.4.BUILD-SNAPSHOT</spring-cloud-netflix.version>
|
||||
<spring-cloud-consul.version>1.1.2.BUILD-SNAPSHOT</spring-cloud-consul.version>
|
||||
<spring-cloud-commons.version>1.1.7.BUILD-SNAPSHOT</spring-cloud-commons.version>
|
||||
<spring-cloud-netflix.version>1.3.0.BUILD-SNAPSHOT</spring-cloud-netflix.version>
|
||||
<spring-cloud-consul.version>1.2.0.BUILD-SNAPSHOT</spring-cloud-consul.version>
|
||||
<spring-cloud-commons.version>1.2.0.BUILD-SNAPSHOT</spring-cloud-commons.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
- org.springframework.cloud.contract.verifier.stubs:bootService
|
||||
cloud:
|
||||
enabled: false
|
||||
camel:
|
||||
enabled: false
|
||||
|
||||
spring.cloud:
|
||||
consul.enabled: false
|
||||
service-registry.enabled: false
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
stubrunner.amqp.enabled: true
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
stubrunner.repositoryRoot: classpath:m2repo/repository/
|
||||
stubrunner.ids: org.springframework.cloud.contract.verifier.stubs:camelService
|
||||
server:
|
||||
port: 0
|
||||
port: 0
|
||||
debug: true
|
||||
@@ -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 })
|
||||
|
||||
@@ -11,4 +11,6 @@ spring:
|
||||
destination: bookStorage
|
||||
|
||||
server:
|
||||
port: 0
|
||||
port: 0
|
||||
|
||||
debug: true
|
||||
Reference in New Issue
Block a user