From dfcb955095a3f4378a0dec5a4ac9bcd8c890c6a3 Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Fri, 21 Jan 2022 23:46:02 +0100 Subject: [PATCH] Load MockitoConfiguration parent-first to make it work in continuous testing Moves the class to a separate new module to reduce the blast radius. --- bom/application/pom.xml | 5 ++++ core/runtime/pom.xml | 1 + test-framework/junit5-mockito-config/pom.xml | 27 +++++++++++++++++++ .../configuration/MockitoConfiguration.java | 4 +-- test-framework/junit5-mockito/pom.xml | 7 +++++ test-framework/junit5-properties/pom.xml | 2 +- test-framework/pom.xml | 1 + 7 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 test-framework/junit5-mockito-config/pom.xml rename test-framework/{junit5-mockito => junit5-mockito-config}/src/main/java/org/mockito/configuration/MockitoConfiguration.java (86%) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 29eef6fd5f484..9e16eb02e80a7 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -2576,6 +2576,11 @@ quarkus-junit5-mockito ${project.version} + + io.quarkus + quarkus-junit5-mockito-config + ${project.version} + io.quarkus quarkus-junit5-vertx diff --git a/core/runtime/pom.xml b/core/runtime/pom.xml index c7962c99bd504..582b4e42fa4ae 100644 --- a/core/runtime/pom.xml +++ b/core/runtime/pom.xml @@ -170,6 +170,7 @@ io.quarkus:quarkus-class-change-agent org.jacoco:org.jacoco.agent:runtime io.quarkus:quarkus-bootstrap-gradle-resolver + io.quarkus:quarkus-junit5-mockito-config diff --git a/test-framework/junit5-mockito-config/pom.xml b/test-framework/junit5-mockito-config/pom.xml new file mode 100644 index 0000000000000..505bb46ed6138 --- /dev/null +++ b/test-framework/junit5-mockito-config/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + io.quarkus + quarkus-test-framework + 999-SNAPSHOT + + + quarkus-junit5-mockito-config + Quarkus - Test framework - JUnit 5 - Mockito Config + + Contains a MockitoConfiguration that has to be loaded parent-first to work in continuous testing. + It is separated from junit5-mockito to minimize the blast radius. + + + + + org.mockito + mockito-core + + + + diff --git a/test-framework/junit5-mockito/src/main/java/org/mockito/configuration/MockitoConfiguration.java b/test-framework/junit5-mockito-config/src/main/java/org/mockito/configuration/MockitoConfiguration.java similarity index 86% rename from test-framework/junit5-mockito/src/main/java/org/mockito/configuration/MockitoConfiguration.java rename to test-framework/junit5-mockito-config/src/main/java/org/mockito/configuration/MockitoConfiguration.java index fdd103e884d23..df02392f8ed76 100644 --- a/test-framework/junit5-mockito/src/main/java/org/mockito/configuration/MockitoConfiguration.java +++ b/test-framework/junit5-mockito-config/src/main/java/org/mockito/configuration/MockitoConfiguration.java @@ -4,8 +4,6 @@ import org.mockito.stubbing.Answer; -import io.quarkus.test.junit.mockito.internal.MutinyAnswer; - public class MockitoConfiguration extends DefaultMockitoConfiguration { @SuppressWarnings("unchecked") @@ -14,7 +12,7 @@ public Answer getDefaultAnswer() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { // we need to load it from the TCCL (QuarkusClassLoader) instead of our class loader (JUnit CL) - Class mutinyAnswer = cl.loadClass(MutinyAnswer.class.getName()); + Class mutinyAnswer = cl.loadClass("io.quarkus.test.junit.mockito.internal.MutinyAnswer"); return (Answer) mutinyAnswer.getDeclaredConstructor().newInstance(); } catch (ClassNotFoundException | SecurityException | IllegalArgumentException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { diff --git a/test-framework/junit5-mockito/pom.xml b/test-framework/junit5-mockito/pom.xml index 337bbb7347f96..aed8ac6101148 100644 --- a/test-framework/junit5-mockito/pom.xml +++ b/test-framework/junit5-mockito/pom.xml @@ -18,6 +18,13 @@ io.quarkus quarkus-junit5 + + + io.quarkus + quarkus-junit5-mockito-config + io.quarkus quarkus-arc-deployment diff --git a/test-framework/junit5-properties/pom.xml b/test-framework/junit5-properties/pom.xml index a7a604a25caba..63fb5bf6fe370 100644 --- a/test-framework/junit5-properties/pom.xml +++ b/test-framework/junit5-properties/pom.xml @@ -13,7 +13,7 @@ quarkus-junit5-properties Quarkus - Test Framework - JUnit 5 - Properties - Contains junit-platform.properties in a "use-excludable" way + Contains junit-platform.properties in a "user-excludable" way until https://github.com/junit-team/junit5/issues/2794 is available. diff --git a/test-framework/pom.xml b/test-framework/pom.xml index 9e30d6d7b1edf..1eef291e6d199 100644 --- a/test-framework/pom.xml +++ b/test-framework/pom.xml @@ -28,6 +28,7 @@ junit5-properties junit5 junit5-mockito + junit5-mockito-config junit5-vertx amazon-lambda arquillian