C - the application context typepublic interface ApplicationContextAssertProvider<C extends ApplicationContext> extends ApplicationContext, org.assertj.core.api.AssertProvider<ApplicationContextAssert<C>>, Closeable
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.
AssertableApplicationContext,
AssertableWebApplicationContext,
AssertableReactiveWebApplicationContext,
ApplicationContextAssertFACTORY_BEAN_PREFIXCLASSPATH_ALL_URL_PREFIXCLASSPATH_URL_PREFIX| Modifier and Type | Method and Description |
|---|---|
ApplicationContextAssert<C> |
assertThat()
Deprecated.
to prevent accidental use. Prefer standard AssertJ
assertThat(context)... calls instead. |
void |
close() |
static <T extends ApplicationContextAssertProvider<C>,C extends ApplicationContext> |
get(Class<T> type,
Class<? extends C> contextType,
Supplier<? extends C> contextSupplier)
Factory method to create a new
ApplicationContextAssertProvider instance. |
C |
getSourceApplicationContext()
Return the original source
ApplicationContext. |
<T extends C> |
getSourceApplicationContext(Class<T> requiredType)
Return the original source
ApplicationContext, casting it to the requested
type. |
Throwable |
getStartupFailure()
Return the failure that caused application context to fail or
null if the
context started without issue. |
getApplicationName, getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDategetEnvironmentcontainsBeanDefinition, findAnnotationOnBean, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotationcontainsLocalBean, getParentBeanFactorycontainsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getBeanProvider, getBeanProvider, getType, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatchgetMessage, getMessage, getMessagepublishEvent, publishEventgetResourcesgetClassLoader, getResource@Deprecated ApplicationContextAssert<C> assertThat()
assertThat(context)... calls instead.assertThat in interface org.assertj.core.api.AssertProvider<ApplicationContextAssert<C extends ApplicationContext>>C getSourceApplicationContext()
ApplicationContext.IllegalStateException - if the source context failed to start<T extends C> T getSourceApplicationContext(Class<T> requiredType)
ApplicationContext, casting it to the requested
type.T - the context typerequiredType - the required context typeIllegalStateException - if the source context failed to startThrowable getStartupFailure()
null if the
context started without issue.nullvoid close()
close in interface AutoCloseableclose in interface Closeablestatic <T extends ApplicationContextAssertProvider<C>,C extends ApplicationContext> T get(Class<T> type, Class<? extends C> contextType, Supplier<? extends C> contextSupplier)
ApplicationContextAssertProvider instance.T - the assert provider typeC - the context typetype - the type of ApplicationContextAssertProvider required (must be
an interface)contextType - the type of ApplicationContext being managed (must be an
interface)contextSupplier - a supplier that will either return a fully configured
ApplicationContext or throw an exception if the context fails to start.ApplicationContextAssertProvider instance