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
,
ApplicationContextAssert
FACTORY_BEAN_PREFIX
CLASSPATH_ALL_URL_PREFIX
CLASSPATH_URL_PREFIX
Modifier and Type | Method and Description |
---|---|
ApplicationContextAssert<C> |
assertThat()
Deprecated.
use 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, getStartupDate
getEnvironment
containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation
containsLocalBean, getParentBeanFactory
containsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getBeanProvider, getBeanProvider, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch
getMessage, getMessage, getMessage
publishEvent, publishEvent
getResources
getClassLoader, 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.null
void close()
close
in interface AutoCloseable
close
in interface Closeable
static <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
instanceCopyright © 2019 Pivotal Software, Inc.. All rights reserved.