类 TestContextAotGenerator

java.lang.Object
cn.taketoday.test.context.aot.TestContextAotGenerator

public class TestContextAotGenerator extends Object
TestContextAotGenerator generates AOT artifacts for integration tests that depend on support from the Infra TestContext Framework.
从以下版本开始:
4.0
作者:
Sam Brannen, Harry Yang
另请参阅:
  • ApplicationContextAotGenerator
  • 字段详细资料

    • FAIL_ON_ERROR_PROPERTY_NAME

      public static final String FAIL_ON_ERROR_PROPERTY_NAME
      JVM system property used to set the failOnError flag: "infra.test.aot.processing.failOnError".

      The failOnError flag controls whether errors encountered during AOT processing in the Infra TestContext Framework should result in an exception that fails the overall process.

      Defaults to true.

      Supported values include true or false, ignoring case. For example, the default may be changed to false by supplying the following JVM system property via the command line.

      -Dinfra.test.aot.processing.failOnError=false

      May alternatively be configured via the TodayStrategies mechanism.

      另请参阅:
    • logger

      private static final cn.taketoday.logging.Logger logger
    • isDisabledInAotMode

      private static final Predicate<? super Class<?>> isDisabledInAotMode
    • aotGenerator

      private final cn.taketoday.context.aot.ApplicationContextAotGenerator aotGenerator
    • testRuntimeHintsRegistrars

      private final cn.taketoday.beans.factory.aot.AotServices<TestRuntimeHintsRegistrar> testRuntimeHintsRegistrars
    • mergedConfigRuntimeHints

      private final MergedContextConfigurationRuntimeHints mergedConfigRuntimeHints
    • sequence

      private final AtomicInteger sequence
    • generatedFiles

      private final cn.taketoday.aot.generate.GeneratedFiles generatedFiles
    • runtimeHints

      private final cn.taketoday.aot.hint.RuntimeHints runtimeHints
    • failOnError

      final boolean failOnError
  • 构造器详细资料

    • TestContextAotGenerator

      public TestContextAotGenerator(cn.taketoday.aot.generate.GeneratedFiles generatedFiles)
      Create a new TestContextAotGenerator that uses the supplied GeneratedFiles.
      参数:
      generatedFiles - the GeneratedFiles to use
      另请参阅:
    • TestContextAotGenerator

      public TestContextAotGenerator(cn.taketoday.aot.generate.GeneratedFiles generatedFiles, cn.taketoday.aot.hint.RuntimeHints runtimeHints)
      Create a new TestContextAotGenerator that uses the supplied GeneratedFiles and RuntimeHints.

      This constructor looks up the value of the failOnError flag via the "infra.test.aot.processing.failOnError" property, defaulting to true if the property is not set.

      参数:
      generatedFiles - the GeneratedFiles to use
      runtimeHints - the RuntimeHints to use
      另请参阅:
    • TestContextAotGenerator

      public TestContextAotGenerator(cn.taketoday.aot.generate.GeneratedFiles generatedFiles, cn.taketoday.aot.hint.RuntimeHints runtimeHints, boolean failOnError)
      Create a new TestContextAotGenerator that uses the supplied GeneratedFiles, RuntimeHints, and failOnError flag.
      参数:
      generatedFiles - the GeneratedFiles to use
      runtimeHints - the RuntimeHints to use
      failOnError - true if errors encountered during AOT processing should result in an exception that fails the overall process
  • 方法详细资料

    • getRuntimeHints

      public final cn.taketoday.aot.hint.RuntimeHints getRuntimeHints()
      Get the RuntimeHints gathered during AOT processing.
    • processAheadOfTime

      public void processAheadOfTime(Stream<Class<?>> testClasses) throws TestContextAotException
      Process each of the supplied Infra integration test classes and generate AOT artifacts.
      抛出:
      TestContextAotException - if an error occurs during AOT processing
    • collectRuntimeHintsRegistrarClasses

      private void collectRuntimeHintsRegistrarClasses(Class<?> testClass, Set<Class<? extends cn.taketoday.aot.hint.RuntimeHintsRegistrar>> coreRuntimeHintsRegistrarClasses)
      Collect all RuntimeHintsRegistrar classes declared via @ImportRuntimeHints on the supplied test class and add them to the supplied Set.
      参数:
      testClass - the test class on which to search for @ImportRuntimeHints
      coreRuntimeHintsRegistrarClasses - the set of registrar classes
    • resetAotFactories

      private void resetAotFactories()
    • processAheadOfTime

      private cn.taketoday.util.MultiValueMap<cn.taketoday.javapoet.ClassName,Class<?>> processAheadOfTime(cn.taketoday.util.MultiValueMap<MergedContextConfiguration,Class<?>> mergedConfigMappings)
    • processAheadOfTime

      cn.taketoday.javapoet.ClassName processAheadOfTime(MergedContextConfiguration mergedConfig, cn.taketoday.aot.generate.GenerationContext generationContext) throws TestContextAotException
      Process the specified MergedContextConfiguration ahead-of-time using the specified GenerationContext.

      Return the ClassName of the ApplicationContextInitializer to use to restore an optimized state of the test application context for the given MergedContextConfiguration.

      参数:
      mergedConfig - the MergedContextConfiguration to process
      generationContext - the generation context to use
      返回:
      the ClassName for the generated ApplicationContextInitializer
      抛出:
      TestContextAotException - if an error occurs during AOT processing
    • loadContextForAotProcessing

      private cn.taketoday.context.support.GenericApplicationContext loadContextForAotProcessing(MergedContextConfiguration mergedConfig) throws TestContextAotException
      Load the GenericApplicationContext for the supplied merged context configuration for AOT processing.

      Only supports SmartContextLoaders that create GenericApplicationContexts.

      抛出:
      TestContextAotException - if an error occurs while loading the application context or if one of the prerequisites is not met
      另请参阅:
    • buildMergedContextConfiguration

      private MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass)
    • createGenerationContext

      cn.taketoday.aot.generate.DefaultGenerationContext createGenerationContext(Class<?> testClass)
    • nextTestContextId

      private String nextTestContextId()
    • generateAotTestContextInitializerMappings

      private void generateAotTestContextInitializerMappings(cn.taketoday.util.MultiValueMap<cn.taketoday.javapoet.ClassName,Class<?>> initializerClassMappings)
    • generateAotTestAttributeMappings

      private void generateAotTestAttributeMappings()
    • registerPublicMethods

      private void registerPublicMethods(String className)
    • registerDeclaredConstructors

      private void registerDeclaredConstructors(Class<?> type)
    • registerSkippedExceptionTypes

      private void registerSkippedExceptionTypes()
      Register hints for skipped exception types loaded via reflection in TestContextManager.
    • getFailOnErrorFlag

      private static boolean getFailOnErrorFlag()
    • classNames

      private static List<String> classNames(List<Class<?>> classes)