|
|
|
@ -25,9 +25,6 @@ import org.junit.jupiter.api.BeforeEach;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
|
|
|
|
|
|
import org.springframework.aot.generate.ClassNameGenerator;
|
|
|
|
|
import org.springframework.aot.generate.DefaultGenerationContext;
|
|
|
|
|
import org.springframework.aot.generate.InMemoryGeneratedFiles;
|
|
|
|
|
import org.springframework.aot.test.generator.compile.CompileWithTargetClassAccess;
|
|
|
|
|
import org.springframework.aot.test.generator.compile.TestCompiler;
|
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
|
|
|
|
@ -45,6 +42,7 @@ import org.springframework.context.ApplicationContextInitializer;
|
|
|
|
|
import org.springframework.context.aot.ApplicationContextAotGenerator;
|
|
|
|
|
import org.springframework.context.support.GenericApplicationContext;
|
|
|
|
|
import org.springframework.javapoet.ClassName;
|
|
|
|
|
import org.springframework.test.aot.generate.TestGenerationContext;
|
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
@ -76,14 +74,12 @@ class ChildManagementContextInitializerAotTests {
|
|
|
|
|
ServletManagementContextAutoConfiguration.class, WebEndpointAutoConfiguration.class,
|
|
|
|
|
EndpointAutoConfiguration.class));
|
|
|
|
|
contextRunner.withPropertyValues("server.port=0", "management.server.port=0").prepare((context) -> {
|
|
|
|
|
InMemoryGeneratedFiles generatedFiles = new InMemoryGeneratedFiles();
|
|
|
|
|
DefaultGenerationContext generationContext = new DefaultGenerationContext(
|
|
|
|
|
new ClassNameGenerator(TestTarget.class), generatedFiles);
|
|
|
|
|
TestGenerationContext generationContext = new TestGenerationContext(TestTarget.class);
|
|
|
|
|
ClassName className = new ApplicationContextAotGenerator().generateApplicationContext(
|
|
|
|
|
(GenericApplicationContext) context.getSourceApplicationContext(), generationContext);
|
|
|
|
|
generationContext.writeGeneratedContent();
|
|
|
|
|
TestCompiler compiler = TestCompiler.forSystem();
|
|
|
|
|
compiler.withFiles(generatedFiles).compile((compiled) -> {
|
|
|
|
|
compiler.withFiles(generationContext.getGeneratedFiles()).compile((compiled) -> {
|
|
|
|
|
ServletWebServerApplicationContext freshApplicationContext = new ServletWebServerApplicationContext();
|
|
|
|
|
TestPropertyValues.of("server.port=0", "management.server.port=0").applyTo(freshApplicationContext);
|
|
|
|
|
ApplicationContextInitializer<GenericApplicationContext> initializer = compiled
|
|
|
|
|