@@ -57,8 +57,6 @@ public class CoreQuarkusTestExtension {
57
57
protected static final String TEST_LOCATION = "test-location" ;
58
58
protected static final String TEST_CLASS = "test-class" ;
59
59
60
- protected static Class currentJUnitTestClass ;
61
-
62
60
/// end copied
63
61
64
62
private static final Logger log = Logger .getLogger (CoreQuarkusTestExtension .class );
@@ -94,10 +92,17 @@ public PrepareResult(AugmentAction augmentAction, QuarkusTestProfile profileInst
94
92
}
95
93
}
96
94
97
- // Re-used from AbstractJvmQuarkusTestExtension
98
95
protected PrepareResult createAugmentor (Class requiredTestClass , Class <? extends QuarkusTestProfile > profile ,
99
96
Collection <Runnable > shutdownTasks ) throws Exception {
100
97
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
+
101
106
// I think the required test class is just an example, since the augmentor is only
102
107
// created once per test profile
103
108
final PathList .Builder rootBuilder = PathList .builder ();
@@ -108,9 +113,6 @@ protected PrepareResult createAugmentor(Class requiredTestClass, Class<? extends
108
113
}
109
114
};
110
115
111
- currentJUnitTestClass = requiredTestClass ;
112
-
113
- final Path testClassLocation ;
114
116
final Path appClassLocation ;
115
117
final Path projectRoot = Paths .get ("" )
116
118
.normalize ()
@@ -175,7 +177,7 @@ protected PrepareResult createAugmentor(Class requiredTestClass, Class<? extends
175
177
}
176
178
}
177
179
178
- testClassLocation = getTestClassesLocation (requiredTestClass );
180
+ // testClassLocation = getTestClassesLocation(requiredTestClass);
179
181
System .out .println ("test class location is " + testClassLocation );
180
182
appClassLocation = getAppClassLocationForTestLocation (testClassLocation .toString ());
181
183
System .out .println ("app class location is " + appClassLocation );
@@ -279,7 +281,7 @@ protected PrepareResult createAugmentor(Class requiredTestClass, Class<? extends
279
281
.isAuxiliaryApplication ());
280
282
final Map <String , Object > props = new HashMap <>();
281
283
props .put (TEST_LOCATION , testClassLocation );
282
- props .put (TEST_CLASS , requiredTestClass );
284
+ // TODO surely someone reads this? props.put(TEST_CLASS, requiredTestClass);
283
285
// TODO what's going on here with the profile?
284
286
Class <? extends QuarkusTestProfile > quarkusTestProfile = profile ;
285
287
PrepareResult result = new PrepareResult (curatedApplication
@@ -301,7 +303,8 @@ public ClassLoader doJavaStart(Class testClass, CuratedApplication curatedApplic
301
303
QuarkusTestProfile profileInstance = result .profileInstance ;
302
304
303
305
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 ());
305
308
306
309
System .out .println ("HOLLY about to make app for " + testClass );
307
310
StartupAction startupAction = augmentAction .createInitialRuntimeApplication ();
@@ -312,15 +315,43 @@ public ClassLoader doJavaStart(Class testClass, CuratedApplication curatedApplic
312
315
313
316
}
314
317
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
+
315
339
// TODO can we defer this and move it back to the junit5 module?
316
340
public static class TestBuildChainFunction implements Function <Map <String , Object >, List <Consumer <BuildChainBuilder >>> {
317
341
318
342
@ Override
319
343
public List <Consumer <BuildChainBuilder >> apply (Map <String , Object > stringObjectMap ) {
320
344
Path testLocation = (Path ) stringObjectMap .get (TEST_LOCATION );
321
345
// 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
+ }
324
355
List <Consumer <BuildChainBuilder >> allCustomizers = new ArrayList <>(1 );
325
356
Consumer <BuildChainBuilder > defaultCustomizer = new Consumer <BuildChainBuilder >() {
326
357
0 commit comments