From 32e221d49945b4e77f8a241d4e0d5460f3fca976 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 11 Oct 2018 10:49:56 -0400 Subject: [PATCH] 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 --- build.gradle | 4 ++-- ...licationEventListeningMessageProducerTests.java | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 6c742ddbe2..8c49704179 100644 --- a/build.gradle +++ b/build.gradle @@ -154,8 +154,8 @@ subprojects { subproject -> springSecurityVersion = '5.0.7.RELEASE' springSocialTwitterVersion = '1.1.2.RELEASE' springRetryVersion = '1.2.2.RELEASE' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.9.RELEASE' - springWsVersion = '3.0.2.RELEASE' + springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.10.BUILD-SNAPSHOT' + springWsVersion = '3.0.3.RELEASE' tomcatVersion = "8.5.23" xmlUnitVersion = '1.6' xstreamVersion = '1.4.10' diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java index 585d84e431..237c23a35b 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.integration.event.inbound; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.isOneOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -254,9 +256,9 @@ public class ApplicationEventListeningMessageProducerTests { Class event = TestUtils.getPropertyValue(entry.getKey(), "eventType.resolved", Class.class); assertThat(event, Matchers.is(Matchers.isOneOf(ContextRefreshedEvent.class, TestApplicationEvent1.class))); - Set listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListenerBeans", Set.class); + Set listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListeners", Set.class); assertEquals(1, listeners.size()); - assertEquals("testListener", listeners.iterator().next()); + assertSame(ctx.getBean("testListener"), listeners.iterator().next()); } TestApplicationEvent2 event2 = new TestApplicationEvent2(); @@ -265,11 +267,11 @@ public class ApplicationEventListeningMessageProducerTests { for (Map.Entry entry : retrieverCache.entrySet()) { Class event = TestUtils.getPropertyValue(entry.getKey(), "eventType.resolved", Class.class); if (TestApplicationEvent2.class.isAssignableFrom(event)) { - Set listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListenerBeans", Set.class); + Set listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListeners", Set.class); assertEquals(2, listeners.size()); for (Object listener : listeners) { - assertThat((String) listener, - Matchers.is(Matchers.isOneOf("testListenerMessageProducer", "testListener"))); + assertThat(listener, + is(isOneOf(ctx.getBean("testListenerMessageProducer"), ctx.getBean("testListener")))); } break; }