File tree 3 files changed +17
-8
lines changed
main/java/org/springframework/cloud/autoconfigure
test/java/org/springframework/cloud/autoconfigure 3 files changed +17
-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 .servlet .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
//TODO: support reactive
51
53
@ AutoConfigureAfter (WebMvcAutoConfiguration .class )
52
54
public class RefreshAutoConfiguration {
Original file line number Diff line number Diff line change 45
45
*/
46
46
@ Configuration
47
47
@ ConditionalOnClass (Health .class )
48
- @ AutoConfigureAfter (EndpointAutoConfiguration .class )
48
+ @ AutoConfigureAfter ({ EndpointAutoConfiguration .class , RefreshAutoConfiguration . class } )
49
49
@ Import ({ RestartEndpointWithIntegrationConfiguration .class ,
50
50
RestartEndpointWithoutIntegrationConfiguration .class ,
51
51
PauseResumeEndpointsConfiguration .class })
52
52
public class RefreshEndpointAutoConfiguration {
53
53
54
+ @ Bean
55
+ @ ConditionalOnBean (RefreshScope .class )
54
56
@ ConditionalOnMissingBean
55
57
@ ConditionalOnEnabledHealthIndicator ("refresh" )
56
- @ Bean
57
58
RefreshScopeHealthIndicator refreshScopeHealthIndicator (RefreshScope scope ,
58
59
ConfigurationPropertiesRebinder rebinder ) {
59
60
return new RefreshScopeHealthIndicator (scope , rebinder );
Original file line number Diff line number Diff line change 10
10
import org .springframework .context .ConfigurableApplicationContext ;
11
11
import org .springframework .context .annotation .Configuration ;
12
12
13
- import static org .hamcrest .CoreMatchers .containsString ;
14
- import static org .hamcrest .CoreMatchers .not ;
15
- import static org .junit .Assert .assertThat ;
16
- import static org .junit .Assert .assertTrue ;
13
+ import static org .assertj .core .api .Assertions .assertThat ;
14
+
17
15
18
16
/**
19
17
* @author Dave Syer
@@ -27,8 +25,16 @@ public class RefreshAutoConfigurationTests {
27
25
public void noWarnings () {
28
26
try (ConfigurableApplicationContext context = getApplicationContext (
29
27
Config .class )) {
30
- assertTrue (context .containsBean ("refreshScope" ));
31
- assertThat (output .toString (), not (containsString ("WARN" )));
28
+ assertThat (context .containsBean ("refreshScope" )).isTrue ();
29
+ assertThat (output .toString ()).doesNotContain ("WARN" );
30
+ }
31
+ }
32
+
33
+ @ Test
34
+ public void disabled () {
35
+ try (ConfigurableApplicationContext context = getApplicationContext (
36
+ Config .class , "spring.cloud.refresh.enabled:false" )) {
37
+ assertThat (context .containsBean ("refreshScope" )).isFalse ();
32
38
}
33
39
}
34
40
You can’t perform that action at this time.
0 commit comments