public class SpringBootModule extends Object implements org.unitils.core.Module
| 限定符和类型 | 类和说明 |
|---|---|
protected class |
SpringBootModule.SpringTestListener
The
TestListener for this module |
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
PROPKEY_APPLICATION_CONTEXT_FACTORY_CLASS_NAME |
| 构造器和说明 |
|---|
SpringBootModule() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
afterInit()
No after initialization needed for this module
|
protected void |
closeApplicationContextIfNeeded(Object testObject) |
org.unitils.spring.enums.LoadTime |
findLoadTime(Class<?> clzz) |
org.springframework.context.ApplicationContext |
getApplicationContext(Object testObject)
Gets the application context for this test.
|
protected org.unitils.database.DatabaseModule |
getDatabaseModule() |
Object |
getSpringBean(Object testObject,
String name)
Gets the org.unitils.spring model with the given name.
|
<T> T |
getSpringBeanByType(Object testObject,
Class<T> type)
Gets the org.unitils.spring model with the given type.
|
org.unitils.core.TestListener |
getTestListener() |
void |
init(Properties configuration)
Initializes this module using the given configuration
|
void |
initialize(Object testObject) |
void |
injectApplicationContext(Object testObject)
Gets the application context for this class and sets it on the fields and setter methods that are
annotated with
SpringApplicationContext. |
void |
injectSpringBeans(Object testObject)
Injects org.unitils.spring beans into all fields that are annotated with
SpringBean. |
void |
injectSpringBeansByName(Object testObject)
Injects org.unitils.spring beans into all fields that are annotated with
SpringBeanByName. |
void |
injectSpringBeansByType(Object testObject)
Injects org.unitils.spring beans into all fields methods that are annotated with
SpringBeanByType. |
void |
invalidateApplicationContext(Class<?>... classes)
Forces the reloading of the application context the next time that it is requested.
|
boolean |
isApplicationContextConfiguredFor(Object testObject) |
protected boolean |
isDatabaseModuleEnabled() |
static void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
public static final String PROPKEY_APPLICATION_CONTEXT_FACTORY_CLASS_NAME
public SpringBootModule()
public static void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
public void init(Properties configuration)
init 在接口中 org.unitils.core.Moduleconfiguration - The configuration, not nullpublic void afterInit()
afterInit 在接口中 org.unitils.core.Modulepublic Object getSpringBean(Object testObject, String name)
SpringApplicationContext,
determines the application context in which to look for the model.
A UnitilsException is thrown when the no model could be found for the given name.testObject - The test instance, not nullname - The name, not nullpublic <T> T getSpringBeanByType(Object testObject, Class<T> type)
SpringApplicationContext,
determines the application context in which to look for the model.
If more there is not exactly 1 possible model assignment, an UnitilsException will be thrown.testObject - The test instance, not nulltype - The type, not nullpublic boolean isApplicationContextConfiguredFor(Object testObject)
testObject - The test objectpublic org.springframework.context.ApplicationContext getApplicationContext(Object testObject)
SpringApplicationContext
annotation.
If a class level SpringApplicationContext annotation is found, the passed locations will be loaded using
a ClassPathXmlApplicationContext.
Custom creation methods can be created by annotating them with SpringApplicationContext. They
should have an ApplicationContext as return type and either no or exactly 1 argument of type
ApplicationContext. In the latter case, the current configured application context is passed as the argument.
A UnitilsException will be thrown if no context could be retrieved or created.testObject - public void invalidateApplicationContext(Class<?>... classes)
classes - The classes for which to reset the contextspublic void injectApplicationContext(Object testObject)
SpringApplicationContext. If no application context could be created, an
UnitilsException will be raised.testObject - The test instance, not nullpublic void injectSpringBeans(Object testObject)
SpringBean.testObject - The test instance, not nullpublic void injectSpringBeansByType(Object testObject)
SpringBeanByType.testObject - The test instance, not nullpublic void injectSpringBeansByName(Object testObject)
SpringBeanByName.testObject - The test instance, not nullprotected void closeApplicationContextIfNeeded(Object testObject)
protected boolean isDatabaseModuleEnabled()
protected org.unitils.database.DatabaseModule getDatabaseModule()
public void initialize(Object testObject)
public org.unitils.core.TestListener getTestListener()
getTestListener 在接口中 org.unitils.core.ModuleTestListener for this modulepublic org.unitils.spring.enums.LoadTime findLoadTime(Class<?> clzz)
Copyright © 2018. All rights reserved.