Skip to content

Commit 878028d

Browse files
ArneLimburgnilshartmann96
authored andcommitted
feat: Use pact broker
1 parent a8c0230 commit 878028d

10 files changed

Lines changed: 36 additions & 19 deletions

File tree

.github/workflows/build.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ 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
26+
run: mvn clean package -f customer-service/pom.xml pact:publish
2127

2228
- name: Build billing-service
2329
run: mvn clean package -f billing-service/pom.xml
2430

2531
- name: Build delivery-service
26-
run: mvn clean package -f delivery-service/pom.xml
32+
run: mvn clean package -f delivery-service/pom.xml pact:publish
2733

2834
- name: Build address-validation-service
2935
run: mvn clean package -f address-validation-service/pom.xml
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:5050}")
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:5050}")
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
@@ -19,6 +19,7 @@
1919
<maven.compiler.target>17</maven.compiler.target>
2020
<failOnMissingWebXml>false</failOnMissingWebXml>
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
<pactBroker.url>http://localhost:5050</pactBroker.url>
2223
<meecrowave.version>2.0.0</meecrowave.version>
2324
<deltaspike.version>1.9.6</deltaspike.version>
2425
<junit.version>5.8.2</junit.version>
@@ -202,6 +203,14 @@
202203
</execution>
203204
</executions>
204205
</plugin>
206+
<plugin>
207+
<groupId>au.com.dius.pact.provider</groupId>
208+
<artifactId>maven</artifactId>
209+
<version>4.3.5</version>
210+
<configuration>
211+
<pactBrokerUrl>${pactBroker.url}</pactBrokerUrl>
212+
</configuration>
213+
</plugin>
205214
</plugins>
206215
</build>
207216
</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
@@ -19,6 +19,7 @@
1919
<maven.compiler.target>17</maven.compiler.target>
2020
<failOnMissingWebXml>false</failOnMissingWebXml>
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
<pactBroker.url>http://localhost:5050</pactBroker.url>
2223
<meecrowave.version>2.0.0</meecrowave.version>
2324
<deltaspike.version>1.9.6</deltaspike.version>
2425
<hibernate.version>7.2.2.Final</hibernate.version>
@@ -175,6 +176,7 @@
175176
<configuration>
176177
<systemPropertyVariables>
177178
<pact.provider.version>${project.version}</pact.provider.version>
179+
<pactBroker.url>${pactBroker.url}</pactBroker.url>
178180
<jakarta.persistence.jdbc.url>jdbc:h2:mem:delivery</jakarta.persistence.jdbc.url>
179181
<jakarta.persistence.jdbc.driver>org.h2.Driver</jakarta.persistence.jdbc.driver>
180182
<jakarta.persistence.jdbc.user>sa</jakarta.persistence.jdbc.user>
@@ -215,7 +217,7 @@
215217
<artifactId>maven</artifactId>
216218
<version>4.3.5</version>
217219
<configuration>
218-
<pactBrokerUrl>http://localhost:5050</pactBrokerUrl>
220+
<pactBrokerUrl>${pactBroker.url}</pactBrokerUrl>
219221
</configuration>
220222
</plugin>
221223
</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
@@ -41,16 +41,18 @@
4141
import au.com.dius.pact.provider.junit5.HttpTestTarget;
4242
import au.com.dius.pact.provider.junit5.PactVerificationContext;
4343
import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;
44+
import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify;
4445
import au.com.dius.pact.provider.junitsupport.Provider;
4546
import au.com.dius.pact.provider.junitsupport.State;
4647
import au.com.dius.pact.provider.junitsupport.StateChangeAction;
47-
import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
48+
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
4849
import de.openknowledge.sample.address.domain.AddressValidationService;
4950
import rocks.limburg.cdimock.MockitoBeans;
5051

52+
@IgnoreNoPactsToVerify
5153
@MockitoBeans(types = {AddressValidationService.class})
5254
@Provider("delivery-service")
53-
@PactFolder("src/test/pacts")
55+
@PactBroker(url = "${pactBroker.url:http://localhost:5050}")
5456
@MonoMeecrowaveConfig
5557
public class DeliveryAddressServiceTest {
5658

0 commit comments

Comments
 (0)