Skip to content
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

Introduce AotTestAttributes mechanism in the TestContext framework #29100

Closed
sbrannen opened this issue Sep 7, 2022 · 1 comment
Closed

Introduce AotTestAttributes mechanism in the TestContext framework #29100

sbrannen opened this issue Sep 7, 2022 · 1 comment
Assignees
Labels
in: test Issues in the test module theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Sep 7, 2022

Overview

For certain use cases it would be beneficial to be able to compute something during AOT build-time processing and then retrieve the result of that computation during AOT run-time execution.

Use Case

The SpringBootTestContextBootstrapper performs class path scanning for the @SpringBootConfiguration class using a utility called AnnotatedClassFinder; however, class path scanning does not work within a GraalVM native image.

In the Spring Native project, the AnnotatedClassFinder worked without modification because Spring's component indexer was used to index annotated components during the build; however, in Spring Framework 6.0 and Spring Boot 3.0 we do not want to rely on the component indexer.

Ideally, SpringBootTestContextBootstrapper should be able to:

  • Use the AnnotatedClassFinder during AOT build-time processing.
  • Store the class name of the @SpringBootConfiguration class for later retrieval.
  • Retrieve the @SpringBootConfiguration class name that was discovered at build time during AOT run-time execution.

Proposal

Introduce an AotTestAttributes mechanism in the Spring TestContext Framework.

  • conceptually similar to org.springframework.core.AttributeAccessor
  • must allow an AOT-aware component to contribute a key-value pair, where the key is a String and the value is an String
  • initial support should provide convenience methods for retrieving an attribute as a String or boolean
    • if deemed necessary, generic support can later be added for providing a CodeBlock or statement to create the object in the attributes store
  • must generate the necessary source code during the AOT processing phase in the testing framework to create a persistent map of the attributes
  • must provide a mechanism for accessing the stored attributes during AOT run-time execution
@sbrannen sbrannen added in: test Issues in the test module type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing labels Sep 7, 2022
@sbrannen sbrannen added this to the 6.0.0-M6 milestone Sep 7, 2022
@sbrannen sbrannen self-assigned this Sep 7, 2022
@sbrannen sbrannen changed the title Introduce AotProperties mechanism in the TestContext framework Introduce TestAotProperties mechanism in the TestContext framework Sep 7, 2022
@sbrannen
Copy link
Member Author

sbrannen commented Sep 8, 2022

I've pushed a working prototype for TestAotProperties here:

main...sbrannen:TestAotProperties

@philwebb, let's see if this meets the needs of SpringBootTestContextBootstrapper.

@sbrannen sbrannen changed the title Introduce TestAotProperties mechanism in the TestContext framework Introduce AotTestAttributes mechanism in the TestContext framework Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant