Skip to content

Commit 2c4ddb4

Browse files
committed
Use runtime classloader even in normal mode
1 parent 776a20c commit 2c4ddb4

File tree

14 files changed

+239
-23
lines changed

14 files changed

+239
-23
lines changed

bom/application/pom.xml

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

core/deployment/src/main/java/io/quarkus/deployment/dev/testing/CoreQuarkusTestExtension.java

+42-11
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ public class CoreQuarkusTestExtension {
5757
protected static final String TEST_LOCATION = "test-location";
5858
protected static final String TEST_CLASS = "test-class";
5959

60-
protected static Class currentJUnitTestClass;
61-
6260
/// end copied
6361

6462
private static final Logger log = Logger.getLogger(CoreQuarkusTestExtension.class);
@@ -94,10 +92,17 @@ public PrepareResult(AugmentAction augmentAction, QuarkusTestProfile profileInst
9492
}
9593
}
9694

97-
// Re-used from AbstractJvmQuarkusTestExtension
9895
protected PrepareResult createAugmentor(Class requiredTestClass, Class<? extends QuarkusTestProfile> profile,
9996
Collection<Runnable> shutdownTasks) throws Exception {
10097

98+
Path testClassLocation = getTestClassesLocation(requiredTestClass);
99+
return createAugmentor(testClassLocation, profile, shutdownTasks);
100+
}
101+
102+
// Re-used from AbstractJvmQuarkusTestExtension
103+
protected PrepareResult createAugmentor(Path testClassLocation, Class<? extends QuarkusTestProfile> profile,
104+
Collection<Runnable> shutdownTasks) throws Exception {
105+
101106
// I think the required test class is just an example, since the augmentor is only
102107
// created once per test profile
103108
final PathList.Builder rootBuilder = PathList.builder();
@@ -108,9 +113,6 @@ protected PrepareResult createAugmentor(Class requiredTestClass, Class<? extends
108113
}
109114
};
110115

111-
currentJUnitTestClass = requiredTestClass;
112-
113-
final Path testClassLocation;
114116
final Path appClassLocation;
115117
final Path projectRoot = Paths.get("")
116118
.normalize()
@@ -175,7 +177,7 @@ protected PrepareResult createAugmentor(Class requiredTestClass, Class<? extends
175177
}
176178
}
177179

178-
testClassLocation = getTestClassesLocation(requiredTestClass);
180+
// testClassLocation = getTestClassesLocation(requiredTestClass);
179181
System.out.println("test class location is " + testClassLocation);
180182
appClassLocation = getAppClassLocationForTestLocation(testClassLocation.toString());
181183
System.out.println("app class location is " + appClassLocation);
@@ -279,7 +281,7 @@ protected PrepareResult createAugmentor(Class requiredTestClass, Class<? extends
279281
.isAuxiliaryApplication());
280282
final Map<String, Object> props = new HashMap<>();
281283
props.put(TEST_LOCATION, testClassLocation);
282-
props.put(TEST_CLASS, requiredTestClass);
284+
// TODO surely someone reads this? props.put(TEST_CLASS, requiredTestClass);
283285
// TODO what's going on here with the profile?
284286
Class<? extends QuarkusTestProfile> quarkusTestProfile = profile;
285287
PrepareResult result = new PrepareResult(curatedApplication
@@ -301,7 +303,8 @@ public ClassLoader doJavaStart(Class testClass, CuratedApplication curatedApplic
301303
QuarkusTestProfile profileInstance = result.profileInstance;
302304

303305
testHttpEndpointProviders = TestHttpEndpointProvider.load();
304-
System.out.println("CORE MAKER SEES CLASS OF STARTUP " + StartupAction.class.getClassLoader());
306+
System.out.println(
307+
"CORE MAKER SEES CLASS OF STARTUP " + StartupAction.class.getClassLoader());
305308

306309
System.out.println("HOLLY about to make app for " + testClass);
307310
StartupAction startupAction = augmentAction.createInitialRuntimeApplication();
@@ -312,15 +315,43 @@ public ClassLoader doJavaStart(Class testClass, CuratedApplication curatedApplic
312315

313316
}
314317

318+
public ClassLoader doJavaStart(Path location, CuratedApplication curatedApplication) throws Exception {
319+
Class<? extends QuarkusTestProfile> profile = null;
320+
// TODO do we want any of these?
321+
Collection shutdownTasks = new HashSet();
322+
PrepareResult result = createAugmentor(location, profile, shutdownTasks);
323+
AugmentAction augmentAction = result.augmentAction;
324+
QuarkusTestProfile profileInstance = result.profileInstance;
325+
326+
testHttpEndpointProviders = TestHttpEndpointProvider.load();
327+
System.out.println(
328+
"CORE MAKER SEES CLASS OF STARTUP " + StartupAction.class.getClassLoader());
329+
330+
System.out.println("HOLLY about to make app for " + location);
331+
StartupAction startupAction = augmentAction.createInitialRuntimeApplication();
332+
// TODO this seems to be safe to do because the classloaders are the same
333+
startupAction.store();
334+
System.out.println("HOLLY did store " + startupAction);
335+
return startupAction.getClassLoader();
336+
337+
}
338+
315339
// TODO can we defer this and move it back to the junit5 module?
316340
public static class TestBuildChainFunction implements Function<Map<String, Object>, List<Consumer<BuildChainBuilder>>> {
317341

318342
@Override
319343
public List<Consumer<BuildChainBuilder>> apply(Map<String, Object> stringObjectMap) {
320344
Path testLocation = (Path) stringObjectMap.get(TEST_LOCATION);
321345
// the index was written by the extension
322-
Index testClassesIndex = TestClassIndexer.readIndex(testLocation, (Class<?>) stringObjectMap.get(TEST_CLASS));
323-
346+
Class<?> testClass = (Class<?>) stringObjectMap.get(TEST_CLASS);
347+
// TODO is this at all safe?
348+
349+
Index testClassesIndex;
350+
if (testClass != null) {
351+
testClassesIndex = TestClassIndexer.readIndex(testLocation, testClass);
352+
} else {
353+
testClassesIndex = TestClassIndexer.readIndex(testLocation);
354+
}
324355
List<Consumer<BuildChainBuilder>> allCustomizers = new ArrayList<>(1);
325356
Consumer<BuildChainBuilder> defaultCustomizer = new Consumer<BuildChainBuilder>() {
326357

core/deployment/src/main/java/io/quarkus/deployment/dev/testing/ModuleTestRunner.java

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class ModuleTestRunner {
2525

2626
public ModuleTestRunner(TestSupport testSupport, CuratedApplication testApplication,
2727
DevModeContext.ModuleInfo moduleInfo) {
28+
System.out.println("HOLLY making module test runner");
2829
this.testSupport = testSupport;
2930
this.testApplication = testApplication;
3031
this.moduleInfo = moduleInfo;

core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestClassIndexer.java

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public static Index readIndex(Class<?> testClass) {
6868
return readIndex(getTestClassesLocation(testClass), testClass);
6969
}
7070

71+
public static Index readIndex(Path testLocation) {
72+
return indexTestClasses(testLocation);
73+
}
74+
7175
public static Index readIndex(Path testClassLocation, Class<?> testClass) {
7276
Path path = indexPath(testClassLocation, testClass);
7377
if (path.toFile().exists()) {

core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class TestSupport implements TestController {
8686

8787
public TestSupport(CuratedApplication curatedApplication, List<CompilationProvider> compilationProviders,
8888
DevModeContext context, DevModeType devModeType) {
89+
System.out.println("HOLLY making test support");
8990
this.curatedApplication = curatedApplication;
9091
this.compilationProviders = compilationProviders;
9192
this.context = context;

independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.nio.file.Path;
88
import java.util.ArrayDeque;
99
import java.util.ArrayList;
10-
import java.util.Arrays;
1110
import java.util.Collection;
1211
import java.util.Deque;
1312
import java.util.HashMap;
@@ -323,9 +322,9 @@ private boolean isRuntimeArtifact(ArtifactKey key) {
323322
}
324323

325324
private void visitRuntimeDependencies(List<DependencyNode> list) {
326-
System.out.println(list.size() + "HOLLY will visit " + Arrays.toString(list.toArray()));
325+
// System.out.println(list.size() + "HOLLY will visit " + Arrays.toString(list.toArray()));
327326
for (DependencyNode n : list) {
328-
System.out.println("HOLLY visiting " + n);
327+
// System.out.println("HOLLY visiting " + n);
329328
visitRuntimeDependency(n);
330329
}
331330
}
@@ -348,9 +347,9 @@ private void visitRuntimeDependency(DependencyNode node) {
348347
}
349348

350349
try {
351-
System.out.println("about to get " + node + ".>" + artifact);
350+
// System.out.println("about to get " + node + ".>" + artifact);
352351
final ExtensionDependency extDep = getExtensionDependencyOrNull(node, artifact);
353-
System.out.println("got " + extDep);
352+
// System.out.println("got " + extDep);
354353

355354
if (dep == null) {
356355
WorkspaceModule module = null;

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</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</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

0 commit comments

Comments
 (0)