Skip to content

Commit 11d70c0

Browse files
committed
pact feign consumer example
1 parent 4e26aa5 commit 11d70c0

16 files changed

Lines changed: 520 additions & 0 deletions

File tree

pact/pact-feign-consumer/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Testing a Spring Boot REST API Consumer against a Contract with Spring Cloud Contract
2+
3+
## Companion Blog Article
4+
Read the [companion blog article](https://reflectoring.io/consumer-driven-contract-consumer-spring-cloud-contract/) to this repository.
5+
6+
## Getting Started
7+
8+
* have a look at the [contract](/src/test/resources/contracts)
9+
* have a look at the [feign client](/src/main/java/io/reflectoring/UserClient.java)
10+
* have a look at the [consumer test](/src/test/java/io/reflectoring/UserClientTest.java)
11+
* run `./gradlew publishToMavenLocal` in the [producer project](../spring-cloud-contract-provider)
12+
to create a provider stubs
13+
* run `./gradlew build` in this project to verify the feign client against the stub
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
userservice:
2+
ribbon:
3+
eureka:
4+
enabled: false
5+
listOfServers: localhost:8080
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apply plugin: 'org.springframework.boot'
2+
3+
buildscript {
4+
repositories {
5+
mavenLocal()
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springboot_version}"
10+
}
11+
}
12+
13+
14+
repositories {
15+
mavenLocal()
16+
jcenter()
17+
}
18+
19+
dependencies {
20+
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springboot_version}")
21+
compile("org.springframework.boot:spring-boot-starter-web:${springboot_version}")
22+
compile("org.springframework.cloud:spring-cloud-starter-feign:1.4.1.RELEASE")
23+
compile('com.h2database:h2:1.4.196')
24+
testCompile('org.codehaus.groovy:groovy-all:2.4.6')
25+
testCompile("au.com.dius:pact-jvm-consumer-junit_2.11:3.5.2")
26+
testCompile("org.springframework.boot:spring-boot-starter-test:${springboot_version}")
27+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
springboot_version=1.5.9.RELEASE
2+
verifier_version=1.2.2.RELEASE
53.4 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip

pact/pact-feign-consumer/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pact/pact-feign-consumer/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.reflectoring;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.netflix.feign.EnableFeignClients;
6+
7+
@SpringBootApplication
8+
@EnableFeignClients
9+
public class ConsumerApplication {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(ConsumerApplication.class, args);
13+
}
14+
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.reflectoring;
2+
3+
import feign.Logger;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
@Configuration
8+
public class FeignConfiguration {
9+
10+
@Bean
11+
public Logger.Level logLevel(){
12+
return Logger.Level.FULL;
13+
}
14+
15+
}

0 commit comments

Comments
 (0)