C
- the application context typepublic class ApplicationContextAssert<C extends ApplicationContext> extends org.assertj.core.api.AbstractAssert<ApplicationContextAssert<C>,C>
assertions
that can be applied to an
ApplicationContext
.ApplicationContextRunner
,
AssertableApplicationContext
Modifier and Type | Class and Description |
---|---|
static class |
ApplicationContextAssert.Scope
The scope of an assertion.
|
Modifier and Type | Method and Description |
---|---|
ApplicationContextAssert<C> |
doesNotHaveBean(Class<?> type)
Verifies that the application context (or ancestors) does not contain any beans of
the given type.
|
ApplicationContextAssert<C> |
doesNotHaveBean(Class<?> type,
ApplicationContextAssert.Scope scope)
Verifies that the application context does not contain any beans of the given type.
|
ApplicationContextAssert<C> |
doesNotHaveBean(String name)
Verifies that the application context does not contain a beans of the given name.
|
protected C |
getApplicationContext() |
<T> org.assertj.core.api.AbstractObjectAssert<?,T> |
getBean(Class<T> type)
Obtain a single bean of the given type from the application context (or ancestors),
the bean becoming the object under test.
|
<T> org.assertj.core.api.AbstractObjectAssert<?,T> |
getBean(Class<T> type,
ApplicationContextAssert.Scope scope)
Obtain a single bean of the given type from the application context, the bean
becoming the object under test.
|
org.assertj.core.api.AbstractObjectAssert<?,Object> |
getBean(String name)
Obtain a single bean of the given name from the application context, the bean
becoming the object under test.
|
<T> org.assertj.core.api.AbstractObjectAssert<?,T> |
getBean(String name,
Class<T> type)
Obtain a single bean of the given name and type from the application context, the
bean becoming the object under test.
|
<T> org.assertj.core.api.AbstractObjectArrayAssert<?,String> |
getBeanNames(Class<T> type)
Obtain the beans names of the given type from the application context, the names
becoming the object array under test.
|
<T> org.assertj.core.api.MapAssert<String,T> |
getBeans(Class<T> type)
Obtain a map bean names and instances of the given type from the application
context (or ancestors), the map becoming the object under test.
|
<T> org.assertj.core.api.MapAssert<String,T> |
getBeans(Class<T> type,
ApplicationContextAssert.Scope scope)
Obtain a map bean names and instances of the given type from the application
context, the map becoming the object under test.
|
org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> |
getFailure()
Obtain the failure that stopped the application context from running, the failure
becoming the object under test.
|
protected Throwable |
getStartupFailure() |
ApplicationContextAssert<C> |
hasBean(String name)
Verifies that the application context contains a bean with the given name.
|
ApplicationContextAssert<C> |
hasFailed()
Verifies that the application has failed to start.
|
ApplicationContextAssert<C> |
hasNotFailed()
Verifies that the application has not failed to start.
|
ApplicationContextAssert<C> |
hasSingleBean(Class<?> type)
Verifies that the application context (or ancestors) contains a single bean with
the given type.
|
ApplicationContextAssert<C> |
hasSingleBean(Class<?> type,
ApplicationContextAssert.Scope scope)
Verifies that the application context contains a single bean with the given type.
|
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
public ApplicationContextAssert<C> hasBean(String name)
Example:
assertThat(context).hasBean("fooBean");
name
- the name of the beanthis
assertion object.AssertionError
- if the application context did not startAssertionError
- if the application context does not contain a bean with the
given namepublic ApplicationContextAssert<C> hasSingleBean(Class<?> type)
Example:
assertThat(context).hasSingleBean(Foo.class);
type
- the bean typethis
assertion object.AssertionError
- if the application context did not startAssertionError
- if the application context does no beans of the given typeAssertionError
- if the application context contains multiple beans of the
given typepublic ApplicationContextAssert<C> hasSingleBean(Class<?> type, ApplicationContextAssert.Scope scope)
Example:
assertThat(context).hasSingleBean(Foo.class, Scope.NO_ANCESTORS);
type
- the bean typescope
- the scope of the assertionthis
assertion object.AssertionError
- if the application context did not startAssertionError
- if the application context does no beans of the given typeAssertionError
- if the application context contains multiple beans of the
given typepublic ApplicationContextAssert<C> doesNotHaveBean(Class<?> type)
Example:
assertThat(context).doesNotHaveBean(Foo.class);
type
- the bean typethis
assertion object.AssertionError
- if the application context did not startAssertionError
- if the application context contains any beans of the given
typepublic ApplicationContextAssert<C> doesNotHaveBean(Class<?> type, ApplicationContextAssert.Scope scope)
Example:
assertThat(context).doesNotHaveBean(Foo.class, Scope.NO_ANCESTORS);
type
- the bean typescope
- the scope of the assertionthis
assertion object.AssertionError
- if the application context did not startAssertionError
- if the application context contains any beans of the given
typepublic ApplicationContextAssert<C> doesNotHaveBean(String name)
Example:
assertThat(context).doesNotHaveBean("fooBean");
name
- the name of the beanthis
assertion object.AssertionError
- if the application context did not startAssertionError
- if the application context contains a beans of the given
namepublic <T> org.assertj.core.api.AbstractObjectArrayAssert<?,String> getBeanNames(Class<T> type)
Example:
assertThat(context).getBeanNames(Foo.class).containsOnly("fooBean");
T
- the bean typetype
- the bean typeAssertionError
- if the application context did not startpublic <T> org.assertj.core.api.AbstractObjectAssert<?,T> getBean(Class<T> type)
null
is returned.
Example:
assertThat(context).getBean(Foo.class).isInstanceOf(DefaultFoo.class); assertThat(context).getBean(Bar.class).isNull();
T
- the bean typetype
- the bean typenull
if the no bean
is foundAssertionError
- if the application context did not startAssertionError
- if the application context contains multiple beans of the
given typepublic <T> org.assertj.core.api.AbstractObjectAssert<?,T> getBean(Class<T> type, ApplicationContextAssert.Scope scope)
null
is returned.
Example:
assertThat(context).getBean(Foo.class, Scope.NO_ANCESTORS).isInstanceOf(DefaultFoo.class); assertThat(context).getBean(Bar.class, Scope.NO_ANCESTORS).isNull();
T
- the bean typetype
- the bean typescope
- the scope of the assertionnull
if the no bean
is foundAssertionError
- if the application context did not startAssertionError
- if the application context contains multiple beans of the
given typepublic org.assertj.core.api.AbstractObjectAssert<?,Object> getBean(String name)
null
is returned.
Example:
assertThat(context).getBean("foo").isInstanceOf(Foo.class); assertThat(context).getBean("foo").isNull();
name
- the name of the beannull
if the no bean
is foundAssertionError
- if the application context did not startpublic <T> org.assertj.core.api.AbstractObjectAssert<?,T> getBean(String name, Class<T> type)
null
is returned.
Example:
assertThat(context).getBean("foo", Foo.class).isInstanceOf(DefaultFoo.class); assertThat(context).getBean("foo", Foo.class).isNull();
T
- the bean typename
- the name of the beantype
- the bean typenull
if the no bean
is foundAssertionError
- if the application context did not startAssertionError
- if the application context contains a bean with the given
name but a different typepublic <T> org.assertj.core.api.MapAssert<String,T> getBeans(Class<T> type)
map
is returned.
Example:
assertThat(context).getBeans(Foo.class).containsKey("foo");
T
- the bean typetype
- the bean typemap
if the
no beans are foundAssertionError
- if the application context did not startpublic <T> org.assertj.core.api.MapAssert<String,T> getBeans(Class<T> type, ApplicationContextAssert.Scope scope)
map
is returned.
Example:
assertThat(context).getBeans(Foo.class, Scope.NO_ANCESTORS).containsKey("foo");
T
- the bean typetype
- the bean typescope
- the scope of the assertionmap
if the
no beans are foundAssertionError
- if the application context did not startpublic org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> getFailure()
Example:
assertThat(context).getFailure().containsMessage("missing bean");
AssertionError
- if the application context started without a failurepublic ApplicationContextAssert<C> hasFailed()
Example:
assertThat(context).hasFailed();
this
assertion object.AssertionError
- if the application context started without a failurepublic ApplicationContextAssert<C> hasNotFailed()
Example:
assertThat(context).hasNotFailed();
this
assertion object.AssertionError
- if the application context failed to startprotected final C getApplicationContext()
protected final Throwable getStartupFailure()
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.