Skip to content

Commit 48fa082

Browse files
author
APAC\PMUKIRI
committed
Chore: Placed docker file and Readme.md content
1 parent f775a07 commit 48fa082

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

consumer/junit5/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,43 @@ variable to 'true'.
368368
By default, the Pact lifecycle will be invoked for every test method and will expect there to be a method annotated
369369
with `@Pact` for each test method invoked. To add non-Pact tests, just annotate the non-Pact test method with the
370370
`@PactIgnore` annotation.
371+
372+
# ClassicJavaPact - Setup
373+
374+
1. Install Windows Subsystem for Linux (WSL).
375+
2. Install Docker in the WSL.
376+
[version of docker: Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1]
377+
3. Install Docker-compose plugin in WSL.
378+
1. Download Docker Compose
379+
```bash
380+
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
381+
```
382+
2. Make the Docker Compose binary executable
383+
```bash
384+
sudo chmod +x /usr/local/bin/docker-compose
385+
```
386+
3. Verify the installation
387+
```bash
388+
docker-compose --version
389+
```
390+
4. Run the Docker compose command to run Pact-broker.yml file
391+
```bash
392+
docker-compose up -d
393+
```
394+
5. Run the ClassicJavaPactTest in Consumer/Junit5 package
395+
6. Run the docker-compose file in resources of Junit5 in wsl
396+
7. Then publish the interaction file to localserver at 9292 port. By using plugin and below gradle task:
397+
```bash
398+
id "au.com.dius.pact" version "4.3.10"
399+
```
400+
```bash
401+
//./gradlew pactPublish --> command to publish pact file to pact broker.
402+
pact {
403+
publish {
404+
pactDirectory = file('build/pacts/samples')
405+
pactBrokerUrl = 'http://localhost:9292'
406+
consumerVersion = '1.0.0'
407+
}
408+
}
409+
```
410+
8. Run the ClassicJavaPactTest in Provider/Junit5 package

consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/BasicJavaPactTest.java renamed to consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/ClassicJavaPactTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@ExtendWith(PactConsumerTestExt.class)
2121
@PactTestFor(providerName = "ProviderTestPost", pactVersion = PactSpecVersion.V3)
2222
@PactDirectory("build/pacts/samples")
23-
public class BasicJavaPactTest {
23+
public class ClassicJavaPactTest {
2424

2525
public static DslPart getDslPartiPart() throws IOException {
2626
return LambdaDsl.newJsonBody((body) -> {
@@ -54,7 +54,6 @@ void runTestPostPrudhvi(MockServer mockServer) throws IOException {
5454
"}", ContentType.APPLICATION_JSON)
5555
.execute().returnResponse();
5656
Assertions.assertEquals(postResponse.getCode(), 200);
57-
5857
}
5958
}
6059
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: "3"
2+
3+
services:
4+
postgres:
5+
image: postgres
6+
healthcheck:
7+
test: psql postgres --command "select 1" -U postgres
8+
volumes:
9+
- postgres-volume:/var/lib/postgresql/data
10+
ports:
11+
- "5402:5402"
12+
environment:
13+
POSTGRES_USER: postgres
14+
POSTGRES_PASSWORD: password
15+
POSTGRES_DB: postgres
16+
17+
pact-broker:
18+
image: "pactfoundation/pact-broker:2.110.0-pactbroker2.107.1"
19+
ports:
20+
- "9292:9292"
21+
depends_on:
22+
- postgres
23+
environment:
24+
PACT_BROKER_PORT: '9292'
25+
PACT_BROKER_DATABASE_URL: "postgres://postgres:password@postgres/postgres"
26+
PACT_BROKER_LOG_LEVEL: INFO
27+
PACT_BROKER_SQL_LOG_LEVEL: DEBUG
28+
PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES: "5"
29+
PACT_BROKER_BASE_URL: 'https://localhost http://localhost http://localhost:9292 http://pact-broker:9292 https://host.docker.internal http://host.docker.internal http://host.docker.internal:9292'
30+
volumes:
31+
postgres-volume:

provider/junit5/src/test/java/au/com/dius/pact/provider/junit5/BasicJavaPactTest.java renamed to provider/junit5/src/test/java/au/com/dius/pact/provider/junit5/ClassicJavaPactTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@Provider("ProviderTestPost")
1616
@PactBroker(host = "localhost", port = "9292", consumers = "ConsumerTestPost")
17-
public class BasicJavaPactTest {
17+
public class ClassicJavaPactTest {
1818
private static final int WIREMOCK_PORT = 8080;
1919
private WireMockServer wireMockServer;
2020

0 commit comments

Comments
 (0)