Improve TestCompiler and allow lookup based class defines
Update the `TestCompiler` so that classes can be defined using a `Lookup`. This update allows package-private classes to be accessed without needing a quite so unusual classloader setup. The `@CompileWithTargetClassAccess` should be added to any test that needs to use `Lookup` based defines. The test will run with a completed forked classloader so not to pollute the main classloader. This commit also adds some useful additional APIs. See gh-28120
This commit is contained in:
@@ -32,6 +32,7 @@ import org.springframework.aot.generator.DefaultGeneratedTypeContext;
|
||||
import org.springframework.aot.generator.GeneratedType;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
import org.springframework.aot.test.generator.compile.CompileWithTargetClassAccess;
|
||||
import org.springframework.aot.test.generator.compile.TestCompiler;
|
||||
import org.springframework.aot.test.generator.file.SourceFile;
|
||||
import org.springframework.aot.test.generator.file.SourceFiles;
|
||||
@@ -126,6 +127,7 @@ class PersistenceAnnotationBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@CompileWithTargetClassAccess(classes = DefaultPersistenceUnitField.class)
|
||||
void generateEntityManagerFactoryInjection() {
|
||||
GenericApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.registerBeanDefinition("test", new RootBeanDefinition(DefaultPersistenceUnitField.class));
|
||||
|
||||
Reference in New Issue
Block a user