|
31 | 31 | import org.springframework.boot.autoconfigure.SpringBootApplication;
|
32 | 32 | import org.springframework.boot.test.context.AnnotatedClassFinder;
|
33 | 33 | import org.springframework.core.annotation.AnnotatedElementUtils;
|
| 34 | +import org.springframework.core.io.support.SpringFactoriesLoader; |
34 | 35 | import org.springframework.modulith.core.ApplicationModule;
|
35 | 36 | import org.springframework.modulith.core.ApplicationModules;
|
| 37 | +import org.springframework.modulith.core.ApplicationModulesFactory; |
36 | 38 | import org.springframework.modulith.core.JavaPackage;
|
37 | 39 | import org.springframework.modulith.test.ApplicationModuleTest.BootstrapMode;
|
38 | 40 | import org.springframework.util.ObjectUtils;
|
|
46 | 48 | public class ModuleTestExecution implements Iterable<ApplicationModule> {
|
47 | 49 |
|
48 | 50 | private static final Logger LOGGER = LoggerFactory.getLogger(ModuleTestExecution.class);
|
| 51 | + private static final ApplicationModulesFactory BOOTSTRAP; |
49 | 52 |
|
50 | 53 | private static Map<Class<?>, Class<?>> MODULITH_TYPES = new HashMap<>();
|
51 | 54 | private static Map<Key, ModuleTestExecution> EXECUTIONS = new HashMap<>();
|
52 | 55 |
|
| 56 | + static { |
| 57 | + |
| 58 | + var factories = SpringFactoriesLoader.loadFactories(ApplicationModulesFactory.class, |
| 59 | + ModuleTestExecution.class.getClassLoader()); |
| 60 | + |
| 61 | + BOOTSTRAP = !factories.isEmpty() ? factories.get(0) : ApplicationModulesFactory.defaultFactory(); |
| 62 | + } |
| 63 | + |
53 | 64 | private final Key key;
|
54 | 65 |
|
55 | 66 | private final BootstrapMode bootstrapMode;
|
@@ -98,7 +109,7 @@ public static Supplier<ModuleTestExecution> of(Class<?> type) {
|
98 | 109 |
|
99 | 110 | var annotation = AnnotatedElementUtils.findMergedAnnotation(type, ApplicationModuleTest.class);
|
100 | 111 | var packageName = type.getPackage().getName();
|
101 |
| - var modules = ApplicationModules.of(findSpringBootApplicationByClasses(annotation, type)); |
| 112 | + var modules = BOOTSTRAP.of(findSpringBootApplicationByClasses(annotation, type)); |
102 | 113 | var moduleName = annotation.module();
|
103 | 114 |
|
104 | 115 | var module = StringUtils.hasText(moduleName)
|
|
0 commit comments