Skip to content

Commit f5a756d

Browse files
committed
WIP for JUnit 5.10
1 parent ffc4731 commit f5a756d

File tree

9 files changed

+328
-8
lines changed

9 files changed

+328
-8
lines changed

bom/application/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<db2-jdbc.version>11.5.8.0</db2-jdbc.version>
140140
<shrinkwrap.version>1.2.6</shrinkwrap.version>
141141
<rest-assured.version>5.3.0</rest-assured.version>
142-
<junit.jupiter.version>5.9.3</junit.jupiter.version>
142+
<junit.jupiter.version>5.10.0-RC1</junit.jupiter.version>
143143
<junit-pioneer.version>1.5.0</junit-pioneer.version>
144144
<infinispan.version>14.0.11.Final</infinispan.version>
145145
<infinispan.protostream.version>4.6.2.Final</infinispan.protostream.version>

independent-projects/bootstrap/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<assertj.version>3.24.2</assertj.version>
4848
<eclipse-minimal-json.version>0.9.5</eclipse-minimal-json.version>
4949
<jboss-logging.version>3.5.1.Final</jboss-logging.version>
50-
<junit.jupiter.version>5.9.3</junit.jupiter.version>
50+
<junit.jupiter.version>5.10.0-RC1</junit.jupiter.version>
5151
<maven-core.version>3.9.3</maven-core.version><!-- Keep in sync with sisu.version -->
5252
<sisu.version>0.3.5</sisu.version><!-- Keep in sync with maven-core.version -->
5353
<maven-plugin-annotations.version>3.7.1</maven-plugin-annotations.version>

independent-projects/extension-maven-plugin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<maven-plugin-plugin.version>3.8.1</maven-plugin-plugin.version>
4646
<jackson-bom.version>2.15.2</jackson-bom.version>
4747
<smallrye-beanbag.version>1.3.2</smallrye-beanbag.version>
48-
<junit.jupiter.version>5.9.3</junit.jupiter.version>
48+
<junit.jupiter.version>5.10.0-RC1</junit.jupiter.version>
4949
</properties>
5050
<build>
5151
<testResources>

independent-projects/tools/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<assertj.version>3.24.2</assertj.version>
5656
<jackson-bom.version>2.15.2</jackson-bom.version>
5757
<jakarta.enterprise.cdi-api.version>4.0.1</jakarta.enterprise.cdi-api.version>
58-
<junit.version>5.9.3</junit.version>
58+
<junit.version>5.10.0-M1</junit.version>
5959
<commons-compress.version>1.23.0</commons-compress.version>
6060
<jboss-logging.version>3.5.1.Final</jboss-logging.version>
6161
<mockito.version>5.3.1</mockito.version>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
junit.jupiter.extensions.autodetection.enabled=true
22
junit.jupiter.testclass.order.default=io.quarkus.test.junit.util.QuarkusTestProfileAwareClassOrderer
3+
junit.platform.launcher.interceptors.enabled=true

test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractJvmQuarkusTestExtension.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ public static boolean hasPerTestResources(Class<?> requiredTestClass) {
254254
return false;
255255
}
256256

257-
protected static class PrepareResult {
258-
protected final AugmentAction augmentAction;
259-
protected final QuarkusTestProfile profileInstance;
257+
public static class PrepareResult {
258+
public final AugmentAction augmentAction;
259+
public final QuarkusTestProfile profileInstance;
260260
protected final CuratedApplication curatedApplication;
261261
protected final Path testClassLocation;
262262

test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public Thread newThread(Runnable r) {
221221

222222
testHttpEndpointProviders = TestHttpEndpointProvider.load();
223223
StartupAction startupAction = augmentAction.createInitialRuntimeApplication();
224+
System.out.println("HOLLY startup classloader is " + startupAction.getClassLoader());
224225
Thread.currentThread().setContextClassLoader(startupAction.getClassLoader());
225226
populateDeepCloneField(startupAction);
226227

@@ -355,6 +356,7 @@ private void shutdownHangDetection() {
355356
}
356357

357358
private void populateDeepCloneField(StartupAction startupAction) {
359+
System.out.println("HOLLY making deep cloner");
358360
deepClone = new SerializationWithXStreamFallbackDeepClone(startupAction.getClassLoader());
359361
}
360362

@@ -373,6 +375,7 @@ private void populateTestMethodInvokers(ClassLoader quarkusClassLoader) {
373375

374376
@Override
375377
public void beforeTestExecution(ExtensionContext context) throws Exception {
378+
System.out.println("HOLLY before test exevcution" + context.getRequiredTestClass().getClassLoader());
376379
if (isNativeOrIntegrationTest(context.getRequiredTestClass()) || isBeforeTestCallbacksEmpty()) {
377380
return;
378381
}
@@ -392,6 +395,7 @@ public void beforeTestExecution(ExtensionContext context) throws Exception {
392395

393396
@Override
394397
public void beforeEach(ExtensionContext context) throws Exception {
398+
System.out.println("HOLLY before each" + context.getRequiredTestClass().getClassLoader());
395399
if (isNativeOrIntegrationTest(context.getRequiredTestClass())) {
396400
return;
397401
}
@@ -644,6 +648,7 @@ private void throwBootFailureException() {
644648

645649
@Override
646650
public void beforeAll(ExtensionContext context) throws Exception {
651+
System.out.println("HOLLY before all" + context.getRequiredTestClass().getClassLoader());
647652
GroovyClassValue.disable();
648653
currentTestClassStack.push(context.getRequiredTestClass());
649654
//set the right launch mode in the outer CL, used by the HTTP host config source
@@ -689,6 +694,8 @@ public void interceptBeforeAllMethod(Invocation<Void> invocation, ReflectiveInvo
689694
invocation.proceed();
690695
return;
691696
}
697+
698+
System.out.println("HOLLY HI Bintercept bEFORE ALL " + invocationContext.getTargetClass().getClassLoader());
692699
resetHangTimeout();
693700
ensureStarted(extensionContext);
694701
if (failedBoot) {
@@ -916,6 +923,7 @@ private Object runExtensionMethod(ReflectiveInvocationContext<Method> invocation
916923

917924
ClassLoader old = setCCL(runningQuarkusApplication.getClassLoader());
918925
try {
926+
System.out.println("HOLLY the actual test class is " + extensionContext.getRequiredTestClass().getClassLoader());
919927
Class<?> testClassFromTCCL = Class.forName(extensionContext.getRequiredTestClass().getName(), true,
920928
Thread.currentThread().getContextClassLoader());
921929
Map<Class<?>, Object> allTestsClasses = new HashMap<>();
@@ -963,6 +971,7 @@ private Object runExtensionMethod(ReflectiveInvocationContext<Method> invocation
963971
boolean cloneRequired = false;
964972
Object replacement = null;
965973
Class<?> argClass = parameters[i].getType();
974+
System.out.println("HOLLY checking clone on " + argClass + "<-" + argClass.getClassLoader());
966975
if (arg != null) {
967976
Class<?> theclass = argClass;
968977
while (theclass.isArray()) {
@@ -982,6 +991,8 @@ private Object runExtensionMethod(ReflectiveInvocationContext<Method> invocation
982991
cloneRequired = true;
983992
} else {
984993
try {
994+
System.out.println("comparing " + theclass.getClassLoader() + " vs "
995+
+ runningQuarkusApplication.getClassLoader());
985996
cloneRequired = runningQuarkusApplication.getClassLoader()
986997
.loadClass(theclass.getName()) != theclass;
987998
} catch (ClassNotFoundException e) {
@@ -997,7 +1008,9 @@ private Object runExtensionMethod(ReflectiveInvocationContext<Method> invocation
9971008
if (replacement != null) {
9981009
argumentsFromTccl.add(replacement);
9991010
} else if (cloneRequired) {
1000-
argumentsFromTccl.add(deepClone.clone(arg));
1011+
// argumentsFromTccl.add(deepClone.clone(arg));
1012+
argumentsFromTccl.add(arg);
1013+
System.err.println("HOLLY NOT DOING CLONE");
10011014
} else if (testMethodInvokerToUse != null) {
10021015
argumentsFromTccl.add(testMethodInvokerToUse.getClass().getMethod("methodParamInstance", String.class)
10031016
.invoke(testMethodInvokerToUse, argClass.getName()));

0 commit comments

Comments
 (0)