Skip to content

Commit 32e221d

Browse files
garyrussellartembilan
authored andcommitted
SPR-17307: Fix event listener tests
JIRA: https://jira.spring.io/browse/SPR-17307 The event multicaster now saves singletons in `applicationListeners` instead of adding the bean name to `applicationListenerBeans`. **cherry-pick to 5.0.x** # Conflicts: # build.gradle
1 parent 490ae1b commit 32e221d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ subprojects { subproject ->
154154
springSecurityVersion = '5.0.7.RELEASE'
155155
springSocialTwitterVersion = '1.1.2.RELEASE'
156156
springRetryVersion = '1.2.2.RELEASE'
157-
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.9.RELEASE'
158-
springWsVersion = '3.0.2.RELEASE'
157+
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.10.BUILD-SNAPSHOT'
158+
springWsVersion = '3.0.3.RELEASE'
159159
tomcatVersion = "8.5.23"
160160
xmlUnitVersion = '1.6'
161161
xstreamVersion = '1.4.10'

spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.event.inbound;
1818

19+
import static org.hamcrest.Matchers.is;
20+
import static org.hamcrest.Matchers.isOneOf;
1921
import static org.junit.Assert.assertEquals;
2022
import static org.junit.Assert.assertFalse;
2123
import static org.junit.Assert.assertNotNull;
@@ -254,9 +256,9 @@ public void testInt2935CheckRetrieverCache() {
254256
Class<? extends ApplicationEvent> event = TestUtils.getPropertyValue(entry.getKey(), "eventType.resolved",
255257
Class.class);
256258
assertThat(event, Matchers.is(Matchers.isOneOf(ContextRefreshedEvent.class, TestApplicationEvent1.class)));
257-
Set<?> listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListenerBeans", Set.class);
259+
Set<?> listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListeners", Set.class);
258260
assertEquals(1, listeners.size());
259-
assertEquals("testListener", listeners.iterator().next());
261+
assertSame(ctx.getBean("testListener"), listeners.iterator().next());
260262
}
261263

262264
TestApplicationEvent2 event2 = new TestApplicationEvent2();
@@ -265,11 +267,11 @@ public void testInt2935CheckRetrieverCache() {
265267
for (Map.Entry<?, ?> entry : retrieverCache.entrySet()) {
266268
Class<?> event = TestUtils.getPropertyValue(entry.getKey(), "eventType.resolved", Class.class);
267269
if (TestApplicationEvent2.class.isAssignableFrom(event)) {
268-
Set<?> listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListenerBeans", Set.class);
270+
Set<?> listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListeners", Set.class);
269271
assertEquals(2, listeners.size());
270272
for (Object listener : listeners) {
271-
assertThat((String) listener,
272-
Matchers.is(Matchers.isOneOf("testListenerMessageProducer", "testListener")));
273+
assertThat(listener,
274+
is(isOneOf(ctx.getBean("testListenerMessageProducer"), ctx.getBean("testListener"))));
273275
}
274276
break;
275277
}

0 commit comments

Comments
 (0)