From c7911705be40f2fe8315124b9d3bd837cb2d1582 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Dec 2024 09:59:01 +1100 Subject: [PATCH 1/7] chore: Update readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6dab78336..19860ed8f 100644 --- a/README.md +++ b/README.md @@ -46,11 +46,12 @@ and in the [Pact-JVM wiki](https://github.com/pact-foundation/pact-jvm/wiki). [S ## Supported JDK and specification versions: -| Branch | Specification | JDK | Kotlin Version | Latest Version | Notes | -|------------------------------------------------------------------------|---------------|------------|----------------|----------------|-------| -| [4.6.x](https://github.com/pact-foundation/pact-jvm/blob/v4.6.x/README.md) master | V4 + plugins | 17+ | 1.8.22 | 4.6.15 | | -| [4.5.x](https://github.com/pact-foundation/pact-jvm/blob/v4.5.x/README.md) | V4 + plugins | 11+/17+(1) | 1.7.20 | 4.5.13 | | -| [4.1.x](https://github.com/pact-foundation/pact-jvm/blob/v4.1.x/README.md) | V3 | 8-12 | 1.3.72 | 4.1.43 | | +| Branch | Specification | JDK | Kotlin Version | Latest Version | Notes | +|-----------------------------------------------------------------------------------|---------------|-----------------------|----------------|----------------|-------| +| [4.7.x](https://github.com/pact-foundation/pact-jvm/blob/v4.7.x/README.md) | V4 + plugins | 17+ (tested up to 23) | 2.0.21 | 4.7.0-beta.0 | | +| [4.6.x](https://github.com/pact-foundation/pact-jvm/blob/v4.6.x/README.md) master | V4 + plugins | 17+ (tested up to 18) | 1.8.22 | 4.6.15 | | +| [4.5.x](https://github.com/pact-foundation/pact-jvm/blob/v4.5.x/README.md) | V4 + plugins | 11+/17+(1) | 1.7.20 | 4.5.13 | | +| [4.1.x](https://github.com/pact-foundation/pact-jvm/blob/v4.1.x/README.md) | V3 | 8-12 | 1.3.72 | 4.1.43 | | **Notes:** * **1:** Spring6 support library requires JDK 17+. The rest of Pact-JVM 4.5.x libs require 11+. From 147a2a6614c05a2e0fab584ce65f23716f5f25ad Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Dec 2024 10:23:10 +1100 Subject: [PATCH 2/7] fix: LambdaDslJsonArray has no datetime function #1839 --- .../pact/consumer/dsl/LambdaDslJsonArray.java | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java index 68dd69705..461047495 100644 --- a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java +++ b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java @@ -304,8 +304,7 @@ public LambdaDslJsonArray time(final String format, final Date example) { */ @Deprecated public LambdaDslJsonArray timestamp() { - pactArray.datetime(); - return this; + return datetime(); } /** @@ -316,8 +315,7 @@ public LambdaDslJsonArray timestamp() { */ @Deprecated public LambdaDslJsonArray timestamp(final String format) { - pactArray.datetime(format); - return this; + return datetime(format); } /** @@ -329,8 +327,7 @@ public LambdaDslJsonArray timestamp(final String format) { */ @Deprecated public LambdaDslJsonArray timestamp(final String format, final Date example) { - pactArray.datetime(format, example); - return this; + return datetime(format, example); } /** @@ -342,10 +339,49 @@ public LambdaDslJsonArray timestamp(final String format, final Date example) { */ @Deprecated public LambdaDslJsonArray timestamp(final String format, final Instant example) { - pactArray.datetime(format, example); - return this; + return datetime(format, example); } + /** + * Element that must be an ISO formatted date/time + */ + public LambdaDslJsonArray datetime() { + pactArray.datetime(); + return this; + } + + /** + * Element that must match the given date/time format + * + * @param format date/time format + */ + public LambdaDslJsonArray datetime(final String format) { + pactArray.datetime(format); + return this; + } + + /** + * Element that must match the given date/time format + * + * @param format date/time format + * @param example example date and time to use for generated bodies + */ + public LambdaDslJsonArray datetime(final String format, final Date example) { + pactArray.datetime(format, example); + return this; + } + + /** + * Element that must match the given date/time format + * + * @param format date/time format + * @param example example date and time to use for generated bodies + */ + public LambdaDslJsonArray datetime(final String format, final Instant example) { + pactArray.datetime(format, example); + return this; + } + /** * Element that must be a numeric identifier */ From 19c663c8c1c1d5b9522b7cb93fdb611722629d93 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Dec 2024 10:24:23 +1100 Subject: [PATCH 3/7] chore: The pact-jvm-server main spec was not configured correctly --- pact-jvm-server/build.gradle | 2 +- .../src/test/groovy/au/com/dius/pact/server/MainSpec.groovy | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pact-jvm-server/build.gradle b/pact-jvm-server/build.gradle index 1f5aab28f..211dfa5f8 100644 --- a/pact-jvm-server/build.gradle +++ b/pact-jvm-server/build.gradle @@ -43,7 +43,7 @@ java { } test { - dependsOn(':pact-jvm-server:assembleDist') + dependsOn(':pact-jvm-server:installDist') systemProperty('appExecutable', (new File(buildDir, 'install/pact-jvm-server/bin/pact-jvm-server')).path) } diff --git a/pact-jvm-server/src/test/groovy/au/com/dius/pact/server/MainSpec.groovy b/pact-jvm-server/src/test/groovy/au/com/dius/pact/server/MainSpec.groovy index b4831b4f7..76b7f328d 100644 --- a/pact-jvm-server/src/test/groovy/au/com/dius/pact/server/MainSpec.groovy +++ b/pact-jvm-server/src/test/groovy/au/com/dius/pact/server/MainSpec.groovy @@ -4,10 +4,13 @@ import groovy.json.JsonSlurper import org.apache.hc.client5.http.fluent.Request import org.apache.hc.core5.http.ContentType import org.apache.hc.core5.http.HttpResponse +import spock.lang.IgnoreIf import spock.lang.Specification import java.util.concurrent.TimeUnit +@IgnoreIf({ os.windows }) +@IgnoreIf({ System.getenv('CI') != null }) class MainSpec extends Specification { def 'application command line args'() { when: From 38c0d27b89d81eef71084c9c4fd604dbbaaf5ccf Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Dec 2024 10:59:23 +1100 Subject: [PATCH 4/7] feat: Update LambdaDsl.newJsonArray to allow setting the number of examples --- .../com/dius/pact/consumer/dsl/LambdaDsl.java | 12 ++++++++++++ .../consumer/dsl/LambdaDslJsonArrayTest.java | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java index 459d1313d..9de883d50 100644 --- a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java +++ b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java @@ -24,6 +24,18 @@ public static LambdaDslJsonArray newJsonArray(Consumer array return dslArray; } + /** + * DSL function to simplify creating a {@link DslPart} generated from a {@link LambdaDslJsonArray}. + * @param examples Number of examples to populate the array with + */ + public static LambdaDslJsonArray newJsonArray(Integer examples, Consumer array) { + final PactDslJsonArray pactDslJsonArray = new PactDslJsonArray(); + pactDslJsonArray.setNumberExamples(examples); + final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(pactDslJsonArray); + array.accept(dslArray); + return dslArray; + } + /** * DSL function to simplify creating a {@link DslPart} generated from a {@link LambdaDslJsonArray} where a minimum base array size is specified */ diff --git a/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java b/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java index 1fcb958ca..919e87856 100644 --- a/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java +++ b/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java @@ -764,4 +764,21 @@ public void testUnorderedArrayMatcher() { assertThat(lambdaPactDsl.getMatchers(), is(pactDslJson.getMatchers())); } + @Test + public void arrayEachLike() { + // Old DSL + final DslPart pactDslJson = PactDslJsonArray + .arrayEachLike(2) + .stringType("name", "Berlin") + .close(); + + // Lambda DSL + final DslPart lambdaPactDsl = LambdaDsl.newJsonArray(2, array -> + array.object(obj -> + obj.stringType("name", "Berlin") + ) + ).build().close(); + + assertThat(lambdaPactDsl.getBody().toString(), is(pactDslJson.getBody().toString())); + } } From 2d2016317634a62fb3da321b4c79307ebff28e51 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Dec 2024 14:21:15 +1100 Subject: [PATCH 5/7] fix: Dependency conflict with org.slf4j:slf4j-api was causing Spring tests to fail --- .../au.com.dius.pact.kotlin-common-conventions.gradle | 2 +- provider/junit5spring/build.gradle | 6 ++++-- .../spring/junit5/MockMvcTestTargetWebMvcTestJava.java | 2 -- .../pact/provider/spring/junit5/WebTestClientPactTest.java | 2 -- provider/spring/README.md | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle index 5d3e9bf6f..af9721489 100644 --- a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle +++ b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle @@ -41,7 +41,7 @@ dependencies { implementation 'org.apache.commons:commons-collections4:4.4' implementation 'org.apache.tika:tika-core:2.9.1' implementation 'com.google.guava:guava:31.1-jre' - implementation 'org.slf4j:slf4j-api:1.7.36' + implementation 'org.slf4j:slf4j-api:2.0.4' implementation 'io.ktor:ktor-http-jvm:2.3.8' implementation 'io.ktor:ktor-server-netty:2.3.8' implementation 'io.ktor:ktor-network-tls-certificates:2.3.8' diff --git a/provider/junit5spring/build.gradle b/provider/junit5spring/build.gradle index e46c2c8e6..e96a1c644 100644 --- a/provider/junit5spring/build.gradle +++ b/provider/junit5spring/build.gradle @@ -17,7 +17,9 @@ dependencies { implementation 'org.apache.commons:commons-lang3' implementation 'javax.mail:mail:1.5.0-b01' - testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.14' - testImplementation 'org.springframework.boot:spring-boot-starter-web:2.5.14' + testImplementation 'org.springframework.boot:spring-boot-test:2.5.14' + testImplementation 'org.springframework.boot:spring-boot-test-autoconfigure:2.5.14' + testImplementation 'org.springframework:spring-webmvc:5.3.20' testImplementation 'org.apache.groovy:groovy' + testImplementation 'org.yaml:snakeyaml:1.33' } diff --git a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java index 9a8126bab..379859991 100644 --- a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java +++ b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java @@ -5,7 +5,6 @@ import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -24,7 +23,6 @@ @WebMvcTest @Provider("myAwesomeService") @PactFolder("pacts") -@Disabled // TODO: this fails with NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder class MockMvcTestTargetWebMvcTestJava { @Autowired diff --git a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java index 39762977b..0c55c023a 100644 --- a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java +++ b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java @@ -4,7 +4,6 @@ import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; @@ -18,7 +17,6 @@ @SpringBootTest @Provider("myAwesomeService") @PactFolder("pacts") -@Disabled // TODO: this fails with NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder class WebTestClientPactTest { public static class Handler { diff --git a/provider/spring/README.md b/provider/spring/README.md index 5125919cb..01cc7d539 100644 --- a/provider/spring/README.md +++ b/provider/spring/README.md @@ -198,7 +198,7 @@ public class PactVerificationTest { ``` #### JUnit5 -You actually don't need to dependend on `pact-jvm-provider-spring` for this. It's sufficient to depend on `pact-jvm-provider-junit5`. +You actually don't need to depend on `pact-jvm-provider-spring` for this. It's sufficient to depend on `pact-jvm-provider-junit5`. You can set the port to the `HttpTestTarget` object in the before method. From 47039f3dfda2e3b82fb6d99ba3ce8b6e38467bbf Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 5 Dec 2024 09:38:43 +1100 Subject: [PATCH 6/7] update changelog for release 4.6.16 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf7a2fc31..1778e63ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD` replacing TAGNAME and HEAD as appropriate. +# 4.6.16 - Maintenance Release + +* 2d2016317 - fix: Dependency conflict with org.slf4j:slf4j-api was causing Spring tests to fail (Ronald Holshausen, Wed Dec 4 14:21:15 2024 +1100) +* 38c0d27b8 - feat: Update LambdaDsl.newJsonArray to allow setting the number of examples (Ronald Holshausen, Wed Dec 4 10:59:23 2024 +1100) +* 19c663c8c - chore: The pact-jvm-server main spec was not configured correctly (Ronald Holshausen, Wed Dec 4 10:24:23 2024 +1100) +* 147a2a661 - fix: LambdaDslJsonArray has no datetime function #1839 (Ronald Holshausen, Wed Dec 4 10:23:10 2024 +1100) +* c7911705b - chore: Update readme (Ronald Holshausen, Wed Dec 4 09:59:01 2024 +1100) +* 7229244f6 - Merge pull request #1837 from cburgmer/patch-1 (Ronald Holshausen, Fri Nov 15 10:03:21 2024 +1100) +* e95461a6a - Fix path to Clojure example (Christoph Burgmer, Thu Nov 14 14:21:10 2024 +0100) +* 9f6b209e2 - chore: Add a test + update docs on JUnit 4 report dir default #1836 (Ronald Holshausen, Thu Nov 14 15:58:48 2024 +1100) +* 3e501f58e - chore: Add a test for pact-jvm-server (Ronald Holshausen, Tue Oct 29 17:40:28 2024 +1100) +* 85c92365e - Update README.md (Ronald Holshausen, Tue Oct 29 11:32:02 2024 +1100) +* 5c41e17fc - bump version to 4.6.16 (Ronald Holshausen, Tue Oct 29 10:38:07 2024 +1100) + # 4.6.15 - Maintenance Release * 93fe19637 - fix: Log the error response bodies from the Pact Broker #1830 (Ronald Holshausen, Thu Oct 24 11:41:59 2024 +1100) From 8b09520f2def2710102f25704c2820a280c59c18 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 5 Dec 2024 09:50:10 +1100 Subject: [PATCH 7/7] bump version to 4.6.17 --- .../groovy/au.com.dius.pact.kotlin-common-conventions.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle index af9721489..fed8a43f8 100644 --- a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle +++ b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle @@ -12,7 +12,7 @@ repositories { mavenCentral() } -version = '4.6.16' +version = '4.6.17' java { targetCompatibility = '17'