|
|
@ -16,10 +16,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.cloud.endpoint; |
|
|
|
package org.springframework.cloud.endpoint; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
@ -28,8 +24,8 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.After; |
|
|
|
import org.junit.After; |
|
|
|
import org.junit.Ignore; |
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.Banner.Mode; |
|
|
|
import org.springframework.boot.Banner.Mode; |
|
|
|
import org.springframework.boot.WebApplicationType; |
|
|
|
import org.springframework.boot.WebApplicationType; |
|
|
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
|
|
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
|
|
@ -43,7 +39,7 @@ import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEven |
|
|
|
import org.springframework.context.ApplicationEvent; |
|
|
|
import org.springframework.context.ApplicationEvent; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.event.EventListener; |
|
|
|
import org.springframework.context.event.SmartApplicationListener; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.env.MapPropertySource; |
|
|
|
import org.springframework.core.env.MapPropertySource; |
|
|
|
import org.springframework.core.env.PropertySource; |
|
|
|
import org.springframework.core.env.PropertySource; |
|
|
@ -51,6 +47,10 @@ import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
import org.springframework.util.ReflectionUtils; |
|
|
|
import org.springframework.util.ReflectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Dave Syer |
|
|
|
* @author Dave Syer |
|
|
|
* @author Venil Noronha |
|
|
|
* @author Venil Noronha |
|
|
@ -132,7 +132,6 @@ public class RefreshEndpointTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@Ignore //FIXME: 2.1.0
|
|
|
|
|
|
|
|
public void eventsPublishedInOrder() throws Exception { |
|
|
|
public void eventsPublishedInOrder() throws Exception { |
|
|
|
this.context = new SpringApplicationBuilder(Empty.class) |
|
|
|
this.context = new SpringApplicationBuilder(Empty.class) |
|
|
|
.web(WebApplicationType.NONE).bannerMode(Mode.OFF).run(); |
|
|
|
.web(WebApplicationType.NONE).bannerMode(Mode.OFF).run(); |
|
|
@ -148,7 +147,6 @@ public class RefreshEndpointTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@Ignore //FIXME: 2.1.0
|
|
|
|
|
|
|
|
public void shutdownHooksCleaned() { |
|
|
|
public void shutdownHooksCleaned() { |
|
|
|
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(Empty.class) |
|
|
|
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(Empty.class) |
|
|
|
.web(WebApplicationType.NONE).bannerMode(Mode.OFF).run()) { |
|
|
|
.web(WebApplicationType.NONE).bannerMode(Mode.OFF).run()) { |
|
|
@ -174,19 +172,24 @@ public class RefreshEndpointTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
protected static class Empty { |
|
|
|
protected static class Empty implements SmartApplicationListener { |
|
|
|
private List<ApplicationEvent> events = new ArrayList<ApplicationEvent>(); |
|
|
|
private List<ApplicationEvent> events = new ArrayList<ApplicationEvent>(); |
|
|
|
|
|
|
|
|
|
|
|
@EventListener(EnvironmentChangeEvent.class) |
|
|
|
|
|
|
|
public void changed(EnvironmentChangeEvent event) { |
|
|
|
@Override |
|
|
|
this.events.add(event); |
|
|
|
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { |
|
|
|
|
|
|
|
return EnvironmentChangeEvent.class.isAssignableFrom(eventType) |
|
|
|
|
|
|
|
|| RefreshScopeRefreshedEvent.class.isAssignableFrom(eventType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@EventListener(RefreshScopeRefreshedEvent.class) |
|
|
|
@Override |
|
|
|
public void refreshed(RefreshScopeRefreshedEvent event) { |
|
|
|
public void onApplicationEvent(ApplicationEvent event) { |
|
|
|
|
|
|
|
if (event instanceof EnvironmentChangeEvent || |
|
|
|
|
|
|
|
event instanceof RefreshScopeRefreshedEvent) { |
|
|
|
this.events.add(event); |
|
|
|
this.events.add(event); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
@Component |
|
|
|
protected static class ExternalPropertySourceLocator |
|
|
|
protected static class ExternalPropertySourceLocator |
|
|
|