Creates RefreshListener even if actuator not on classpath.
fixes gh-105
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -125,6 +125,11 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-test-support</artifactId>
|
||||
<version>${spring-cloud-commons.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-dependencies</artifactId>
|
||||
|
||||
@@ -49,6 +49,11 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-test-support</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-test-support</artifactId>
|
||||
|
||||
@@ -176,18 +176,19 @@ public class BusAutoConfiguration implements ApplicationEventPublisherAware {
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.refresh.enabled", matchIfMissing = true)
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
public RefreshListener refreshListener(ContextRefresher contextRefresher) {
|
||||
return new RefreshListener(contextRefresher);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Endpoint.class, RefreshScope.class })
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
protected static class BusRefreshConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.refresh.enabled", matchIfMissing = true)
|
||||
public RefreshListener refreshListener(ContextRefresher contextRefresher) {
|
||||
return new RefreshListener(contextRefresher);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
@ConditionalOnProperty(value = "endpoints.spring.cloud.bus.refresh.enabled", matchIfMissing = true)
|
||||
protected static class BusRefreshEndpointConfiguration {
|
||||
@Bean
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.springframework.cloud.bus;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
|
||||
import org.springframework.cloud.bus.endpoint.RefreshBusEndpoint;
|
||||
import org.springframework.cloud.bus.event.RefreshListener;
|
||||
import org.springframework.cloud.test.ClassPathExclusions;
|
||||
import org.springframework.cloud.test.ModifiedClassPathRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@RunWith(ModifiedClassPathRunner.class)
|
||||
@ClassPathExclusions({"spring-boot-actuator-*.jar", "spring-boot-starter-actuator-*.jar"})
|
||||
public class BusAutoConfigurationClassPathTests {
|
||||
|
||||
@Test
|
||||
public void refreshListenerCreatedWithoutActuator() {
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class,
|
||||
BusAutoConfiguration.class))
|
||||
.run(context -> assertThat(context)
|
||||
.hasSingleBean(RefreshListener.class)
|
||||
.doesNotHaveBean(RefreshBusEndpoint.class));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user