类 TestContextTransactionUtils
java.lang.Object
cn.taketoday.test.context.transaction.TestContextTransactionUtils
Utility methods for working with transactions and data access related beans
within the TestContext Framework.
Mainly for internal use within the framework.
- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen, Juergen Hoeller, Harry Yang
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明static final StringDefault bean name for aDataSource:"dataSource".static final StringDefault bean name for aPlatformTransactionManager:"transactionManager".private static final cn.taketoday.logging.Logger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static cn.taketoday.transaction.interceptor.TransactionAttributecreateDelegatingTransactionAttribute(TestContext testContext, cn.taketoday.transaction.interceptor.TransactionAttribute targetAttribute) Create a delegatingTransactionAttributefor the supplied targetTransactionAttributeandTestContext, using the names of the test class and test method to build the name of the transaction.static cn.taketoday.transaction.interceptor.TransactionAttributecreateDelegatingTransactionAttribute(TestContext testContext, cn.taketoday.transaction.interceptor.TransactionAttribute targetAttribute, boolean includeMethodName) Create a delegatingTransactionAttributefor the supplied targetTransactionAttributeandTestContext, using the names of the test class and test method (if requested) to build the name of the transaction.private static voidlogBeansException(TestContext testContext, cn.taketoday.beans.BeansException ex, Class<?> beanType) static DataSourceretrieveDataSource(TestContext testContext, String name) Retrieve theDataSourceto use for the supplied test context.static cn.taketoday.transaction.PlatformTransactionManagerretrieveTransactionManager(TestContext testContext, String name) Retrieve the transaction manager to use for the supplied test context.
-
字段详细资料
-
DEFAULT_DATA_SOURCE_NAME
Default bean name for aDataSource:"dataSource".- 另请参阅:
-
DEFAULT_TRANSACTION_MANAGER_NAME
Default bean name for aPlatformTransactionManager:"transactionManager".- 另请参阅:
-
logger
private static final cn.taketoday.logging.Logger logger
-
-
构造器详细资料
-
TestContextTransactionUtils
public TestContextTransactionUtils()
-
-
方法详细资料
-
retrieveDataSource
@Nullable public static DataSource retrieveDataSource(TestContext testContext, @Nullable String name) Retrieve theDataSourceto use for the supplied test context.The following algorithm is used to retrieve the
DataSourcefrom theApplicationContextof the supplied test context:- Look up the
DataSourceby type and name, if the suppliednameis non-empty, throwing aBeansExceptionif the namedDataSourcedoes not exist. - Attempt to look up the single
DataSourceby type. - Attempt to look up the primary
DataSourceby type. - Attempt to look up the
DataSourceby type and the default data source name.
- 参数:
testContext- the test context for which theDataSourceshould be retrieved; nevernullname- the name of theDataSourceto retrieve (may benullor empty)- 返回:
- the
DataSourceto use, ornullif not found - 抛出:
cn.taketoday.beans.BeansException- if an error occurs while retrieving an explicitly namedDataSource
- Look up the
-
retrieveTransactionManager
@Nullable public static cn.taketoday.transaction.PlatformTransactionManager retrieveTransactionManager(TestContext testContext, @Nullable String name) Retrieve the transaction manager to use for the supplied test context.The following algorithm is used to retrieve the transaction manager from the
ApplicationContextof the supplied test context:- Look up the transaction manager by type and explicit name, if the supplied
nameis non-empty, throwing aBeansExceptionif the named transaction manager does not exist. - Attempt to look up the transaction manager via a
TransactionManagementConfigurer, if present. - Attempt to look up the single transaction manager by type.
- Attempt to look up the primary transaction manager by type.
- Attempt to look up the transaction manager by type and the default transaction manager name.
- 参数:
testContext- the test context for which the transaction manager should be retrieved; nevernullname- the name of the transaction manager to retrieve (may benullor empty)- 返回:
- the transaction manager to use, or
nullif not found - 抛出:
cn.taketoday.beans.BeansException- if an error occurs while retrieving an explicitly named transaction managerIllegalStateException- if more than one TransactionManagementConfigurer exists in the ApplicationContext
- Look up the transaction manager by type and explicit name, if the supplied
-
logBeansException
private static void logBeansException(TestContext testContext, cn.taketoday.beans.BeansException ex, Class<?> beanType) -
createDelegatingTransactionAttribute
public static cn.taketoday.transaction.interceptor.TransactionAttribute createDelegatingTransactionAttribute(TestContext testContext, cn.taketoday.transaction.interceptor.TransactionAttribute targetAttribute) Create a delegatingTransactionAttributefor the supplied targetTransactionAttributeandTestContext, using the names of the test class and test method to build the name of the transaction.- 参数:
testContext- theTestContextupon which to base the nametargetAttribute- theTransactionAttributeto delegate to- 返回:
- the delegating
TransactionAttribute
-
createDelegatingTransactionAttribute
public static cn.taketoday.transaction.interceptor.TransactionAttribute createDelegatingTransactionAttribute(TestContext testContext, cn.taketoday.transaction.interceptor.TransactionAttribute targetAttribute, boolean includeMethodName) Create a delegatingTransactionAttributefor the supplied targetTransactionAttributeandTestContext, using the names of the test class and test method (if requested) to build the name of the transaction.- 参数:
testContext- theTestContextupon which to base the nametargetAttribute- theTransactionAttributeto delegate toincludeMethodName-trueif the test method's name should be included in the name of the transaction- 返回:
- the delegating
TransactionAttribute
-