From 8064fc2b42e2284d06ad9fbed707b9c5a8c6bc3a Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Thu, 15 Dec 2022 16:46:15 +0000 Subject: [PATCH] Basic Quarkus 3 toleration Quarkus 3 brings two major changes - the javax/jakarta namespace change, and a change to classloading. Quarkus 2 coredefined many pact modules to be parentfirst. In Quarkus 3, that will be done by this extension. The Quarkus 3 kotlin extension also stopped loading kotlin parent first. I was able to remove all the parent-first dependencies for the consumer. For the provider, oddly, I had it working with a single parent-first dependency in December, but now I needed the full set. I will continue working to see if I can reduce it down to a minimal set, or having both extensions in the same project will be a problem. I did have to disable one test, and have raised #73, but I think it's not a serious issue. --- pom.xml | 7 +++--- .../pact/it/DevModeContractTestIT.java | 2 +- .../pact/it/TestModeContractTestIT.java | 2 +- .../pact/testapp/AlpacaService.java | 6 ++--- .../io/quarkiverse/pact/testapp/Knitter.java | 4 ++-- .../farm/FarmWithInjectionConsumerTest.java | 24 +++++++++++-------- quarkus-pact-consumer/runtime/pom.xml | 20 ++-------------- .../testapp/farm/alpaca/AlpacaResource.java | 10 ++++---- .../alpaca/IntegrationAlpacaResource.java | 10 ++++---- .../IntegrationDevModeAlpacaResource.java | 10 ++++---- quarkus-pact-provider/runtime/pom.xml | 14 ++++++++++- 11 files changed, 55 insertions(+), 54 deletions(-) diff --git a/pom.xml b/pom.xml index 4d89657..b918908 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 io.quarkiverse @@ -17,14 +18,14 @@ docs - 2.16.2.Final + 3.0.0.Alpha3 4.3.17 3.8.1 11 UTF-8 UTF-8 - + diff --git a/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/DevModeContractTestIT.java b/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/DevModeContractTestIT.java index 6e086e8..546ae79 100644 --- a/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/DevModeContractTestIT.java +++ b/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/DevModeContractTestIT.java @@ -55,7 +55,7 @@ public void testThatTheTestsPassed() throws MavenInvocationException, IOExceptio ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, // so we need to check the pass count explicitly - Assertions.assertEquals(5, results.getTestsPassed()); + Assertions.assertEquals(4, results.getTestsPassed()); Assertions.assertEquals(0, results.getTestsFailed()); // Now confirm a pact file got written by the pact consumer diff --git a/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/TestModeContractTestIT.java b/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/TestModeContractTestIT.java index e772f2b..f3e119c 100644 --- a/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/TestModeContractTestIT.java +++ b/quarkus-pact-consumer/integration-tests/src/test/java/io/quarkiverse/pact/it/TestModeContractTestIT.java @@ -68,7 +68,7 @@ public void testThatTheTestsPassed() throws MavenInvocationException, IOExceptio ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, // so we need to check the pass count explicitly - Assertions.assertEquals(5, results.getTestsPassed()); + Assertions.assertEquals(4, results.getTestsPassed()); Assertions.assertEquals(0, results.getTestsFailed()); // Now confirm a pact file got written by the pact consumer diff --git a/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/AlpacaService.java b/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/AlpacaService.java index 607a980..b6e187c 100644 --- a/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/AlpacaService.java +++ b/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/AlpacaService.java @@ -2,9 +2,9 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; @Path("/alpaca") @RegisterRestClient(configKey = "alpaca-api") diff --git a/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/Knitter.java b/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/Knitter.java index e0cd801..9c02616 100644 --- a/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/Knitter.java +++ b/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/main/java/io/quarkiverse/pact/testapp/Knitter.java @@ -2,8 +2,8 @@ import org.eclipse.microprofile.rest.client.inject.RestClient; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; @ApplicationScoped public class Knitter { diff --git a/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/test/java/io/quarkiverse/pact/devmodetest/farm/FarmWithInjectionConsumerTest.java b/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/test/java/io/quarkiverse/pact/devmodetest/farm/FarmWithInjectionConsumerTest.java index fb6d9aa..67340dc 100644 --- a/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/test/java/io/quarkiverse/pact/devmodetest/farm/FarmWithInjectionConsumerTest.java +++ b/quarkus-pact-consumer/integration-tests/src/test/resources-filtered/projects/happy-knitter/src/test/java/io/quarkiverse/pact/devmodetest/farm/FarmWithInjectionConsumerTest.java @@ -1,5 +1,16 @@ package io.quarkiverse.pact.devmodetest.farm; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.microprofile.rest.client.inject.RestClient; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import au.com.dius.pact.consumer.MockServer; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; @@ -11,16 +22,7 @@ import io.quarkiverse.pact.testapp.ConsumerAlpaca; import io.quarkiverse.pact.testapp.Knitter; import io.quarkus.test.junit.QuarkusTest; -import org.eclipse.microprofile.rest.client.inject.RestClient; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import jakarta.inject.Inject; @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "farm", port = "8085") @@ -80,6 +82,8 @@ public void testContractLooksCorrect() { } @Test + @Disabled // With Quarkus 3, test methods cannot directly access Pact classes, because they are in different classloaders. See https://github.com/quarkiverse/quarkus-pact/issues/73 + // The good news is there are very few use cases where test code should be doing parameter injection of the mock server. public void testPortIsCorrect(MockServer mockServer) { // If we have a test, pact assumes we will call it and validates there was a call ConsumerAlpaca alpaca = alpacaService.getByName("fluffy"); diff --git a/quarkus-pact-consumer/runtime/pom.xml b/quarkus-pact-consumer/runtime/pom.xml index 0e23b64..5ff860c 100644 --- a/quarkus-pact-consumer/runtime/pom.xml +++ b/quarkus-pact-consumer/runtime/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 io.quarkiverse.pact @@ -29,23 +30,6 @@ io.quarkus quarkus-extension-maven-plugin ${quarkus.version} - - - io.github.microutils:kotlin-logging-jvm - com.michael-bull.kotlin-result:kotlin-result-jvm - io.ktor:ktor-http-jvm - - org.apache.tika:tika-core - org.apache.httpcomponents.core5:httpcore5 - org.apache.httpcomponents.client5:httpclient5 - com.github.ajalt:mordant - au.com.dius.pact.core:matchers - io.pact.plugin.driver:core - org.apache.commons:commons-collections4 - com.github.zafarkhaja:java-semver - io.github.java-diff-utils:java-diff-utils - - compile diff --git a/quarkus-pact-provider/deployment/src/test/java/io/quarkiverse/pact/testapp/farm/alpaca/AlpacaResource.java b/quarkus-pact-provider/deployment/src/test/java/io/quarkiverse/pact/testapp/farm/alpaca/AlpacaResource.java index 8f99f99..083f31a 100644 --- a/quarkus-pact-provider/deployment/src/test/java/io/quarkiverse/pact/testapp/farm/alpaca/AlpacaResource.java +++ b/quarkus-pact-provider/deployment/src/test/java/io/quarkiverse/pact/testapp/farm/alpaca/AlpacaResource.java @@ -4,11 +4,11 @@ import java.util.Map; import java.util.Objects; -import javax.ws.rs.CookieParam; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; @Path("/alpaca") public class AlpacaResource { diff --git a/quarkus-pact-provider/integration-tests/src/main/java/io/quarkiverse/pact/testapp/farm/alpaca/IntegrationAlpacaResource.java b/quarkus-pact-provider/integration-tests/src/main/java/io/quarkiverse/pact/testapp/farm/alpaca/IntegrationAlpacaResource.java index 195634d..af5ee2b 100644 --- a/quarkus-pact-provider/integration-tests/src/main/java/io/quarkiverse/pact/testapp/farm/alpaca/IntegrationAlpacaResource.java +++ b/quarkus-pact-provider/integration-tests/src/main/java/io/quarkiverse/pact/testapp/farm/alpaca/IntegrationAlpacaResource.java @@ -4,11 +4,11 @@ import java.util.Map; import java.util.Objects; -import javax.ws.rs.CookieParam; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; @Path("/alpaca") public class IntegrationAlpacaResource { diff --git a/quarkus-pact-provider/integration-tests/src/test/resources-filtered/projects/happy-farm/src/main/java/io/quarkiverse/pact/testapp/IntegrationDevModeAlpacaResource.java b/quarkus-pact-provider/integration-tests/src/test/resources-filtered/projects/happy-farm/src/main/java/io/quarkiverse/pact/testapp/IntegrationDevModeAlpacaResource.java index 323c6b2..2f720eb 100644 --- a/quarkus-pact-provider/integration-tests/src/test/resources-filtered/projects/happy-farm/src/main/java/io/quarkiverse/pact/testapp/IntegrationDevModeAlpacaResource.java +++ b/quarkus-pact-provider/integration-tests/src/test/resources-filtered/projects/happy-farm/src/main/java/io/quarkiverse/pact/testapp/IntegrationDevModeAlpacaResource.java @@ -4,11 +4,11 @@ import java.util.Map; import java.util.Objects; -import javax.ws.rs.CookieParam; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; @Path("/alpaca") public class IntegrationDevModeAlpacaResource { diff --git a/quarkus-pact-provider/runtime/pom.xml b/quarkus-pact-provider/runtime/pom.xml index 686a902..891d4df 100644 --- a/quarkus-pact-provider/runtime/pom.xml +++ b/quarkus-pact-provider/runtime/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 io.quarkiverse.pact @@ -31,6 +32,15 @@ ${quarkus.version} + au.com.dius.pact.provider:junit5 + org.jetbrains.kotlin:kotlin-stdlib-jdk8 + org.jetbrains.kotlin:kotlin-stdlib-jdk7 + org.jetbrains.kotlin:kotlin-reflect + org.jetbrains.kotlin:kotlin-stdlib + org.jetbrains.kotlin:kotlin-stdlib-common + org.jetbrains:annotations + au.com.dius.pact:provider + au.com.dius.pact.core:support io.github.microutils:kotlin-logging-jvm com.michael-bull.kotlin-result:kotlin-result-jvm io.ktor:ktor-http-jvm @@ -40,6 +50,8 @@ org.apache.httpcomponents.client5:httpclient5 com.github.ajalt:mordant au.com.dius.pact.core:matchers + au.com.dius.pact.core:model + au.com.dius.pact.core:pactbroker io.pact.plugin.driver:core org.apache.commons:commons-collections4 com.github.zafarkhaja:java-semver