diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java index bed2f4c13f..3b354c33ac 100644 --- a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java @@ -40,6 +40,7 @@ import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttributeSource; import org.springframework.util.Assert; @@ -49,8 +50,7 @@ import org.springframework.util.StringUtils; /** * {@code TestExecutionListener} that provides support for executing tests * within test-managed transactions by honoring Spring's - * {@link org.springframework.transaction.annotation.Transactional @Transactional} - * annotation. + * {@link Transactional @Transactional} annotation. * *
Test-managed transactions are transactions that are managed @@ -76,8 +76,7 @@ import org.springframework.util.StringUtils; * not annotated with {@code @Transactional} (at the class or method * level) will not be run within a transaction. Furthermore, tests that * are annotated with {@code @Transactional} but have the - * {@link org.springframework.transaction.annotation.Transactional#propagation propagation} - * type set to + * {@link Transactional#propagation propagation} type set to * {@link org.springframework.transaction.annotation.Propagation#NOT_SUPPORTED NOT_SUPPORTED} * will not be run within a transaction. * @@ -109,15 +108,30 @@ import org.springframework.util.StringUtils; * {@code ApplicationContext} for the test. In case there are multiple * instances of {@code PlatformTransactionManager} within the test's * {@code ApplicationContext}, a qualifier may be declared via - * {@link org.springframework.transaction.annotation.Transactional @Transactional} - * (e.g., {@code @Transactional("myTxMgr")} or {@code @Transactional(transactionManger = "myTxMgr")}, - * or {@link org.springframework.transaction.annotation.TransactionManagementConfigurer + * {@link Transactional @Transactional} (e.g., {@code @Transactional("myTxMgr")} + * or {@code @Transactional(transactionManger = "myTxMgr")}, or + * {@link org.springframework.transaction.annotation.TransactionManagementConfigurer * TransactionManagementConfigurer} can be implemented by an * {@link org.springframework.context.annotation.Configuration @Configuration} * class. See {@link TestContextTransactionUtils#retrieveTransactionManager} * for details on the algorithm used to look up a transaction manager in * the test's {@code ApplicationContext}. * + *
| Attribute | Supported for test-managed transactions |
|---|---|
| {@link Transactional#value value} and {@link Transactional#transactionManager transactionManager} | yes |
| {@link Transactional#propagation propagation} | + *only {@link org.springframework.transaction.annotation.Propagation#NOT_SUPPORTED NOT_SUPPORTED} is supported |
| {@link Transactional#isolation isolation} | no |
| {@link Transactional#timeout timeout} | no |
| {@link Transactional#readOnly readOnly} | no |
| {@link Transactional#rollbackFor rollbackFor} and {@link Transactional#rollbackForClassName rollbackForClassName} | + *no: use {@link TestTransaction#flagForRollback()} instead |
| {@link Transactional#noRollbackFor noRollbackFor} and {@link Transactional#noRollbackForClassName noRollbackForClassName} | + *no: use {@link TestTransaction#flagForCommit()} instead |
Note that if a {@code @BeforeTransaction} method fails, any remaining
* {@code @BeforeTransaction} methods will not be invoked, and a transaction
* will not be started.
- * @see org.springframework.transaction.annotation.Transactional
+ * @see Transactional @Transactional
* @see #getTransactionManager(TestContext, String)
*/
@Override
diff --git a/src/docs/asciidoc/testing.adoc b/src/docs/asciidoc/testing.adoc
index 7d226160fd..a607fb3a49 100644
--- a/src/docs/asciidoc/testing.adoc
+++ b/src/docs/asciidoc/testing.adoc
@@ -1025,6 +1025,7 @@ and can be used anywhere in the Spring Framework.
* `@Autowired`
* `@Qualifier`
+* `@Value`
* `@Resource` (javax.annotation) if JSR-250 is present
* `@ManagedBean` (javax.annotation) if JSR-250 is present
* `@Inject` (javax.inject) if JSR-330 is present
@@ -1032,7 +1033,8 @@ and can be used anywhere in the Spring Framework.
* `@PersistenceContext` (javax.persistence) if JPA is present
* `@PersistenceUnit` (javax.persistence) if JPA is present
* `@Required`
-* `@Transactional`
+* `@Transactional` (org.springframework.transaction.annotation)
+ _with <