Introduce @Commit alias for @Rollback(false)
Due to common usage of @Rollback(false), this commit introduces a new @Commit annotation that more clearly conveys the intent of the code while retaining the run-time semantics. @Commit is in fact meta-annotated with @Rollback(false). Issue: SPR-13279
This commit is contained in:
@@ -799,13 +799,36 @@ for an example and further details.
|
||||
|
||||
+
|
||||
|
||||
* `@Commit`
|
||||
|
||||
+
|
||||
|
||||
Indicates that the transaction for a transactional test method should be __committed__
|
||||
after the test method has completed. `@Commit` can be used as a direct replacement for
|
||||
`@Rollback(false)` in order to more explicitly convey the intent of the code. Analogous to
|
||||
`@Rollback`, `@Commit` may also be declared as a class-level or method-level annotation.
|
||||
|
||||
+
|
||||
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
**@Commit**
|
||||
@Test
|
||||
public void testProcessWithoutRollback() {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
|
||||
* `@Rollback`
|
||||
|
||||
+
|
||||
|
||||
Indicates whether the transaction for a transactional test method should be __rolled
|
||||
back__ after the test method has completed. If `true`, the transaction is rolled back;
|
||||
otherwise, the transaction is committed.
|
||||
otherwise, the transaction is committed. Rollback semantics for integration tests in the
|
||||
Spring TestContext Framework default to `true` even if `@Rollback` is not explicitly
|
||||
declared.
|
||||
|
||||
+
|
||||
|
||||
|
||||
@@ -577,6 +577,8 @@ public @interface MyTestConfig {
|
||||
_before_ a test -- for example, if some rogue (i.e., yet to be
|
||||
determined) test within a large test suite has corrupted the original
|
||||
configuration for the `ApplicationContext`.
|
||||
* `@Commit` is a new annotation that may be used as a direct replacement for
|
||||
`@Rollback(false)`.
|
||||
* `@Rollback` may now be used to configure class-level _default rollback_ semantics.
|
||||
** Consequently, `@TransactionConfiguration` is now deprecated and will be removed in a
|
||||
subsequent release.
|
||||
|
||||
Reference in New Issue
Block a user