Class FoxgloveTestListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
guru.mikelue.foxglove.springframework.FoxgloveTestListener
- All Implemented Interfaces:
Ordered,TestExecutionListener
This listener resolving Auto-constructing default
If the Spring's context cannot find a viable
TableFacetsSource and DataGeneratorSource
in Spring's Context framework of test first.
From Spring's context
- For named sources, using
BeanFactory.getBean(String)to get object - For subtype of
TableFacetsProviderorDataGeneratorProvider, usingBeanFactory.getBean(Class)to get object of that type. - For
DataGenerator, usingBeanFactory.getBean(Class)with type ofTableFacetsProvider.class, orDataGenerator.class.
This method would throwNoUniqueBeanDefinitionExceptionif there are multiple candidates in the context. - For
TableFacet, usingBeanFactory.getBean(Class)with type ofTableFacetsProvider.class.
This method would throwNoUniqueBeanDefinitionExceptionif there are multiple candidates in the context.
Auto-constructing default DataGenerator
If the Spring's context cannot find a viable DataGenerator bean,
this listener will construct with:
- Using
TestTransaction.isActive()andDataSourceUtils.getConnection(DataSource)to get current transaction's connection for data generation. - Otherwise, using
DataSourceto construct a newDataGenerator(prototype scope).
Otherwise, this listener follows the semantics defined by annotation doc.
Nested test classes
This listener doesn't support resolving sources from enclosing classes.
However, you could use Spring's NestedTestConfiguration to resolve sources from Spring's context.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default order of this listener is just afterSqlScriptsTestExecutionListener.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeTestClass(TestContext testContext) voidbeforeTestMethod(TestContext testContext) intgetOrder()The order of this listener is just afterSqlScriptsTestExecutionListener.Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestExecution, afterTestMethod, beforeTestExecution, prepareTestInstance
-
Field Details
-
ORDER
public static final int ORDERThe default order of this listener is just afterSqlScriptsTestExecutionListener.- See Also:
-
-
Constructor Details
-
FoxgloveTestListener
public FoxgloveTestListener()Default constructor.
-
-
Method Details
-
getOrder
public int getOrder()The order of this listener is just afterSqlScriptsTestExecutionListener.- Specified by:
getOrderin interfaceOrdered- Overrides:
getOrderin classAbstractTestExecutionListener- Returns:
- The order value
- See Also:
-
beforeTestClass
- Specified by:
beforeTestClassin interfaceTestExecutionListener- Overrides:
beforeTestClassin classAbstractTestExecutionListener- Throws:
Exception
-
beforeTestMethod
- Specified by:
beforeTestMethodin interfaceTestExecutionListener- Overrides:
beforeTestMethodin classAbstractTestExecutionListener- Throws:
Exception
-