Interface ApplicationContextAssertProvider<C extends ApplicationContext>
- Type Parameters:
- C- the application context type
- All Superinterfaces:
- ApplicationContext,- ApplicationEventPublisher,- org.assertj.core.api.AssertProvider<ApplicationContextAssert<C>>,- AutoCloseable,- BeanFactory,- Closeable,- EnvironmentCapable,- HierarchicalBeanFactory,- ListableBeanFactory,- MessageSource,- ResourceLoader,- ResourcePatternResolver
- All Known Subinterfaces:
- AssertableApplicationContext,- AssertableReactiveWebApplicationContext,- AssertableWebApplicationContext
public interface ApplicationContextAssertProvider<C extends ApplicationContext>
extends ApplicationContext, org.assertj.core.api.AssertProvider<ApplicationContextAssert<C>>, Closeable
An 
ApplicationContext that additionally supports AssertJ style assertions. Can
 be used to decorate an existing application context or an application context that
 failed to start.
 
 Assertions can be applied using the standard AssertJ assertThat(...) style (see
 ApplicationContextAssert for a complete list). For example: 
assertThat(applicationContext).hasSingleBean(MyBean.class);
 If the original ApplicationContext is needed for any reason the
 getSourceApplicationContext() method can be used.
 
 Any ApplicationContext method called on a context that has failed to start will
 throw an IllegalStateException.
- Since:
- 2.0.0
- Author:
- Phillip Webb
- See Also:
- 
Field SummaryFields inherited from interface org.springframework.beans.factory.BeanFactoryFACTORY_BEAN_PREFIXFields inherited from interface org.springframework.core.io.ResourceLoaderCLASSPATH_URL_PREFIXFields inherited from interface org.springframework.core.io.support.ResourcePatternResolverCLASSPATH_ALL_URL_PREFIX
- 
Method SummaryModifier and TypeMethodDescriptionDeprecated.to prevent accidental use.voidclose()static <T extends ApplicationContextAssertProvider<C>,C extends ApplicationContext> 
 TFactory method to create a newApplicationContextAssertProviderinstance.Return the original sourceApplicationContext.<T extends C>
 TgetSourceApplicationContext(Class<T> requiredType) Return the original sourceApplicationContext, casting it to the requested type.Return the failure that caused application context to fail ornullif the context started without issue.Methods inherited from interface org.springframework.context.ApplicationContextgetApplicationName, getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDateMethods inherited from interface org.springframework.context.ApplicationEventPublisherpublishEvent, publishEventMethods inherited from interface org.springframework.beans.factory.BeanFactorycontainsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getBeanProvider, getBeanProvider, getType, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatchMethods inherited from interface org.springframework.core.env.EnvironmentCapablegetEnvironmentMethods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactorycontainsLocalBean, getParentBeanFactoryMethods inherited from interface org.springframework.beans.factory.ListableBeanFactorycontainsBeanDefinition, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotationMethods inherited from interface org.springframework.context.MessageSourcegetMessage, getMessage, getMessageMethods inherited from interface org.springframework.core.io.ResourceLoadergetClassLoader, getResourceMethods inherited from interface org.springframework.core.io.support.ResourcePatternResolvergetResources
- 
Method Details- 
assertThatDeprecated.to prevent accidental use. Prefer standard AssertJassertThat(context)...calls instead.Return an assert for AspectJ.- Specified by:
- assertThatin interface- org.assertj.core.api.AssertProvider<C extends ApplicationContext>
- Returns:
- an AspectJ assert
 
- 
getSourceApplicationContextC getSourceApplicationContext()Return the original sourceApplicationContext.- Returns:
- the source application context
- Throws:
- IllegalStateException- if the source context failed to start
 
- 
getSourceApplicationContextReturn the original sourceApplicationContext, casting it to the requested type.- Type Parameters:
- T- the context type
- Parameters:
- requiredType- the required context type
- Returns:
- the source application context
- Throws:
- IllegalStateException- if the source context failed to start
 
- 
getStartupFailureThrowable getStartupFailure()Return the failure that caused application context to fail ornullif the context started without issue.- Returns:
- the startup failure or null
 
- 
closevoid close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
- 
getstatic <T extends ApplicationContextAssertProvider<C>,C extends ApplicationContext> T get(Class<T> type, Class<? extends C> contextType, Supplier<? extends C> contextSupplier) Factory method to create a newApplicationContextAssertProviderinstance.- Type Parameters:
- T- the assert provider type
- C- the context type
- Parameters:
- type- the type of- ApplicationContextAssertProviderrequired (must be an interface)
- contextType- the type of- ApplicationContextbeing managed (must be an interface)
- contextSupplier- a supplier that will either return a fully configured- ApplicationContextor throw an exception if the context fails to start.
- Returns:
- a ApplicationContextAssertProviderinstance
 
 
-