-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support in the TCF to use pre-processed AOT contexts #28205
Comments
Brainstorming with @jhoeller we believe that For the TCF, it could use the AotDetector, check a generated class based on the current test class name and then do whatever. An example of such arrangement could be the following: /**
* Bootstrap for {@link MyTest}. Generated code, do not edit
*/
public class MyTest__TestContextInitializer {
public static SmartContextLoader loadContext() {
return new AotContextLoader(...);
}
} The class could also implement an interface or whatever. If multiple test classes share the same context, then the generated code for those test classes would delegate to a common generated class. Such arrangement makes sure that the check is consistent (and 100% transparent when running tests in a native image). |
TestContextAotGenerator now uses AotTestMappingsCodeGenerator to generate a AotTestMappings__Generated.java class which is loaded in AotTestMappings via reflection in order to retrieve access to ApplicationContextIntializers generated during AOT processing. Furthermore, the processAheadOfTimeAndGenerateAotTestMappings() method in TestContextAotGeneratorTests now performs a rather extensive test including: - emulating TestClassScanner to find test classes - processing all test classes and generating ApplicationContextIntializers - generating mappings for AotTestMappings - compiling all generated code - loading AotTestMappings - using AotTestMappings to instantiate the generated ApplicationContextIntializers - using AotRuntimeContextLoader to load the AOT-optimized ApplicationContext - asserting the behavior of the loaded ApplicationContext See spring-projectsgh-28205 Closes spring-projectsgh-28204
This commit introduces initial AOT run-time support in the Spring TestContext Framework. - DefaultCacheAwareContextLoaderDelegate: when running in AOT mode, now loads a test's ApplicationContext using the AotRuntimeContextLoader instead of via the standard SmartContextLoader and ContextLoader SPIs. - DependencyInjectionTestExecutionListener: when running in AOT mode, now injects dependencies into a test instance using a local instance of AutowiredAnnotationBeanPostProcessor instead of relying on AutowireCapableBeanFactory support. Closes spring-projectsgh-28205
TestContextAotGenerator now uses AotTestMappingsCodeGenerator to generate a AotTestMappings__Generated.java class which is loaded in AotTestMappings via reflection in order to retrieve access to ApplicationContextIntializers generated during AOT processing. Furthermore, the processAheadOfTimeAndGenerateAotTestMappings() method in TestContextAotGeneratorTests now performs a rather extensive test including: - emulating TestClassScanner to find test classes - processing all test classes and generating ApplicationContextIntializers - generating mappings for AotTestMappings - compiling all generated code - loading AotTestMappings - using AotTestMappings to instantiate the generated ApplicationContextIntializer - using the AotContextLoader API to load the AOT-optimized ApplicationContext - asserting the behavior of the loaded ApplicationContext See spring-projectsgh-28205 Closes spring-projectsgh-28204
This commit introduces initial AOT run-time support in the Spring TestContext Framework. - DefaultCacheAwareContextLoaderDelegate: when running in AOT mode, now loads a test's ApplicationContext via the AotContextLoader SPI instead of via the standard SmartContextLoader and ContextLoader SPIs. - DependencyInjectionTestExecutionListener: when running in AOT mode, now injects dependencies into a test instance using a local instance of AutowiredAnnotationBeanPostProcessor instead of relying on AutowireCapableBeanFactory support. Closes spring-projectsgh-28205
TestContextAotGenerator now uses AotTestMappingsCodeGenerator to generate a AotTestMappings__Generated.java class which is loaded in AotTestMappings via reflection in order to retrieve access to ApplicationContextIntializers generated during AOT processing. Furthermore, the processAheadOfTimeAndGenerateAotTestMappings() method in TestContextAotGeneratorTests now performs a rather extensive test including: - emulating TestClassScanner to find test classes - processing all test classes and generating ApplicationContextIntializers - generating mappings for AotTestMappings - compiling all generated code - loading AotTestMappings - using AotTestMappings to instantiate the generated ApplicationContextIntializer - using the AotContextLoader API to load the AOT-optimized ApplicationContext - asserting the behavior of the loaded ApplicationContext See spring-projectsgh-28205 Closes spring-projectsgh-28204
Overview
Once we've done #28204, we need to be able to configure the TCF so that it uses our optimized context rather than doing all the parsing again. Given that our input is the test class, it would be interesting to see if we can shortcut most of the processing and go straight to starting (or reusing) the context.
Related Issues
The text was updated successfully, but these errors were encountered: