Fix sample apps

This commit is contained in:
Dave Syer
2016-07-13 13:24:18 +01:00
parent cf27296f65
commit f0656e8c78
43 changed files with 505 additions and 448 deletions

View File

@@ -7,7 +7,7 @@
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>java:com.example.CamelMessagingApplication</config>
<config>java:com.example.fraud.CamelMessagingApplication</config>
</configs>
<autoconfigs>
</autoconfigs>

View File

@@ -7,7 +7,7 @@
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>java:com.example.IntegrationMessagingApplication</config>
<config>java:com.example.fraud.IntegrationMessagingApplication</config>
</configs>
<autoconfigs>
</autoconfigs>

View File

@@ -7,7 +7,7 @@
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>java:com.example.SpringMessagingApplication</config>
<config>java:com.example.fraud.SpringMessagingApplication</config>
</configs>
<autoconfigs>
</autoconfigs>

View File

@@ -7,7 +7,7 @@
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>java:com.example.StreamMessagingApplication</config>
<config>java:com.example.fraud.StreamMessagingApplication</config>
</configs>
<autoconfigs>
</autoconfigs>

View File

@@ -66,6 +66,11 @@
<artifactId>spring-cloud-contract-stub-runner-boot</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-stub-runner-stream</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-messaging-core</artifactId>
@@ -125,6 +130,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.toomuchcoding.jsonassert</groupId>
<artifactId>jsonassert</artifactId>

View File

@@ -6,7 +6,7 @@ buildscript {
maven { url "http://repo.spring.io/plugins-staging-local/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.BUILD-SNAPSHOT"
}
}
@@ -32,10 +32,7 @@ dependencyManagement {
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.cloud:spring-cloud-starter-stream-rabbit")

View File

@@ -14,14 +14,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<version>1.4.0.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract-verifier.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract-verifier.version>
<spring-cloud-contract.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
</properties>
<dependencies>
@@ -38,13 +38,19 @@
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-stub-runner-stream</artifactId>
<version>${spring-cloud-contract-verifier.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-dependencies</artifactId>
<version>${spring-cloud-contract.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>

View File

@@ -1,10 +1,12 @@
package org.springframework.cloud.stream.verifier.sample.sink;
package com.example.sink;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.example.sink.ContractVerifierSampleStreamSinkApplication;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ContractVerifierSampleStreamSinkApplication.class)
public class ContractVerifierSampleStreamSinkApplicationTests {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.stream.verifier.sample.sink;
package com.example.sink;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -25,6 +25,8 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.contract.stubrunner.StubTrigger;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.example.sink.ContractVerifierSampleStreamSinkApplication;
/**
* @author Marius Bogoevici
*/

View File

@@ -8,7 +8,7 @@ buildscript {
maven { url "http://repo.spring.io/plugins-staging-local/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.BUILD-SNAPSHOT"
classpath "org.springframework.cloud.contract:spring-cloud-contract-verifier-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
}
}
@@ -41,15 +41,12 @@ ext {
}
contractVerifier {
baseClassForTests = 'org.springframework.cloud.stream.sample.verifier.source.SensorSourceTestBase'
baseClassForTests = 'com.example.source.SensorSourceTestBase'
stubsOutputDir = stubsOutputDirRoot
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.cloud:spring-cloud-starter-stream-rabbit")
compile("org.springframework.cloud.contract:spring-cloud-contract-verifier-stream:${findProperty('verifierVersion') ?: verifierVersion}")

View File

@@ -14,15 +14,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<version>1.4.0.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract-verifier.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract-verifier.version>
<spring-cloud-contract-verifier-maven-plugin.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract-verifier-maven-plugin.version>
<spring-cloud-contract.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
</properties>
<dependencies>
@@ -40,27 +39,31 @@
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-core</artifactId>
<version>${spring-cloud-contract-verifier.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-stream</artifactId>
<version>${spring-cloud-contract-verifier.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>2.4.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-dependencies</artifactId>
<version>${spring-cloud-contract.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
@@ -80,17 +83,17 @@
<plugin>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-maven-plugin</artifactId>
<version>${spring-cloud-contract-verifier-maven-plugin.version}</version>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
<configuration>
<baseClassForTests>org.springframework.cloud.stream.sample.verifier.source.SensorSourceTestBase</baseClassForTests>
<baseClassForTests>com.example.source.SensorSourceTestBase</baseClassForTests>
</configuration>
<!-- this was added for testing purposes only-->
<dependencies>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-core</artifactId>
<version>${spring-cloud-contract-verifier.version}</version>
<version>${spring-cloud-contract.version}</version>
</dependency>
</dependencies>
</plugin>
@@ -101,6 +104,36 @@
</configuration>
</plugin>
</plugins>
<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.contract</groupId>
<artifactId>spring-cloud-contract-verifier-maven-plugin</artifactId>
<versionRange>[1.0.0.BUILD-SNAPSHOT,)</versionRange>
<goals>
<goal>convert</goal>
<goal>generateTests</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>

View File

@@ -1,10 +1,12 @@
package org.springframework.cloud.stream.sample.verifier.source;
package com.example.source;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.example.source.ContractVerifierSampleStreamSourceApplication;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ContractVerifierSampleStreamSourceApplication.class)
public class ContractVerifierSampleStreamSourceApplicationTests {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.stream.sample.verifier.source;
package com.example.source;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +22,8 @@ import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.example.source.ContractVerifierSampleStreamSourceApplication;
/**
* Base class for sensor autogenerated tests (used by Spring Cloud Contract).
*

View File

@@ -6,11 +6,11 @@ buildscript {
maven { url "http://repo.spring.io/plugins-staging-local/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.BUILD-SNAPSHOT"
}
}
group = 'org.springframework.cloud.contract.testprojects'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
repositories {
@@ -26,10 +26,7 @@ apply plugin: 'spring-boot'
apply plugin: 'maven-publish'
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
testRuntime "org.spockframework:spock-spring"

View File

@@ -1,187 +1,191 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud.contract.testprojects</groupId>
<artifactId>http-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<groupId>com.example</groupId>
<artifactId>http-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring Cloud Contract Verifier Http Client Sample</name>
<description>Spring Cloud Contract Verifier Http Client Sample</description>
<name>Spring Cloud Contract Verifier Http Client Sample</name>
<description>Spring Cloud Contract Verifier Http Client Sample</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<relativePath/>
</parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract-verifier.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract-verifier.version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-stub-runner-spring</artifactId>
<version>${spring-cloud-contract-verifier.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-stub-runner-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-spring</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-dependencies</artifactId>
<version>${spring-cloud-contract.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<testSources>
<testSource>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
<testSource>
<directory>${project.build.directory}/generated-test-sources/accurest</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*Spec.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<testSources>
<testSource>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
<testSource>
<directory>${project.build.directory}/generated-test-sources/accurest</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Spec.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>spring</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/plugins-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/plugins-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<profiles>
<profile>
<id>spring</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/plugins-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/plugins-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>

View File

@@ -1,4 +1,4 @@
package org.springframework.cloud.contract.frauddetection;
package com.example.loan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@@ -1,11 +1,5 @@
package org.springframework.cloud.contract.frauddetection;
package com.example.loan;
import org.springframework.cloud.contract.frauddetection.model.FraudCheckStatus;
import org.springframework.cloud.contract.frauddetection.model.FraudServiceRequest;
import org.springframework.cloud.contract.frauddetection.model.FraudServiceResponse;
import org.springframework.cloud.contract.frauddetection.model.LoanApplicationResult;
import org.springframework.cloud.contract.frauddetection.model.LoanApplication;
import org.springframework.cloud.contract.frauddetection.model.LoanApplicationStatus;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -13,6 +7,13 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.example.loan.model.FraudCheckStatus;
import com.example.loan.model.FraudServiceRequest;
import com.example.loan.model.FraudServiceResponse;
import com.example.loan.model.LoanApplication;
import com.example.loan.model.LoanApplicationResult;
import com.example.loan.model.LoanApplicationStatus;
@Service
public class LoanApplicationService {

View File

@@ -0,0 +1,5 @@
package com.example.loan.model;
public enum FraudCheckStatus {
OK, FRAUD
}

View File

@@ -1,4 +1,4 @@
package org.springframework.cloud.contract.frauddetection.model;
package com.example.loan.model;
public enum LoanApplicationStatus {
LOAN_APPLIED, LOAN_APPLICATION_REJECTED

View File

@@ -1,5 +0,0 @@
package org.springframework.cloud.contract.frauddetection.model;
public enum FraudCheckStatus {
OK, FRAUD
}

View File

@@ -1,17 +1,17 @@
package org.springframework.cloud.contract
package com.example.loan
import org.springframework.cloud.contract.frauddetection.Application
import org.springframework.cloud.contract.frauddetection.LoanApplicationService
import org.springframework.cloud.contract.frauddetection.model.Client
import org.springframework.cloud.contract.frauddetection.model.LoanApplication
import org.springframework.cloud.contract.frauddetection.model.LoanApplicationResult
import org.springframework.cloud.contract.frauddetection.model.LoanApplicationStatus
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.test.context.ContextConfiguration
import spock.lang.Specification
@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application)
import com.example.loan.model.Client
import com.example.loan.model.LoanApplication
import com.example.loan.model.LoanApplicationResult
import com.example.loan.model.LoanApplicationStatus
@ContextConfiguration(loader = SpringBootContextLoader, classes = Application)
class LoanApplicationServiceSpec extends Specification {
@Autowired

View File

@@ -1,3 +1,3 @@
stubrunner:
work-offline: true
stubs.ids: 'org.springframework.cloud.contract.testprojects:http-server:+:stubs:8080'
stubs.ids: 'com.example:http-server:+:stubs:8080'

View File

@@ -9,12 +9,12 @@ buildscript {
maven { url 'http://repo.spring.io/plugins-snapshot' }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.BUILD-SNAPSHOT"
classpath "org.springframework.cloud.contract:spring-cloud-contract-verifier-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
}
}
group = 'org.springframework.cloud.contract.testprojects'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
repositories {
@@ -38,10 +38,7 @@ contractVerifier {
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
testRuntime "org.spockframework:spock-spring"

View File

@@ -1,174 +1,202 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud.contract.testprojects</groupId>
<artifactId>http-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<groupId>com.example</groupId>
<artifactId>http-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring Cloud Contract Verifier Http Server Sample</name>
<description>Spring Cloud Contract Verifier Http Server Sample</description>
<name>Spring Cloud Contract Verifier Http Server Sample</name>
<description>Spring Cloud Contract Verifier Http Server Sample</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<relativePath/>
</parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract-verifier.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract-verifier.version>
<spring-cloud-contract-verifier-maven-plugin.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract-verifier-maven-plugin.version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- verifier test dependencies-->
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.toomuchcoding.jsonassert</groupId>
<artifactId>jsonassert</artifactId>
<version>0.4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.4.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- verifier test dependencies -->
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.toomuchcoding.jsonassert</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-maven-plugin</artifactId>
<version>${spring-cloud-contract-verifier-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<baseClassForTests>org.springframework.cloud.MvcTest</baseClassForTests>
</configuration>
<!-- this was added for testing purposes only-->
<dependencies>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-core</artifactId>
<version>${spring-cloud-contract-verifier.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-dependencies</artifactId>
<version>${spring-cloud-contract.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>spring</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/plugins-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/plugins-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
<configuration>
<baseClassForTests>com.example.fraud.MvcTest</baseClassForTests>
</configuration>
<!-- this was added for testing purposes only -->
<dependencies>
<dependency>
<groupId>org.springframework.cloud.contract</groupId>
<artifactId>spring-cloud-contract-verifier-core</artifactId>
<version>${spring-cloud-contract.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<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.contract</groupId>
<artifactId>spring-cloud-contract-verifier-maven-plugin</artifactId>
<versionRange>[1.0.0.BUILD-SNAPSHOT,)</versionRange>
<goals>
<goal>convert</goal>
<goal>generateTests</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>spring</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/plugins-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/plugins-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>

View File

@@ -1,4 +1,4 @@
package org.springframework.cloud.contract.frauddetection;
package com.example.fraud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

View File

@@ -1,13 +1,13 @@
package org.springframework.cloud.contract.frauddetection;
import org.springframework.cloud.contract.frauddetection.model.FraudCheck;
import org.springframework.cloud.contract.frauddetection.model.FraudCheckResult;
import org.springframework.cloud.contract.frauddetection.model.FraudCheckStatus;
package com.example.fraud;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.fraud.model.FraudCheck;
import com.example.fraud.model.FraudCheckResult;
import com.example.fraud.model.FraudCheckStatus;
import java.math.BigDecimal;
import static org.springframework.web.bind.annotation.RequestMethod.PUT;

View File

@@ -0,0 +1,5 @@
package com.example.fraud.model;
public enum FraudCheckStatus {
OK, FRAUD
}

View File

@@ -1,5 +0,0 @@
package org.springframework.cloud.contract.frauddetection.model;
public enum FraudCheckStatus {
OK, FRAUD
}

View File

@@ -1,15 +0,0 @@
package com.toomuchcoding
import org.springframework.cloud.contract.frauddetection.FraudDetectionController
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
import spock.lang.Specification
class MvcSpec extends Specification {
def setup() {
RestAssuredMockMvc.standaloneSetup(new FraudDetectionController())
}
void assertThatRejectionReasonIsNull(def rejectionReason) {
assert !rejectionReason
}
}

View File

@@ -1,7 +1,7 @@
package org.springframework.cloud;
package com.example.fraud;
import com.example.fraud.FraudDetectionController;
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
import org.springframework.cloud.contract.frauddetection.FraudDetectionController;
import org.junit.Before;

View File

@@ -22,7 +22,7 @@ org.springframework.cloud.contract.spec.Contract.make {
"rejectionReason": "Amount too high"
}""")
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(server(regex('application/vnd.fraud.v1.json.*')), client('application/vnd.fraud.v1+json')))
}
}

View File

@@ -23,7 +23,7 @@ org.springframework.cloud.contract.spec.Contract.make {
rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(test(regex('application/vnd.fraud.v1.json.*')), stub('application/vnd.fraud.v1+json')))
}
}

View File

@@ -4,12 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--
POM ONLY TO EASILY IMPORT TO IDE
-->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-samples</artifactId>
<version>1.0.0-SNAPSHOT</version>