File tree 3 files changed +18
-8
lines changed
main/java/org/springframework/cloud/autoconfigure
test/java/org/springframework/cloud/autoconfigure
3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 26
26
import org .springframework .boot .autoconfigure .AutoConfigureAfter ;
27
27
import org .springframework .boot .autoconfigure .condition .ConditionalOnClass ;
28
28
import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
29
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
29
30
import org .springframework .boot .autoconfigure .web .WebMvcAutoConfiguration ;
30
31
import org .springframework .cloud .context .environment .EnvironmentManager ;
31
32
import org .springframework .cloud .context .refresh .ContextRefresher ;
47
48
*/
48
49
@ Configuration
49
50
@ ConditionalOnClass (RefreshScope .class )
51
+ @ ConditionalOnProperty (name = "spring.cloud.refresh.enabled" , matchIfMissing = true )
50
52
@ AutoConfigureAfter (WebMvcAutoConfiguration .class )
51
53
public class RefreshAutoConfiguration {
52
54
Original file line number Diff line number Diff line change 44
44
*/
45
45
@ Configuration
46
46
@ ConditionalOnClass (Endpoint .class )
47
- @ AutoConfigureAfter (EndpointAutoConfiguration .class )
47
+ @ AutoConfigureAfter ({ EndpointAutoConfiguration .class , RefreshAutoConfiguration . class } )
48
48
public class RefreshEndpointAutoConfiguration {
49
49
50
+ @ Bean
51
+ @ ConditionalOnBean (RefreshScope .class )
50
52
@ ConditionalOnMissingBean
51
53
@ ConditionalOnEnabledHealthIndicator ("refresh" )
52
- @ Bean
53
54
RefreshScopeHealthIndicator refreshScopeHealthIndicator (RefreshScope scope ,
54
55
ConfigurationPropertiesRebinder rebinder ) {
55
56
return new RefreshScopeHealthIndicator (scope , rebinder );
@@ -113,6 +114,7 @@ public RestartEndpoint.ResumeEndpoint resumeEndpoint(
113
114
protected static class RefreshEndpointConfiguration {
114
115
115
116
@ Bean
117
+ @ ConditionalOnBean (ContextRefresher .class )
116
118
@ ConditionalOnMissingBean
117
119
public RefreshEndpoint refreshEndpoint (ContextRefresher contextRefresher ) {
118
120
RefreshEndpoint endpoint = new RefreshEndpoint (contextRefresher );
Original file line number Diff line number Diff line change 9
9
import org .springframework .context .ConfigurableApplicationContext ;
10
10
import org .springframework .context .annotation .Configuration ;
11
11
12
- import static org .hamcrest .CoreMatchers .containsString ;
13
- import static org .hamcrest .CoreMatchers .not ;
14
- import static org .junit .Assert .assertThat ;
15
- import static org .junit .Assert .assertTrue ;
12
+ import static org .assertj .core .api .Assertions .assertThat ;
13
+
16
14
17
15
/**
18
16
* @author Dave Syer
@@ -26,8 +24,16 @@ public class RefreshAutoConfigurationTests {
26
24
public void noWarnings () {
27
25
try (ConfigurableApplicationContext context = getApplicationContext (
28
26
Config .class )) {
29
- assertTrue (context .containsBean ("refreshScope" ));
30
- assertThat (output .toString (), not (containsString ("WARN" )));
27
+ assertThat (context .containsBean ("refreshScope" )).isTrue ();
28
+ assertThat (output .toString ()).doesNotContain ("WARN" );
29
+ }
30
+ }
31
+
32
+ @ Test
33
+ public void disabled () {
34
+ try (ConfigurableApplicationContext context = getApplicationContext (
35
+ Config .class , "spring.cloud.refresh.enabled:false" )) {
36
+ assertThat (context .containsBean ("refreshScope" )).isFalse ();
31
37
}
32
38
}
33
39
You can’t perform that action at this time.
0 commit comments