16
16
17
17
package org .springframework .cloud .endpoint ;
18
18
19
- import static org .junit .Assert .assertEquals ;
20
- import static org .junit .Assert .assertFalse ;
21
- import static org .junit .Assert .assertTrue ;
22
-
23
19
import java .lang .reflect .Field ;
24
20
import java .util .ArrayList ;
25
21
import java .util .Collection ;
28
24
import java .util .Map ;
29
25
30
26
import org .junit .After ;
31
- import org .junit .Ignore ;
32
27
import org .junit .Test ;
28
+
33
29
import org .springframework .boot .Banner .Mode ;
34
30
import org .springframework .boot .WebApplicationType ;
35
31
import org .springframework .boot .builder .SpringApplicationBuilder ;
43
39
import org .springframework .context .ApplicationEvent ;
44
40
import org .springframework .context .ConfigurableApplicationContext ;
45
41
import org .springframework .context .annotation .Configuration ;
46
- import org .springframework .context .event .EventListener ;
42
+ import org .springframework .context .event .SmartApplicationListener ;
47
43
import org .springframework .core .env .Environment ;
48
44
import org .springframework .core .env .MapPropertySource ;
49
45
import org .springframework .core .env .PropertySource ;
50
46
import org .springframework .stereotype .Component ;
51
47
import org .springframework .util .ClassUtils ;
52
48
import org .springframework .util .ReflectionUtils ;
53
49
50
+ import static org .junit .Assert .assertEquals ;
51
+ import static org .junit .Assert .assertFalse ;
52
+ import static org .junit .Assert .assertTrue ;
53
+
54
54
/**
55
55
* @author Dave Syer
56
56
* @author Venil Noronha
@@ -132,7 +132,6 @@ public void springMainSourcesEmptyInRefreshCycle() throws Exception {
132
132
}
133
133
134
134
@ Test
135
- @ Ignore //FIXME: 2.1.0
136
135
public void eventsPublishedInOrder () throws Exception {
137
136
this .context = new SpringApplicationBuilder (Empty .class )
138
137
.web (WebApplicationType .NONE ).bannerMode (Mode .OFF ).run ();
@@ -148,7 +147,6 @@ public void eventsPublishedInOrder() throws Exception {
148
147
}
149
148
150
149
@ Test
151
- @ Ignore //FIXME: 2.1.0
152
150
public void shutdownHooksCleaned () {
153
151
try (ConfigurableApplicationContext context = new SpringApplicationBuilder (Empty .class )
154
152
.web (WebApplicationType .NONE ).bannerMode (Mode .OFF ).run ()) {
@@ -174,17 +172,22 @@ private int countShutdownHooks() {
174
172
}
175
173
176
174
@ Configuration
177
- protected static class Empty {
175
+ protected static class Empty implements SmartApplicationListener {
178
176
private List <ApplicationEvent > events = new ArrayList <ApplicationEvent >();
179
177
180
- @ EventListener (EnvironmentChangeEvent .class )
181
- public void changed (EnvironmentChangeEvent event ) {
182
- this .events .add (event );
178
+
179
+ @ Override
180
+ public boolean supportsEventType (Class <? extends ApplicationEvent > eventType ) {
181
+ return EnvironmentChangeEvent .class .isAssignableFrom (eventType )
182
+ || RefreshScopeRefreshedEvent .class .isAssignableFrom (eventType );
183
183
}
184
184
185
- @ EventListener (RefreshScopeRefreshedEvent .class )
186
- public void refreshed (RefreshScopeRefreshedEvent event ) {
187
- this .events .add (event );
185
+ @ Override
186
+ public void onApplicationEvent (ApplicationEvent event ) {
187
+ if (event instanceof EnvironmentChangeEvent ||
188
+ event instanceof RefreshScopeRefreshedEvent ) {
189
+ this .events .add (event );
190
+ }
188
191
}
189
192
}
190
193
0 commit comments