diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java index c9be56b34004b..cea13c6d135f4 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java @@ -197,19 +197,23 @@ public void quarkusStarting() { }); Map> resultsByClass = new HashMap<>(); - launcher.execute(testPlan, new TestExecutionListener() { @Override public void executionStarted(TestIdentifier testIdentifier) { String className = ""; + Class clazz = null; if (testIdentifier.getSource().isPresent()) { if (testIdentifier.getSource().get() instanceof MethodSource) { - className = ((MethodSource) testIdentifier.getSource().get()).getClassName(); + clazz = ((MethodSource) testIdentifier.getSource().get()).getJavaClass(); } else if (testIdentifier.getSource().get() instanceof ClassSource) { - className = ((ClassSource) testIdentifier.getSource().get()).getClassName(); + clazz = ((ClassSource) testIdentifier.getSource().get()).getJavaClass(); } } + if (clazz != null) { + className = clazz.getName(); + Thread.currentThread().setContextClassLoader(clazz.getClassLoader()); + } for (TestRunListener listener : listeners) { listener.testStarted(testIdentifier, className); } @@ -513,7 +517,8 @@ public String apply(Class aClass) { } } - cl = testApplication.createRuntimeClassLoader(Collections.emptyMap(), transformedClasses); + cl = testApplication.createRuntimeClassLoader(testApplication.getAugmentClassLoader(), Collections.emptyMap(), + transformedClasses); for (String i : unitTestClasses) { try { qtClasses.add(cl.loadClass(i)); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java index 4b47e741d0473..71f83ed551706 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunner.java @@ -120,6 +120,7 @@ private void runTests(ClassScanResult classScanResult, boolean reRunFailures) { Thread t = new Thread(new Runnable() { @Override public void run() { + Thread.currentThread().setContextClassLoader(testApplication.getAugmentClassLoader()); try { try { runInternal(classScanResult, reRunFailures); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java index e2bfb2dd5a488..1a789d49bccdf 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java @@ -116,8 +116,9 @@ public void init() { try { testCuratedApplication = curatedApplication.getQuarkusBootstrap().clonedBuilder() .setMode(QuarkusBootstrap.Mode.TEST) - .setDisableClasspathCache(true) + .setDisableClasspathCache(false) .setIsolateDeployment(true) + .setBaseClassLoader(getClass().getClassLoader()) .setTest(true) .setAuxiliaryApplication(true) .addAdditionalApplicationArchive(new AdditionalDependency( diff --git a/core/runtime/pom.xml b/core/runtime/pom.xml index 1979550e4b4fc..fbe98d297c5ec 100644 --- a/core/runtime/pom.xml +++ b/core/runtime/pom.xml @@ -151,6 +151,19 @@ io.quarkus:quarkus-class-change-agent org.jacoco:org.jacoco.agent:runtime io.quarkus:quarkus-bootstrap-gradle-resolver + + + org.codehaus.groovy:groovy + + + org.junit.platform:junit-platform-launcher + org.apiguardian:apiguardian-api + org.junit.platform:junit-platform-engine + org.opentest4j:opentest4j + org.junit.platform:junit-platform-commons + org.graalvm.sdk:graal-sdk @@ -163,9 +176,7 @@ org.wildfly.common:wildfly-common io.smallrye.common:smallrye-common-io - - org.codehaus.groovy:groovy + io.smallrye:smallrye-config diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java index e069d09f147dd..1ec95f0e26753 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java @@ -171,7 +171,8 @@ private void addCpElement(QuarkusClassLoader.Builder builder, AppArtifact dep, C public synchronized QuarkusClassLoader getAugmentClassLoader() { if (augmentClassLoader == null) { //first run, we need to build all the class loaders - QuarkusClassLoader.Builder builder = QuarkusClassLoader.builder("Augmentation Class Loader", + QuarkusClassLoader.Builder builder = QuarkusClassLoader.builder( + "Augmentation Class Loader: " + quarkusBootstrap.getMode(), quarkusBootstrap.getBaseClassLoader(), !quarkusBootstrap.isIsolateDeployment()); builder.addClassLoaderEventListeners(quarkusBootstrap.getClassLoaderEventListeners()); //we want a class loader that can load the deployment artifacts and all their dependencies, but not @@ -203,7 +204,8 @@ public synchronized QuarkusClassLoader getAugmentClassLoader() { */ public synchronized QuarkusClassLoader getBaseRuntimeClassLoader() { if (baseRuntimeClassLoader == null) { - QuarkusClassLoader.Builder builder = QuarkusClassLoader.builder("Quarkus Base Runtime ClassLoader", + QuarkusClassLoader.Builder builder = QuarkusClassLoader.builder( + "Quarkus Base Runtime ClassLoader: " + quarkusBootstrap.getMode(), quarkusBootstrap.getBaseClassLoader(), false); builder.addClassLoaderEventListeners(quarkusBootstrap.getClassLoaderEventListeners()); @@ -257,8 +259,9 @@ private static boolean isHotReloadable(AppArtifact a, Set hotReloadPaths) public QuarkusClassLoader createDeploymentClassLoader() { //first run, we need to build all the class loaders - QuarkusClassLoader.Builder builder = QuarkusClassLoader.builder("Deployment Class Loader", - getAugmentClassLoader(), false) + QuarkusClassLoader.Builder builder = QuarkusClassLoader + .builder("Deployment Class Loader: " + quarkusBootstrap.getMode(), + getAugmentClassLoader(), false) .addClassLoaderEventListeners(quarkusBootstrap.getClassLoaderEventListeners()) .setAggregateParentResources(true); @@ -283,8 +286,14 @@ public QuarkusClassLoader createDeploymentClassLoader() { } public QuarkusClassLoader createRuntimeClassLoader(Map resources, Map transformedClasses) { - QuarkusClassLoader.Builder builder = QuarkusClassLoader.builder("Quarkus Runtime ClassLoader", - getBaseRuntimeClassLoader(), false) + return createRuntimeClassLoader(getBaseRuntimeClassLoader(), resources, transformedClasses); + } + + public QuarkusClassLoader createRuntimeClassLoader(ClassLoader base, Map resources, + Map transformedClasses) { + QuarkusClassLoader.Builder builder = QuarkusClassLoader + .builder("Quarkus Runtime ClassLoader: " + quarkusBootstrap.getMode(), + getBaseRuntimeClassLoader(), false) .setAggregateParentResources(true); builder.setTransformedClasses(transformedClasses);