Skip to content

Commit f10c8d2

Browse files
committed
added angular pact example
1 parent b93c05f commit f10c8d2

18 files changed

Lines changed: 522 additions & 9245 deletions

angular-pact/package-lock.json

Lines changed: 0 additions & 9244 deletions
This file was deleted.

angular-pact/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"build": "ng build",
99
"test": "cross-env LOGLEVEL=DEBUG ng test",
1010
"lint": "ng lint",
11-
"e2e": "ng e2e"
11+
"e2e": "ng e2e",
12+
"publish-pacts": "node publish-pacts.js"
1213
},
1314
"private": true,
1415
"dependencies": {

angular-pact/publish-pacts.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
let projectFolder = __dirname;
2+
let pact = require('@pact-foundation/pact-node');
3+
let project = require('./package.json');
4+
5+
let options = {
6+
pactUrls: [projectFolder + '/pacts'],
7+
pactBroker: 'https://adesso.pact.dius.com.au/',
8+
consumerVersion: project.version,
9+
tags: ['latest'],
10+
pactBrokerUsername: 'Vm6YWrQURJ1T7mDIRiKwfexCAc4HbU',
11+
pactBrokerPassword: 'aLerJwBhpEcN0Wm88Wgvs45AR9dXpc'
12+
};
13+
14+
pact.publishPacts(options).then(function () {
15+
console.log("Pacts successfully published!");
16+
});

pact-spring-provider/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.gradle
2+
/build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
nbproject/private/
21+
build/
22+
nbbuild/
23+
dist/
24+
nbdist/
25+
.nb-gradle/

pact-spring-provider/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Consumer-Driven-Contract Test for a Spring Data Rest Provider
2+
3+
This repo contains an example of consumer-driven-contract testing for a Spring
4+
Data REST API provider. The corresponding consumer to the contract is
5+
implemented in the module `pact-feign-consumer`.
6+
7+
The contract is created and verified with [Pact](https://docs.pact.io/).
8+
9+
## Companion Blog Post
10+
11+
The Companion Blog Post to this project can be found [here](https://reflectoring.io/consumer-driven-contracts-with-pact-feign-spring-data-rest/).
12+
13+
## Running the application
14+
15+
The interesting part in this code base is the class `ProviderPactVerificationTest`.
16+
You can run the tests with `gradlew test` on Windows or `./gradlew test` on Unix.

pact-spring-provider/build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
buildscript {
2+
ext {
3+
springBootVersion = '1.5.4.RELEASE'
4+
}
5+
repositories {
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10+
}
11+
}
12+
13+
apply plugin: 'java'
14+
apply plugin: 'eclipse'
15+
apply plugin: 'org.springframework.boot'
16+
17+
version = '0.0.1-SNAPSHOT'
18+
sourceCompatibility = 1.8
19+
20+
repositories {
21+
mavenLocal()
22+
mavenCentral()
23+
}
24+
25+
dependencies {
26+
compile('org.springframework.boot:spring-boot-starter-data-jpa')
27+
compile('org.springframework.boot:spring-boot-starter-web')
28+
compile('com.h2database:h2:1.4.196')
29+
testCompile('au.com.dius:pact-jvm-provider-spring_2.12:3.5.8')
30+
testCompile('junit:junit:4.12')
31+
testCompile('org.springframework.boot:spring-boot-starter-test')
32+
}
33+
34+
bootRun {
35+
jvmArgs = ["-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"]
36+
}
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-3.5.1-bin.zip

pact-spring-provider/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-spring-provider/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.

0 commit comments

Comments
 (0)