类 InfraTestContextBootstrapper
- 所有已实现的接口:
TestContextBootstrapper
TestContextBootstrapper for Infra. Provides support for
@InfraTest and may also be used directly or subclassed.
Provides the following features over and above DefaultTestContextBootstrapper:
- Uses
InfraApplicationContextLoaderas thedefault context loader. - Automatically searches for a
@InfraConfigurationwhen required. - Allows custom
EnvironmentgetProperties(Class)to be defined. - Provides support for different
webEnvironmentmodes.
- 从以下版本开始:
- 4.0
- 作者:
- Phillip Webb, Andy Wilkinson, Brian Clozel, Madhura Bhave, Lorenzo Dee
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private voidaddConfigAttributesClasses(ContextConfigurationAttributes configAttributes, Class<?>[] classes) Build a newDefaultTestContextusing the test class in theBootstrapContextassociated with this bootstrapper and by delegating toAbstractTestContextBootstrapper.buildMergedContextConfiguration()andAbstractTestContextBootstrapper.getCacheAwareContextLoaderDelegate().private booleancontainsNonTestComponent(Class<?>[] classes) protected final MergedContextConfigurationcreateModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfigurationwith different classes.protected final MergedContextConfigurationcreateModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) Create a newMergedContextConfigurationwith different classes and properties.protected StringdetermineResourceBasePath(MergedContextConfiguration configuration) Determines the resource base path for web applications using the value of@WebAppConfiguration, if any, on the test class of the givenconfiguration.protected InfraTestgetAnnotation(Class<?> testClass) private cn.taketoday.framework.ApplicationTypegetApplicationType(MergedContextConfiguration configuration) protected Class<?>[]getClasses(Class<?> testClass) protected Class<? extends ContextLoader>getDefaultContextLoaderClass(Class<?> testClass) ReturnsDelegatingSmartContextLoader.protected List<TestExecutionListener>Get the defaultTestExecutionListenersfor this bootstrapper.protected StringReturn a "differentiator" property to ensure that there is something to differentiate regular tests and bootstrapped tests.protected Class<?>[]getOrFindConfigurationClasses(MergedContextConfiguration mergedConfig) protected String[]getProperties(Class<?> testClass) protected InfraTest.WebEnvironmentgetWebEnvironment(Class<?> testClass) Return theInfraTest.WebEnvironmenttype for this test or null if undefined.private booleanisFromConfiguration(MergedContextConfiguration candidateConfig, ContextConfiguration configuration) private booleanisListeningOnPort(InfraTest.WebEnvironment webEnvironment) private booleanisWebEnvironmentSupported(MergedContextConfiguration mergedConfig) private Class<?>[]protected MergedContextConfigurationprocessMergedContextConfiguration(MergedContextConfiguration mergedConfig) Process the supplied, newly instantiatedMergedContextConfigurationinstance.protected voidprocessPropertySourceProperties(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties) Post process the property source properties, adding or removing elements as required.protected ContextLoaderresolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) Resolve theContextLoaderclass to use for the supplied list ofContextConfigurationAttributesand then instantiate and return thatContextLoader.protected voidverifyConfiguration(Class<?> testClass)
-
字段详细资料
-
ACTIVATE_SERVLET_LISTENER
- 另请参阅:
-
logger
private static final cn.taketoday.logging.Logger logger
-
-
构造器详细资料
-
InfraTestContextBootstrapper
public InfraTestContextBootstrapper()
-
-
方法详细资料
-
buildTestContext
从类复制的说明:AbstractTestContextBootstrapperBuild a newDefaultTestContextusing the test class in theBootstrapContextassociated with this bootstrapper and by delegating toAbstractTestContextBootstrapper.buildMergedContextConfiguration()andAbstractTestContextBootstrapper.getCacheAwareContextLoaderDelegate().Concrete subclasses may choose to override this method to return a custom
TestContextimplementation.- 指定者:
buildTestContext在接口中TestContextBootstrapper- 覆盖:
buildTestContext在类中AbstractTestContextBootstrapper- 返回:
- a new
TestContext, nevernull - 另请参阅:
-
getDefaultTestExecutionListeners
从类复制的说明:AbstractTestContextBootstrapperGet the defaultTestExecutionListenersfor this bootstrapper.The default implementation delegates to
TestContextFactoriesUtils.loadFactoryImplementations(Class).This method is invoked by
AbstractTestContextBootstrapper.getTestExecutionListeners().- 覆盖:
getDefaultTestExecutionListeners在类中AbstractTestContextBootstrapper- 返回:
- an unmodifiable list of default
TestExecutionListenerinstances
-
resolveContextLoader
protected ContextLoader resolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) 从类复制的说明:AbstractTestContextBootstrapperResolve theContextLoaderclass to use for the supplied list ofContextConfigurationAttributesand then instantiate and return thatContextLoader.If the user has not explicitly declared which loader to use, the value returned from
AbstractTestContextBootstrapper.getDefaultContextLoaderClass(java.lang.Class<?>)will be used as the default context loader class. For details on the class resolution process, seeAbstractTestContextBootstrapper.resolveExplicitContextLoaderClass(java.util.List<cn.taketoday.test.context.ContextConfigurationAttributes>)andAbstractTestContextBootstrapper.getDefaultContextLoaderClass(java.lang.Class<?>).- 覆盖:
resolveContextLoader在类中AbstractTestContextBootstrapper- 参数:
testClass- the test class for which theContextLoadershould be resolved; must not benullconfigAttributesList- the list of configuration attributes to process; must not benull; must be ordered bottom-up (i.e., as if we were traversing up the class hierarchy and enclosing class hierarchy)- 返回:
- the resolved
ContextLoaderfor the suppliedtestClass(nevernull)
-
addConfigAttributesClasses
private void addConfigAttributesClasses(ContextConfigurationAttributes configAttributes, Class<?>[] classes) -
getDefaultContextLoaderClass
从类复制的说明:DefaultTestContextBootstrapperReturnsDelegatingSmartContextLoader.- 覆盖:
getDefaultContextLoaderClass在类中DefaultTestContextBootstrapper- 参数:
testClass- the test class for which to retrieve the defaultContextLoaderclass- 返回:
- the default
ContextLoaderclass for the supplied test class (nevernull)
-
processMergedContextConfiguration
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) 从类复制的说明:AbstractTestContextBootstrapperProcess the supplied, newly instantiatedMergedContextConfigurationinstance.The returned
MergedContextConfigurationinstance may be a wrapper around or a replacement for the original.The default implementation simply returns the supplied instance unmodified.
Concrete subclasses may choose to return a specialized subclass of
MergedContextConfigurationbased on properties in the supplied instance.- 覆盖:
processMergedContextConfiguration在类中AbstractTestContextBootstrapper- 参数:
mergedConfig- theMergedContextConfigurationto process; nevernull- 返回:
- a fully initialized
MergedContextConfiguration; nevernull
-
getApplicationType
private cn.taketoday.framework.ApplicationType getApplicationType(MergedContextConfiguration configuration) -
determineResourceBasePath
Determines the resource base path for web applications using the value of@WebAppConfiguration, if any, on the test class of the givenconfiguration. Defaults tosrc/main/webappin its absence.- 参数:
configuration- the configuration to examine- 返回:
- the resource base path
-
isWebEnvironmentSupported
-
isFromConfiguration
private boolean isFromConfiguration(MergedContextConfiguration candidateConfig, ContextConfiguration configuration) -
getOrFindConfigurationClasses
-
containsNonTestComponent
-
merge
-
getAndProcessPropertySourceProperties
-
getDifferentiatorPropertySourceProperty
Return a "differentiator" property to ensure that there is something to differentiate regular tests and bootstrapped tests. Without this property a cached context could be returned that wasn't created by this bootstrapper. By default uses the bootstrapper class as a property.- 返回:
- the differentiator or
null
-
processPropertySourceProperties
protected void processPropertySourceProperties(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties) Post process the property source properties, adding or removing elements as required.- 参数:
mergedConfig- the merged context configurationpropertySourceProperties- the property source properties to process
-
getWebEnvironment
Return theInfraTest.WebEnvironmenttype for this test or null if undefined.- 参数:
testClass- the source test class- 返回:
- the
InfraTest.WebEnvironmentornull
-
getClasses
-
getProperties
-
getAnnotation
-
verifyConfiguration
-
isListeningOnPort
-
createModifiedConfig
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfigurationwith different classes.- 参数:
mergedConfig- the source configclasses- the replacement classes- 返回:
- a new
MergedContextConfiguration
-
createModifiedConfig
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) Create a newMergedContextConfigurationwith different classes and properties.- 参数:
mergedConfig- the source configclasses- the replacement classespropertySourceProperties- the replacement properties- 返回:
- a new
MergedContextConfiguration
-