public interface SpringRule extends ch.powerunit.rules.TestListenerRule
TestRule
to provide support to use
Spring inside PowerUnit.Modifier and Type | Method and Description |
---|---|
default boolean |
containsBean(String name)
Validate if a bean with a name exists.
|
org.springframework.context.ApplicationContext |
getApplicationContext() |
default <T> T |
getBean(Class<T> requiredType)
Get a bean from the used ApplicationContext.
|
default Object |
getBean(String name)
Get a bean, by name.
|
default Object |
getBean(String name,
Object... arguments)
Get a bean, passing argument.
|
static SpringRule |
of(int autowireMode,
String location,
String... nextLocation)
Create a rule to support Spring.
|
org.springframework.context.ApplicationContext getApplicationContext()
static SpringRule of(int autowireMode, String location, String... nextLocation)
For instance:
@Rule public final SpringRule spring = SpringRule.of( AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, "classpath:sample.xml");
autowireMode
- The autowiring mode (of the test class).location
- the first location for the bean context.nextLocation
- optional additional location for the bean context.AutowireCapableBeanFactory.AUTOWIRE_BY_NAME
,
AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE
default <T> T getBean(Class<T> requiredType)
T
- THe type of the bean.requiredType
- the requiredType.BeanFactory.getBean(Class)
default boolean containsBean(String name)
name
- the nameBeanFactory.containsBean(String)
default Object getBean(String name, Object... arguments) throws org.springframework.beans.BeansException
name
- the namearguments
- the argumentsorg.springframework.beans.BeansException
- if the bean could not be createdBeanFactory.getBean(Class,
Object...)
Copyright © 2015. All rights reserved.