Move getListenerId method to Smart/GenericApplicationListener

See gh-26638
This commit is contained in:
Juergen Hoeller
2021-03-09 12:30:52 +01:00
parent 4b80ef21b6
commit 3c9bd3177e
8 changed files with 54 additions and 67 deletions

View File

@@ -112,8 +112,8 @@ public class AnnotationDrivenEventListenerTests {
this.eventCollector.assertEvent(listener, event);
this.eventCollector.assertTotalEventsCount(1);
context.getBean(ApplicationEventMulticaster.class).removeApplicationListeners(
l -> l.getListenerId().contains("TestEvent"));
context.getBean(ApplicationEventMulticaster.class).removeApplicationListeners(l ->
l instanceof SmartApplicationListener && ((SmartApplicationListener) l).getListenerId().contains("TestEvent"));
this.eventCollector.clear();
this.context.publishEvent(event);
this.eventCollector.assertNoEventReceived(listener);
@@ -133,8 +133,8 @@ public class AnnotationDrivenEventListenerTests {
this.eventCollector.assertEvent(listener, event);
this.eventCollector.assertTotalEventsCount(1);
context.getBean(ApplicationEventMulticaster.class).removeApplicationListeners(
l -> l.getListenerId().contains("TestEvent"));
context.getBean(ApplicationEventMulticaster.class).removeApplicationListeners(l ->
l instanceof SmartApplicationListener && ((SmartApplicationListener) l).getListenerId().contains("TestEvent"));
this.eventCollector.clear();
this.context.publishEvent(event);
this.eventCollector.assertNoEventReceived(listener);
@@ -151,8 +151,8 @@ public class AnnotationDrivenEventListenerTests {
this.eventCollector.assertEvent(bean, event);
this.eventCollector.assertTotalEventsCount(1);
context.getBean(ApplicationEventMulticaster.class).removeApplicationListeners(
l -> l.getListenerId().equals("foo"));
context.getBean(ApplicationEventMulticaster.class).removeApplicationListeners(l ->
l instanceof SmartApplicationListener && ((SmartApplicationListener) l).getListenerId().equals("foo"));
this.eventCollector.clear();
this.context.publishEvent(event);
this.eventCollector.assertNoEventReceived(bean);