Skip to content

Commit e7d6d9e

Browse files
committed
Update to use pact-broker
1 parent 3640641 commit e7d6d9e

File tree

10 files changed

+35
-18
lines changed

10 files changed

+35
-18
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ jobs:
1616
distribution: 'temurin'
1717
cache: maven
1818

19+
- name: Build with Docker
20+
run: docker compose build
21+
22+
- name: Start with Docker
23+
run: docker compose up -d
24+
1925
- name: Build customer-service
20-
run: mvn clean package -f customer-service/pom.xml -Dservice.name=customer-service
26+
run: mvn clean package -f customer-service/pom.xml -Dservice.name=customer-service pact:publish
2127

2228
- name: Build billing-service
2329
run: mvn clean package -f billing-service/pom.xml -Dservice.name=billing-service
@@ -28,11 +34,5 @@ jobs:
2834
- name: Build address-validation-service
2935
run: mvn clean package -f address-validation-service/pom.xml -Dservice.name=address-validation-service
3036

31-
- name: Build with Docker
32-
run: docker compose build
33-
34-
- name: Start with Docker
35-
run: docker compose up -d
36-
3737
- name: Stop Docker Containers
3838
run: docker compose down

address-validation-service/Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pipeline {
4848
}
4949
}
5050
steps {
51-
sh "mvn test -B"
51+
sh "mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -B"
5252
}
5353
}
5454
stage ('Package') {

address-validation-service/src/test/java/de/openknowledge/sample/address/AddressValidationServiceTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
import au.com.dius.pact.provider.junit5.HttpTestTarget;
2828
import au.com.dius.pact.provider.junit5.PactVerificationContext;
2929
import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;
30+
import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify;
3031
import au.com.dius.pact.provider.junitsupport.Provider;
3132
import au.com.dius.pact.provider.junitsupport.State;
32-
import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
33+
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
3334

35+
@IgnoreNoPactsToVerify
3436
@Provider("address-validation-service")
35-
@PactFolder("src/test/pacts")
37+
@PactBroker(url = "${pactBroker.url:http://localhost:5000}")
3638
@MonoMeecrowaveConfig
3739
public class AddressValidationServiceTest {
3840

billing-service/Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pipeline {
4848
}
4949
}
5050
steps {
51-
sh "mvn test -B"
51+
sh "mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -B"
5252
}
5353
}
5454
stage ('Package') {

billing-service/src/test/java/de/openknowledge/sample/address/BillingAddressServiceTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
import au.com.dius.pact.provider.junit5.HttpTestTarget;
2828
import au.com.dius.pact.provider.junit5.PactVerificationContext;
2929
import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;
30+
import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify;
3031
import au.com.dius.pact.provider.junitsupport.Provider;
3132
import au.com.dius.pact.provider.junitsupport.State;
32-
import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
33+
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
3334

35+
@IgnoreNoPactsToVerify
3436
@Provider("billing-service")
35-
@PactFolder("src/test/pacts")
37+
@PactBroker(url = "${pactBroker.url:http://localhost:5000}")
3638
@MonoMeecrowaveConfig
3739
public class BillingAddressServiceTest {
3840

customer-service/Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pipeline {
4848
}
4949
}
5050
steps {
51-
sh "mvn test -B"
51+
sh 'mvn test pact:publish -DpactBroker.url=http://pact:9292 -B'
5252
}
5353
}
5454
stage ('Package') {

customer-service/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<maven.compiler.target>17</maven.compiler.target>
2727
<failOnMissingWebXml>false</failOnMissingWebXml>
2828
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
29+
<pactBroker.url>http://localhost:5000</pactBroker.url>
2930
<meecrowave.version>1.2.15</meecrowave.version>
3031
<deltaspike.version>1.9.6</deltaspike.version>
3132
<junit.version>5.8.2</junit.version>
@@ -252,6 +253,14 @@
252253
</execution>
253254
</executions>
254255
</plugin>
256+
<plugin>
257+
<groupId>au.com.dius.pact.provider</groupId>
258+
<artifactId>maven</artifactId>
259+
<version>4.3.5</version>
260+
<configuration>
261+
<pactBrokerUrl>${pactBroker.url}</pactBrokerUrl>
262+
</configuration>
263+
</plugin>
255264
</plugins>
256265
</build>
257266
</project>

delivery-service/Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pipeline {
4848
}
4949
}
5050
steps {
51-
sh "mvn test -B"
51+
sh "mvn test pact:publish -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -B"
5252
}
5353
}
5454
stage ('Package') {

delivery-service/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<maven.compiler.target>17</maven.compiler.target>
2727
<failOnMissingWebXml>false</failOnMissingWebXml>
2828
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
29+
<pactBroker.url>http://localhost:5000</pactBroker.url>
2930
<meecrowave.version>1.2.15</meecrowave.version>
3031
<deltaspike.version>1.9.6</deltaspike.version>
3132
<hibernate.version>5.4.21.Final</hibernate.version>
@@ -226,6 +227,7 @@
226227
<configuration>
227228
<systemPropertyVariables>
228229
<pact.provider.version>${project.version}</pact.provider.version>
230+
<pactBroker.url>${pactBroker.url}</pactBroker.url>
229231
<javax.persistence.jdbc.url>jdbc:h2:mem:delivery</javax.persistence.jdbc.url>
230232
<javax.persistence.jdbc.driver>org.h2.Driver</javax.persistence.jdbc.driver>
231233
<javax.persistence.jdbc.user>sa</javax.persistence.jdbc.user>
@@ -266,7 +268,7 @@
266268
<artifactId>maven</artifactId>
267269
<version>4.3.5</version>
268270
<configuration>
269-
<pactBrokerUrl>http://localhost:5000</pactBrokerUrl>
271+
<pactBrokerUrl>${pactBroker.url}</pactBrokerUrl>
270272
</configuration>
271273
</plugin>
272274
</plugins>

delivery-service/src/test/java/de/openknowledge/sample/address/DeliveryAddressServiceTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@
3838
import au.com.dius.pact.provider.junit5.HttpTestTarget;
3939
import au.com.dius.pact.provider.junit5.PactVerificationContext;
4040
import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;
41+
import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify;
4142
import au.com.dius.pact.provider.junitsupport.Provider;
4243
import au.com.dius.pact.provider.junitsupport.State;
4344
import au.com.dius.pact.provider.junitsupport.StateChangeAction;
44-
import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
45+
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
4546
import de.openknowledge.sample.address.domain.AddressValidationService;
4647
import rocks.limburg.cdimock.MockitoBeans;
4748

49+
@IgnoreNoPactsToVerify
4850
@MockitoBeans(types = {AddressValidationService.class})
4951
@Provider("delivery-service")
50-
@PactFolder("src/test/pacts")
52+
@PactBroker(url = "${pactBroker.url:http://localhost:5000}")
5153
@MonoMeecrowaveConfig
5254
public class DeliveryAddressServiceTest {
5355

0 commit comments

Comments
 (0)