File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
spring-tx/src/test/java/org/springframework/transaction/reactive Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,34 @@ public void monoSubscriptionNotCancelled() {
61
61
assertThat (cancelled ).isFalse ();
62
62
}
63
63
64
+ @ Test
65
+ public void cancellationPropagatedToMono () {
66
+ AtomicBoolean cancelled = new AtomicBoolean ();
67
+ TransactionalOperator operator = TransactionalOperator .create (tm , new DefaultTransactionDefinition ());
68
+ Mono .create (sink -> sink .onCancel (() -> cancelled .set (true ))).as (operator ::transactional )
69
+ .as (StepVerifier ::create )
70
+ .thenAwait ()
71
+ .thenCancel ()
72
+ .verify ();
73
+ assertThat (tm .commit ).isTrue ();
74
+ assertThat (tm .rollback ).isFalse ();
75
+ assertThat (cancelled ).isTrue ();
76
+ }
77
+
78
+ @ Test
79
+ public void cancellationPropagatedToFlux () {
80
+ AtomicBoolean cancelled = new AtomicBoolean ();
81
+ TransactionalOperator operator = TransactionalOperator .create (tm , new DefaultTransactionDefinition ());
82
+ Flux .create (sink -> sink .onCancel (() -> cancelled .set (true ))).as (operator ::transactional )
83
+ .as (StepVerifier ::create )
84
+ .thenAwait ()
85
+ .thenCancel ()
86
+ .verify ();
87
+ assertThat (tm .commit ).isTrue ();
88
+ assertThat (tm .rollback ).isFalse ();
89
+ assertThat (cancelled ).isTrue ();
90
+ }
91
+
64
92
@ Test
65
93
public void rollbackWithMono () {
66
94
TransactionalOperator operator = TransactionalOperator .create (tm , new DefaultTransactionDefinition ());
You can’t perform that action at this time.
0 commit comments