|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* Copyright 2002-2023 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -57,6 +57,7 @@ import static org.springframework.transaction.event.TransactionPhase.BEFORE_COMM |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Integration tests for {@link TransactionalEventListener} support |
|
|
|
* Integration tests for {@link TransactionalEventListener} support |
|
|
|
|
|
|
|
* with thread-bound transactions. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Stephane Nicoll |
|
|
|
* @author Stephane Nicoll |
|
|
|
* @author Sam Brannen |
|
|
|
* @author Sam Brannen |
|
|
@ -87,7 +88,6 @@ public class TransactionalEventListenerTests { |
|
|
|
getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test"); |
|
|
|
getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test"); |
|
|
|
getEventCollector().assertTotalEventsCount(1); |
|
|
|
getEventCollector().assertTotalEventsCount(1); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test"); |
|
|
|
getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test"); |
|
|
|
getEventCollector().assertTotalEventsCount(1); |
|
|
|
getEventCollector().assertTotalEventsCount(1); |
|
|
@ -115,7 +115,6 @@ public class TransactionalEventListenerTests { |
|
|
|
getContext().publishEvent("test"); |
|
|
|
getContext().publishEvent("test"); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMPLETION, "test"); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMPLETION, "test"); |
|
|
|
getEventCollector().assertTotalEventsCount(1); // After rollback not invoked
|
|
|
|
getEventCollector().assertTotalEventsCount(1); // After rollback not invoked
|
|
|
@ -129,7 +128,6 @@ public class TransactionalEventListenerTests { |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
status.setRollbackOnly(); |
|
|
|
status.setRollbackOnly(); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMPLETION, "test"); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMPLETION, "test"); |
|
|
|
getEventCollector().assertTotalEventsCount(1); // After rollback not invoked
|
|
|
|
getEventCollector().assertTotalEventsCount(1); // After rollback not invoked
|
|
|
@ -142,7 +140,6 @@ public class TransactionalEventListenerTests { |
|
|
|
getContext().publishEvent("test"); |
|
|
|
getContext().publishEvent("test"); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMMIT, "test"); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMMIT, "test"); |
|
|
|
getEventCollector().assertTotalEventsCount(1); // After rollback not invoked
|
|
|
|
getEventCollector().assertTotalEventsCount(1); // After rollback not invoked
|
|
|
@ -307,13 +304,12 @@ public class TransactionalEventListenerTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void afterCommitMetaAnnotation() throws Exception { |
|
|
|
public void afterCommitMetaAnnotation() { |
|
|
|
load(AfterCommitMetaAnnotationTestListener.class); |
|
|
|
load(AfterCommitMetaAnnotationTestListener.class); |
|
|
|
this.transactionTemplate.execute(status -> { |
|
|
|
this.transactionTemplate.execute(status -> { |
|
|
|
getContext().publishEvent("test"); |
|
|
|
getContext().publishEvent("test"); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMMIT, "test"); |
|
|
|
getEventCollector().assertEvents(EventCollector.AFTER_COMMIT, "test"); |
|
|
|
getEventCollector().assertTotalEventsCount(1); |
|
|
|
getEventCollector().assertTotalEventsCount(1); |
|
|
@ -326,7 +322,6 @@ public class TransactionalEventListenerTests { |
|
|
|
getContext().publishEvent("SKIP"); |
|
|
|
getContext().publishEvent("SKIP"); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
getEventCollector().assertNoEventReceived(); |
|
|
|
} |
|
|
|
} |
|
|
|