diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67adcbb..6d01243 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,8 +21,8 @@ jobs: - name: Set up JDK 11 uses: actions/setup-java@v4 with: - distribution: 'zulu' - java-version: '11' + distribution: 'temurin' + java-version: '17' - name: Test run: GIT_BRANCH=${GITHUB_REF:11} make test diff --git a/.github/workflows/verify_changed_pact.yml b/.github/workflows/verify_changed_pact.yml index a975b15..01ba2b7 100644 --- a/.github/workflows/verify_changed_pact.yml +++ b/.github/workflows/verify_changed_pact.yml @@ -21,7 +21,7 @@ jobs: - name: Set up JDK 11 uses: actions/setup-java@v2 with: - distribution: 'zulu' - java-version: '11' + distribution: 'temurin' + java-version: '17' - name: Build run: GIT_BRANCH=${GITHUB_REF:11} make ci_webhook diff --git a/.java-version b/.java-version index b4de394..03b6389 100644 --- a/.java-version +++ b/.java-version @@ -1 +1 @@ -11 +17.0 diff --git a/.vscode/settings.json b/.vscode/settings.json index 1133129..77e57d0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "java.configuration.updateBuildConfiguration": "automatic" + "java.configuration.updateBuildConfiguration": "automatic", + "FSharp.suggestGitignore": false } \ No newline at end of file diff --git a/build.gradle b/build.gradle index c1228fa..3b940da 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,14 @@ plugins { - id 'org.springframework.boot' version '2.3.0.RELEASE' - id 'io.spring.dependency-management' version '1.0.9.RELEASE' + id 'org.springframework.boot' version '2.7.18' + id 'io.spring.dependency-management' version '1.1.4' id 'java' - id "au.com.dius.pact" version "4.1.0" + id "au.com.dius.pact" version "4.6.3" +// id "au.com.dius.pact.provider:gradle" version "4.6.3" } group = 'com.example' version = '0.0.1-SNAPSHOT' -sourceCompatibility = '11' +sourceCompatibility = '17' repositories { mavenCentral() @@ -22,19 +23,21 @@ configurations { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.kafka:spring-kafka' - testImplementation 'au.com.dius.pact.provider:junit5:4.1.7' - testImplementation 'au.com.dius.pact.provider:spring:4.1.7' + testImplementation 'au.com.dius.pact.provider:junit5:4.6.3' + testImplementation 'au.com.dius.pact.provider:spring:4.6.3' + testImplementation 'au.com.dius.pact.provider:gradle:4.6.3' runtimeOnly 'com.h2database:h2' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } - implementation 'com.github.javafaker:javafaker:1.0.2' + implementation 'net.datafaker:datafaker:2.0.2' } test { useJUnitPlatform() + testLogging.showStandardStreams = true // output pact verification logs to stdout } pact { @@ -46,8 +49,8 @@ pact { serviceProviders { "pactflow-example-provider" { - fromPactBroker { - withSelectors { + fromPactBroker { + withSelectors { mainBranch() // (recommended) - Returns the pacts for consumers configured mainBranch property deployedOrReleased() // (recommended) - Returns the pacts for all versions of the consumer that are currently deployed or released and currently supported in any environment. // deployedTo('test') // Normally, this would not be needed, Any versions currently deployed to the specified environment. @@ -55,7 +58,7 @@ pact { // environment('test') // Normally, this would not be needed, Any versions currently deployed or released and supported in the specified environment. // environment('production') // Normally, this would not be needed, Any versions currently deployed or released and supported in the specified environment. } - } + } } } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f04d6a2..6f61557 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/src/main/java/io/pactflow/example/kafka/DummyEventGenerator.java b/src/main/java/io/pactflow/example/kafka/DummyEventGenerator.java index 4e1eb74..d8a8186 100644 --- a/src/main/java/io/pactflow/example/kafka/DummyEventGenerator.java +++ b/src/main/java/io/pactflow/example/kafka/DummyEventGenerator.java @@ -7,7 +7,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import com.github.javafaker.Faker; +import net.datafaker.Faker; @Component public class DummyEventGenerator { diff --git a/src/test/java/io/pactflow/example/kafka/ProductsKafkaProducerTest.java b/src/test/java/io/pactflow/example/kafka/ProductsKafkaProducerTest.java index 6382420..ed1be21 100644 --- a/src/test/java/io/pactflow/example/kafka/ProductsKafkaProducerTest.java +++ b/src/test/java/io/pactflow/example/kafka/ProductsKafkaProducerTest.java @@ -4,12 +4,13 @@ import au.com.dius.pact.core.model.Pact; import au.com.dius.pact.provider.MessageAndMetadata; import au.com.dius.pact.provider.PactVerifyProvider; -import au.com.dius.pact.provider.junit5.AmpqTestTarget; +import au.com.dius.pact.provider.junit5.MessageTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; +import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder; import au.com.dius.pact.provider.junitsupport.loader.VersionSelector; import java.util.HashMap; @@ -25,11 +26,18 @@ @Provider("pactflow-example-provider-java-kafka") @PactBroker(scheme = "https", host = "${PACT_BROKER_HOST}", - consumerVersionSelectors = {@VersionSelector(tag = "master"), @VersionSelector(tag = "prod")}, authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}")) public class ProductsKafkaProducerTest { private static final Logger LOGGER = LoggerFactory.getLogger(ProductsKafkaProducerTest.class); + @au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors + public static SelectorBuilder consumerVersionSelectors() { + // Select Pacts for consumers deployed or released, or on the main branch + return new SelectorBuilder() + .deployedOrReleased() + .mainBranch(); + } + @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) { @@ -38,7 +46,7 @@ void testTemplate(Pact pact, Interaction interaction, PactVerificationContext co @BeforeEach void before(PactVerificationContext context) { - context.setTarget(new AmpqTestTarget()); + context.setTarget(new MessageTestTarget()); System.out.println("GIT_COMMIT" + System.getenv("GIT_COMMIT")); System.setProperty("pact.provider.version",