getBean
Obtain a single bean of the given type from the application context (or ancestors), the bean becoming the object under test. If no beans of the specified type can be found an assert on null
is returned.
Example:
assertThat(context).getBean(Foo.class).isInstanceOf(DefaultFoo.class);
assertThat(context).getBean(Bar.class).isNull();
Return
bean assertions for the bean, or an assert on null
if the no beanis found
Parameters
the bean type
the bean type
Throws
if the application context contains multiple beans of thegiven type
Obtain a single bean of the given type from the application context, the bean becoming the object under test. If no beans of the specified type can be found an assert on null
is returned.
Example:
assertThat(context).getBean(Foo.class, Scope.NO_ANCESTORS).isInstanceOf(DefaultFoo.class);
assertThat(context).getBean(Bar.class, Scope.NO_ANCESTORS).isNull();
Return
bean assertions for the bean, or an assert on null
if the no beanis found
Parameters
the bean type
the bean type
the scope of the assertion
Throws
if the application context contains multiple beans of thegiven type
Obtain a single bean of the given name from the application context, the bean becoming the object under test. If no bean of the specified name can be found an assert on null
is returned.
Example:
assertThat(context).getBean("foo").isInstanceOf(Foo.class);
assertThat(context).getBean("foo").isNull();
Return
bean assertions for the bean, or an assert on null
if the no beanis found
Parameters
the name of the bean
Throws
if the application context did not start
Obtain a single bean of the given name and type from the application context, the bean becoming the object under test. If no bean of the specified name can be found an assert on null
is returned.
Example:
assertThat(context).getBean("foo", Foo.class).isInstanceOf(DefaultFoo.class);
assertThat(context).getBean("foo", Foo.class).isNull();
Return
bean assertions for the bean, or an assert on null
if the no beanis found
Parameters
the bean type
the name of the bean
the bean type
Throws
if the application context contains a bean with the givenname but a different type