Remove some deprecated API usage, switch to newer JDK api usages, refactor.
This commit is contained in:
@@ -288,7 +288,7 @@ public class BootstrapApplicationListener implements ApplicationListener<Applica
|
||||
if (application.getAllSources().contains(BootstrapMarkerConfiguration.class)) {
|
||||
return;
|
||||
}
|
||||
application.addPrimarySources(Arrays.asList(BootstrapMarkerConfiguration.class));
|
||||
application.addPrimarySources(List.of(BootstrapMarkerConfiguration.class));
|
||||
@SuppressWarnings("rawtypes")
|
||||
Set target = new LinkedHashSet<>(application.getInitializers());
|
||||
target.addAll(getOrderedBeansOfType(context, ApplicationContextInitializer.class));
|
||||
@@ -315,13 +315,12 @@ public class BootstrapApplicationListener implements ApplicationListener<Applica
|
||||
initializers.add(ini);
|
||||
}
|
||||
}
|
||||
ArrayList<ApplicationContextInitializer<?>> target = new ArrayList<ApplicationContextInitializer<?>>(
|
||||
initializers);
|
||||
ArrayList<ApplicationContextInitializer<?>> target = new ArrayList<>(initializers);
|
||||
application.setInitializers(target);
|
||||
}
|
||||
|
||||
private <T> List<T> getOrderedBeansOfType(ListableBeanFactory context, Class<T> type) {
|
||||
List<T> result = new ArrayList<T>();
|
||||
List<T> result = new ArrayList<>();
|
||||
for (String name : context.getBeanNamesForType(type)) {
|
||||
result.add(context.getBean(name, type));
|
||||
}
|
||||
@@ -375,8 +374,7 @@ public class BootstrapApplicationListener implements ApplicationListener<Applica
|
||||
|
||||
private void reorderSources(ConfigurableEnvironment environment) {
|
||||
PropertySource<?> removed = environment.getPropertySources().remove(DEFAULT_PROPERTIES);
|
||||
if (removed instanceof ExtendedDefaultPropertySource) {
|
||||
ExtendedDefaultPropertySource defaultProperties = (ExtendedDefaultPropertySource) removed;
|
||||
if (removed instanceof ExtendedDefaultPropertySource defaultProperties) {
|
||||
environment.getPropertySources()
|
||||
.addLast(new MapPropertySource(DEFAULT_PROPERTIES, defaultProperties.getSource()));
|
||||
for (PropertySource<?> source : defaultProperties.getPropertySources().getPropertySources()) {
|
||||
@@ -428,7 +426,7 @@ public class BootstrapApplicationListener implements ApplicationListener<Applica
|
||||
if (propertySource instanceof MapPropertySource) {
|
||||
return (Map<String, Object>) propertySource.getSource();
|
||||
}
|
||||
return new LinkedHashMap<String, Object>();
|
||||
return new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public CompositePropertySource getPropertySources() {
|
||||
|
||||
@@ -135,10 +135,7 @@ public class BootstrapConfigFileApplicationListener
|
||||
private static final Set<String> LOAD_FILTERED_PROPERTY;
|
||||
|
||||
static {
|
||||
Set<String> filteredProperties = new HashSet<>();
|
||||
filteredProperties.add("spring.profiles.active");
|
||||
filteredProperties.add("spring.profiles.include");
|
||||
LOAD_FILTERED_PROPERTY = Collections.unmodifiableSet(filteredProperties);
|
||||
LOAD_FILTERED_PROPERTY = Set.of("spring.profiles.active", "spring.profiles.include");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,8 +47,7 @@ public class BootstrapPropertySource<T> extends EnumerablePropertySource<T> {
|
||||
|
||||
@Override
|
||||
public String[] getPropertyNames() {
|
||||
Set<String> names = new LinkedHashSet<>();
|
||||
names.addAll(Arrays.asList(this.delegate.getPropertyNames()));
|
||||
Set<String> names = new LinkedHashSet<>(Arrays.asList(this.delegate.getPropertyNames()));
|
||||
|
||||
return StringUtils.toStringArray(names);
|
||||
}
|
||||
|
||||
@@ -98,8 +98,7 @@ public class PropertySourceBootstrapConfiguration
|
||||
}
|
||||
List<PropertySource<?>> sourceList = new ArrayList<>();
|
||||
for (PropertySource<?> p : source) {
|
||||
if (p instanceof EnumerablePropertySource) {
|
||||
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) p;
|
||||
if (p instanceof EnumerablePropertySource<?> enumerable) {
|
||||
sourceList.add(new BootstrapPropertySource<>(enumerable));
|
||||
}
|
||||
else {
|
||||
@@ -153,7 +152,7 @@ public class PropertySourceBootstrapConfiguration
|
||||
rebinder.setEnvironment(environment);
|
||||
// We can't fire the event in the ApplicationContext here (too early), but we can
|
||||
// create our own listener and poke it (it doesn't need the key changes)
|
||||
rebinder.onApplicationEvent(new EnvironmentChangeEvent(applicationContext, Collections.<String>emptySet()));
|
||||
rebinder.onApplicationEvent(new EnvironmentChangeEvent(applicationContext, Collections.emptySet()));
|
||||
}
|
||||
|
||||
private void insertPropertySources(MutablePropertySources propertySources, List<PropertySource<?>> composite) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.cloud.bootstrap.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -52,7 +51,7 @@ public interface PropertySourceLocator {
|
||||
if (propertySource == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (CompositePropertySource.class.isInstance(propertySource)) {
|
||||
if (propertySource instanceof CompositePropertySource) {
|
||||
Collection<PropertySource<?>> sources = ((CompositePropertySource) propertySource).getPropertySources();
|
||||
List<PropertySource<?>> filteredSources = new ArrayList<>();
|
||||
for (PropertySource<?> p : sources) {
|
||||
@@ -63,7 +62,7 @@ public interface PropertySourceLocator {
|
||||
return filteredSources;
|
||||
}
|
||||
else {
|
||||
return Arrays.asList(propertySource);
|
||||
return List.of(propertySource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,11 +94,10 @@ public abstract class AbstractEnvironmentDecrypt {
|
||||
}
|
||||
|
||||
}
|
||||
else if (source instanceof EnumerablePropertySource) {
|
||||
else if (source instanceof EnumerablePropertySource<?> enumerable) {
|
||||
Map<String, Object> otherCollectionProperties = new LinkedHashMap<>();
|
||||
boolean sourceHasDecryptedCollection = false;
|
||||
|
||||
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
|
||||
for (String key : enumerable.getPropertyNames()) {
|
||||
Object property = source.getProperty(key);
|
||||
if (property != null) {
|
||||
|
||||
@@ -113,8 +113,7 @@ public class EnvironmentDecryptApplicationInitializer extends AbstractEnvironmen
|
||||
private void insert(ApplicationContext applicationContext, PropertySource<?> propertySource) {
|
||||
ApplicationContext parent = applicationContext;
|
||||
while (parent != null) {
|
||||
if (parent.getEnvironment() instanceof ConfigurableEnvironment) {
|
||||
ConfigurableEnvironment mutable = (ConfigurableEnvironment) parent.getEnvironment();
|
||||
if (parent.getEnvironment() instanceof ConfigurableEnvironment mutable) {
|
||||
insert(mutable.getPropertySources(), propertySource);
|
||||
}
|
||||
parent = parent.getParent();
|
||||
|
||||
@@ -35,8 +35,7 @@ public class OriginTrackedCompositePropertySource extends CompositePropertySourc
|
||||
@SuppressWarnings("unchecked")
|
||||
public Origin getOrigin(String name) {
|
||||
for (PropertySource<?> propertySource : getPropertySources()) {
|
||||
if (propertySource instanceof OriginLookup) {
|
||||
OriginLookup lookup = (OriginLookup) propertySource;
|
||||
if (propertySource instanceof OriginLookup lookup) {
|
||||
Origin origin = lookup.getOrigin(name);
|
||||
if (origin != null) {
|
||||
return origin;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class EnvironmentManager implements ApplicationEventPublisherAware {
|
||||
|
||||
private static final String MANAGER_PROPERTY_SOURCE = "manager";
|
||||
|
||||
private Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
private Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class EnvironmentManager implements ApplicationEventPublisherAware {
|
||||
|
||||
@ManagedOperation
|
||||
public Map<String, Object> reset() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>(this.map);
|
||||
Map<String, Object> result = new LinkedHashMap<>(this.map);
|
||||
if (!this.map.isEmpty()) {
|
||||
this.map.clear();
|
||||
publish(new EnvironmentChangeEvent(this.publisher, result.keySet()));
|
||||
|
||||
@@ -57,9 +57,7 @@ public class ConfigurationPropertiesBeans implements BeanPostProcessor, Applicat
|
||||
this.beanFactory = (ConfigurableListableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
|
||||
}
|
||||
if (applicationContext.getParent() != null && applicationContext.getParent()
|
||||
.getAutowireCapableBeanFactory() instanceof ConfigurableListableBeanFactory) {
|
||||
ConfigurableListableBeanFactory listable = (ConfigurableListableBeanFactory) applicationContext.getParent()
|
||||
.getAutowireCapableBeanFactory();
|
||||
.getAutowireCapableBeanFactory() instanceof ConfigurableListableBeanFactory listable) {
|
||||
String[] names = listable.getBeanNamesForType(ConfigurationPropertiesBeans.class);
|
||||
if (names.length == 1) {
|
||||
this.parent = (ConfigurationPropertiesBeans) listable.getBean(names[0]);
|
||||
@@ -105,7 +103,7 @@ public class ConfigurationPropertiesBeans implements BeanPostProcessor, Applicat
|
||||
}
|
||||
|
||||
public Set<String> getBeanNames() {
|
||||
return new HashSet<String>(this.beans.keySet());
|
||||
return new HashSet<>(this.beans.keySet());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public abstract class ContextRefresher {
|
||||
}
|
||||
|
||||
private Map<String, Object> changes(Map<String, Object> before, Map<String, Object> after) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
for (String key : before.keySet()) {
|
||||
if (!after.containsKey(key)) {
|
||||
result.put(key, null);
|
||||
@@ -162,8 +162,8 @@ public abstract class ContextRefresher {
|
||||
}
|
||||
|
||||
private Map<String, Object> extract(MutablePropertySources propertySources) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
List<PropertySource<?>> sources = new ArrayList<PropertySource<?>>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<PropertySource<?>> sources = new ArrayList<>();
|
||||
for (PropertySource<?> source : propertySources) {
|
||||
sources.add(0, source);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public abstract class ContextRefresher {
|
||||
private void extract(PropertySource<?> parent, Map<String, Object> result) {
|
||||
if (parent instanceof CompositePropertySource) {
|
||||
try {
|
||||
List<PropertySource<?>> sources = new ArrayList<PropertySource<?>>();
|
||||
List<PropertySource<?>> sources = new ArrayList<>();
|
||||
for (PropertySource<?> source : ((CompositePropertySource) parent).getPropertySources()) {
|
||||
sources.add(0, source);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class RestartEndpoint implements ApplicationListener<ApplicationPreparedE
|
||||
|
||||
@Override
|
||||
public void initialize(GenericApplicationContext context) {
|
||||
context.registerBean(PostProcessor.class, () -> new PostProcessor());
|
||||
context.registerBean(PostProcessor.class, PostProcessor::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class GenericScope
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
List<Throwable> errors = new ArrayList<Throwable>();
|
||||
List<Throwable> errors = new ArrayList<>();
|
||||
Collection<BeanLifecycleWrapper> wrappers = this.cache.clear();
|
||||
for (BeanLifecycleWrapper wrapper : wrappers) {
|
||||
try {
|
||||
@@ -243,8 +243,7 @@ public class GenericScope
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
|
||||
for (String name : registry.getBeanDefinitionNames()) {
|
||||
BeanDefinition definition = registry.getBeanDefinition(name);
|
||||
if (definition instanceof RootBeanDefinition) {
|
||||
RootBeanDefinition root = (RootBeanDefinition) definition;
|
||||
if (definition instanceof RootBeanDefinition root) {
|
||||
if (root.getDecoratedDefinition() != null && root.hasBeanClass()
|
||||
&& root.getBeanClass() == ScopedProxyFactoryBean.class) {
|
||||
if (getName().equals(root.getDecoratedDefinition().getBeanDefinition().getScope())) {
|
||||
@@ -321,7 +320,7 @@ public class GenericScope
|
||||
|
||||
public Collection<BeanLifecycleWrapper> clear() {
|
||||
Collection<Object> values = this.cache.clear();
|
||||
Collection<BeanLifecycleWrapper> wrappers = new LinkedHashSet<BeanLifecycleWrapper>();
|
||||
Collection<BeanLifecycleWrapper> wrappers = new LinkedHashSet<>();
|
||||
for (Object object : values) {
|
||||
wrappers.add((BeanLifecycleWrapper) object);
|
||||
}
|
||||
@@ -448,8 +447,7 @@ public class GenericScope
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
super.setBeanFactory(beanFactory);
|
||||
Object proxy = getObject();
|
||||
if (proxy instanceof Advised) {
|
||||
Advised advised = (Advised) proxy;
|
||||
if (proxy instanceof Advised advised) {
|
||||
advised.addAdvice(0, this);
|
||||
}
|
||||
}
|
||||
@@ -479,8 +477,7 @@ public class GenericScope
|
||||
Lock lock = readWriteLock.readLock();
|
||||
lock.lock();
|
||||
try {
|
||||
if (proxy instanceof Advised) {
|
||||
Advised advised = (Advised) proxy;
|
||||
if (proxy instanceof Advised advised) {
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
return ReflectionUtils.invokeMethod(method, advised.getTargetSource().getTarget(),
|
||||
invocation.getArguments());
|
||||
|
||||
@@ -29,14 +29,14 @@ import java.util.concurrent.ConcurrentMap;
|
||||
*/
|
||||
public class StandardScopeCache implements ScopeCache {
|
||||
|
||||
private final ConcurrentMap<String, Object> cache = new ConcurrentHashMap<String, Object>();
|
||||
private final ConcurrentMap<String, Object> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public Object remove(String name) {
|
||||
return this.cache.remove(name);
|
||||
}
|
||||
|
||||
public Collection<Object> clear() {
|
||||
Collection<Object> values = new ArrayList<Object>(this.cache.values());
|
||||
Collection<Object> values = new ArrayList<>(this.cache.values());
|
||||
this.cache.clear();
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,7 @@ import org.springframework.cloud.context.scope.ScopeCache;
|
||||
*/
|
||||
public class ThreadLocalScopeCache implements ScopeCache {
|
||||
|
||||
private ThreadLocal<ConcurrentMap<String, Object>> data = new ThreadLocal<ConcurrentMap<String, Object>>() {
|
||||
protected ConcurrentMap<String, Object> initialValue() {
|
||||
return new ConcurrentHashMap<String, Object>();
|
||||
}
|
||||
};
|
||||
private ThreadLocal<ConcurrentMap<String, Object>> data = ThreadLocal.withInitial(ConcurrentHashMap::new);
|
||||
|
||||
public Object remove(String name) {
|
||||
return this.data.get().remove(name);
|
||||
@@ -41,7 +37,7 @@ public class ThreadLocalScopeCache implements ScopeCache {
|
||||
|
||||
public Collection<Object> clear() {
|
||||
ConcurrentMap<String, Object> map = this.data.get();
|
||||
Collection<Object> values = new ArrayList<Object>(map.values());
|
||||
Collection<Object> values = new ArrayList<>(map.values());
|
||||
map.clear();
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class RefreshScopeHealthIndicator extends AbstractHealthIndicator {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Builder builder) throws Exception {
|
||||
protected void doHealthCheck(Builder builder) {
|
||||
RefreshScope refreshScope = this.scope.getIfAvailable();
|
||||
if (refreshScope != null) {
|
||||
Map<String, Exception> errors = new HashMap<>(refreshScope.getErrors());
|
||||
|
||||
@@ -67,7 +67,7 @@ public class LoggingRebinder implements ApplicationListener<EnvironmentChangeEve
|
||||
Map<String, String> levels = Binder.get(environment).bind("logging.level", STRING_STRING_MAP)
|
||||
.orElseGet(Collections::emptyMap);
|
||||
for (Entry<String, String> entry : levels.entrySet()) {
|
||||
setLogLevel(system, environment, entry.getKey(), entry.getValue().toString());
|
||||
setLogLevel(system, environment, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class CachedRandomPropertySource extends PropertySource<PropertySource> {
|
||||
|
||||
CachedRandomPropertySource(PropertySource randomValuePropertySource, Map<String, Map<String, Object>> cache) {
|
||||
super(NAME, randomValuePropertySource);
|
||||
this.cache = cache;
|
||||
CachedRandomPropertySource.cache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,8 +66,8 @@ public class BootstrapOrderingCustomPropertySourceIntegrationTests {
|
||||
// This is added to bootstrap context as a source in bootstrap.properties
|
||||
protected static class PropertySourceConfiguration implements PropertySourceLocator {
|
||||
|
||||
public static Map<String, Object> MAP = new HashMap<String, Object>(Collections.<String, Object>singletonMap(
|
||||
"custom.foo", "{cipher}6154ca04d4bb6144d672c4e3d750b5147116dd381946d51fa44f8bc25dc256f4"));
|
||||
public static Map<String, Object> MAP = new HashMap<>(Collections.<String, Object>singletonMap("custom.foo",
|
||||
"{cipher}6154ca04d4bb6144d672c4e3d750b5147116dd381946d51fa44f8bc25dc256f4"));
|
||||
|
||||
@Override
|
||||
public PropertySource<?> locate(Environment environment) {
|
||||
|
||||
@@ -60,16 +60,10 @@ public class TestBootstrapConfiguration {
|
||||
|
||||
@Bean
|
||||
public ApplicationContextInitializer<ConfigurableApplicationContext> customInitializer() {
|
||||
return new ApplicationContextInitializer<ConfigurableApplicationContext>() {
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
environment.getPropertySources().addLast(
|
||||
new MapPropertySource("customProperties", Collections.<String, Object>singletonMap("custom.foo",
|
||||
environment.resolvePlaceholders("${spring.application.name:bar}"))));
|
||||
}
|
||||
|
||||
return applicationContext -> {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
environment.getPropertySources().addLast(new MapPropertySource("customProperties", Collections
|
||||
.singletonMap("custom.foo", environment.resolvePlaceholders("${spring.application.name:bar}"))));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.boot.context.properties.bind.Bindable;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.cloud.bootstrap.TestHigherPriorityBootstrapConfiguration;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.CompositePropertySource;
|
||||
@@ -108,12 +107,9 @@ public class BootstrapConfigurationTests {
|
||||
public void bootstrapPropertiesAvailableInInitializer() {
|
||||
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
|
||||
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class)
|
||||
.initializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
// This property is defined in bootstrap.properties
|
||||
then(applicationContext.getEnvironment().getProperty("info.name")).isEqualTo("child");
|
||||
}
|
||||
.initializers(applicationContext -> {
|
||||
// This property is defined in bootstrap.properties
|
||||
then(applicationContext.getEnvironment().getProperty("info.name")).isEqualTo("child");
|
||||
}).run();
|
||||
then(this.context.getEnvironment().getPropertySources()
|
||||
.contains(PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME + "-testBootstrap"))
|
||||
@@ -144,10 +140,9 @@ public class BootstrapConfigurationTests {
|
||||
@Test
|
||||
public void failsOnPropertySource() {
|
||||
System.setProperty("expected.fail", "true");
|
||||
Throwable throwable = Assertions.assertThrows(RuntimeException.class, () -> {
|
||||
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
|
||||
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run();
|
||||
});
|
||||
Throwable throwable = Assertions.assertThrows(RuntimeException.class,
|
||||
() -> this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
|
||||
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run());
|
||||
then(throwable.getMessage().equals("Planned"));
|
||||
}
|
||||
|
||||
@@ -201,8 +196,8 @@ public class BootstrapConfigurationTests {
|
||||
PropertySourceConfiguration.MAP.put("spring.cloud.config.overrideNone", "true");
|
||||
PropertySourceConfiguration.MAP.put("spring.cloud.config.allowOverride", "true");
|
||||
ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
environment.getPropertySources().addLast(
|
||||
new MapPropertySource("last", Collections.<String, Object>singletonMap("bootstrap.foo", "splat")));
|
||||
environment.getPropertySources()
|
||||
.addLast(new MapPropertySource("last", Collections.singletonMap("bootstrap.foo", "splat")));
|
||||
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
|
||||
.properties("spring.cloud.bootstrap.enabled=true").environment(environment)
|
||||
.sources(BareConfiguration.class).run();
|
||||
@@ -415,7 +410,7 @@ public class BootstrapConfigurationTests {
|
||||
// This is added to bootstrap context as a source in bootstrap.properties
|
||||
protected static class PropertySourceConfiguration implements PropertySourceLocator {
|
||||
|
||||
public static Map<String, Object> MAP = new HashMap<String, Object>(
|
||||
public static Map<String, Object> MAP = new HashMap<>(
|
||||
Collections.<String, Object>singletonMap("bootstrap.foo", "bar"));
|
||||
|
||||
private String name;
|
||||
@@ -456,9 +451,9 @@ public class BootstrapConfigurationTests {
|
||||
// This is added to bootstrap context as a source in bootstrap.properties
|
||||
protected static class CompositePropertySourceConfiguration implements PropertySourceLocator {
|
||||
|
||||
public static Map<String, Object> MAP1 = new HashMap<String, Object>();
|
||||
public static Map<String, Object> MAP1 = new HashMap<>();
|
||||
|
||||
public static Map<String, Object> MAP2 = new HashMap<String, Object>();
|
||||
public static Map<String, Object> MAP2 = new HashMap<>();
|
||||
|
||||
public CompositePropertySourceConfiguration() {
|
||||
MAP1.put("list.foo[0]", "hello");
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.bootstrap.encrypt;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -36,7 +36,7 @@ public class EncryptorFactoryTests {
|
||||
@Test
|
||||
public void testWithRsaPrivateKey() throws Exception {
|
||||
String key = StreamUtils.copyToString(new ClassPathResource("/example-test-rsa-private-key").getInputStream(),
|
||||
Charset.forName("ASCII"));
|
||||
StandardCharsets.US_ASCII);
|
||||
|
||||
TextEncryptor encryptor = new EncryptorFactory().create(key);
|
||||
String toEncrypt = "sample text to encrypt";
|
||||
@@ -47,11 +47,11 @@ public class EncryptorFactoryTests {
|
||||
|
||||
@Test
|
||||
public void testWithInvalidRsaPrivateKey() {
|
||||
String key = "-----BEGIN RSA PRIVATE KEY-----\n"
|
||||
+ "MIIEowIBAAKCAQEAwClFgrRa/PUHPIJr9gvIPL6g6Rjp/TVZmVNOf2fL96DYbkj5\n";
|
||||
Assertions.assertThrows(RuntimeException.class, () -> {
|
||||
new EncryptorFactory().create(key);
|
||||
});
|
||||
String key = """
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAwClFgrRa/PUHPIJr9gvIPL6g6Rjp/TVZmVNOf2fL96DYbkj5
|
||||
""";
|
||||
Assertions.assertThrows(RuntimeException.class, () -> new EncryptorFactory().create(key));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class EnvironmentManagerIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void coreWebExtensionAvailable() throws Exception {
|
||||
this.mvc.perform(get(BASE_PATH + "/env/" + UUID.randomUUID().toString())).andExpect(status().isNotFound());
|
||||
this.mvc.perform(get(BASE_PATH + "/env/" + UUID.randomUUID())).andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ConfigurationPropertiesRebinderIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testSimpleProperties() throws Exception {
|
||||
public void testSimpleProperties() {
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
then(this.properties.getCount()).isEqualTo(1);
|
||||
// Change the dynamic property source...
|
||||
@@ -70,7 +70,7 @@ public class ConfigurationPropertiesRebinderIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefreshInParent() throws Exception {
|
||||
public void testRefreshInParent() {
|
||||
then(this.config.getName()).isEqualTo("parent");
|
||||
// Change the dynamic property source...
|
||||
TestPropertyValues.of("config.name=foo").applyTo(this.environment);
|
||||
@@ -81,7 +81,7 @@ public class ConfigurationPropertiesRebinderIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefresh() throws Exception {
|
||||
public void testRefresh() {
|
||||
then(this.properties.getCount()).isEqualTo(1);
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
// Change the dynamic property source...
|
||||
@@ -94,7 +94,7 @@ public class ConfigurationPropertiesRebinderIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefreshByName() throws Exception {
|
||||
public void testRefreshByName() {
|
||||
then(this.properties.getCount()).isEqualTo(1);
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
// Change the dynamic property source...
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ConfigurationPropertiesRebinderLifecycleIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefresh() throws Exception {
|
||||
public void testRefresh() {
|
||||
then(this.properties.getCount()).isEqualTo(0);
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
// Change the dynamic property source...
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ConfigurationPropertiesRebinderProxyIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testAppendProperties() throws Exception {
|
||||
public void testAppendProperties() {
|
||||
// This comes out as a String not Integer if the rebinder processes the proxy
|
||||
// instead of the target
|
||||
then(this.properties.getExpiry().get("one")).isEqualTo(new Integer(168));
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ConfigurationPropertiesRebinderRefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testSimpleProperties() throws Exception {
|
||||
public void testSimpleProperties() {
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
// Change the dynamic property source...
|
||||
TestPropertyValues.of("message:Foo").applyTo(this.environment);
|
||||
@@ -65,7 +65,7 @@ public class ConfigurationPropertiesRebinderRefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefresh() throws Exception {
|
||||
public void testRefresh() {
|
||||
then(this.properties.getCount()).isEqualTo(1);
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
then(this.properties.getCount()).isEqualTo(1);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ContextRefresherIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testSimpleProperties() throws Exception {
|
||||
public void testSimpleProperties() {
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
// Change the dynamic property source...
|
||||
this.properties.setMessage("Foo");
|
||||
@@ -58,7 +58,7 @@ public class ContextRefresherIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefreshBean() throws Exception {
|
||||
public void testRefreshBean() {
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
// Change the dynamic property source...
|
||||
this.properties.setMessage("Foo");
|
||||
@@ -69,7 +69,7 @@ public class ContextRefresherIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testUpdateHikari() throws Exception {
|
||||
public void testUpdateHikari() {
|
||||
then(this.properties.getMessage()).isEqualTo("Hello scope!");
|
||||
TestPropertyValues.of("spring.datasource.hikari.read-only=true").applyTo(this.environment);
|
||||
// ...and then refresh, so the bean is re-initialized:
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RestartIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestartTwice() throws Exception {
|
||||
public void testRestartTwice() {
|
||||
|
||||
this.context = SpringApplication.run(TestConfiguration.class, "--management.endpoint.restart.enabled=true",
|
||||
"--server.port=0", "--spring.cloud.bootstrap.enabled=true",
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ImportRefreshScopeIntegrationTests {
|
||||
private ExampleService service;
|
||||
|
||||
@Test
|
||||
public void testSimpleProperties() throws Exception {
|
||||
public void testSimpleProperties() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
then(this.beanFactory.getBeanDefinition(ScopedProxyUtils.getTargetBeanName("service")).getScope())
|
||||
.isEqualTo("refresh");
|
||||
|
||||
@@ -68,7 +68,7 @@ public class MoreRefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testSimpleProperties() throws Exception {
|
||||
public void testSimpleProperties() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
then(this.service instanceof Advised).isTrue();
|
||||
// Change the dynamic property source...
|
||||
@@ -81,7 +81,7 @@ public class MoreRefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefresh() throws Exception {
|
||||
public void testRefresh() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
String id1 = this.service.toString();
|
||||
// Change the dynamic property source...
|
||||
@@ -98,7 +98,7 @@ public class MoreRefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefreshFails() throws Exception {
|
||||
public void testRefreshFails() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
// Change the dynamic property source...
|
||||
TestPropertyValues.of("message:Foo", "delay:foo").applyTo(this.environment);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.context.scope.refresh;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -72,17 +71,14 @@ public class RefreshScopeConcurrencyTests {
|
||||
this.properties.setMessage("Foo");
|
||||
this.properties.setDelay(500);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
Future<String> result = this.executor.submit(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopeConcurrencyTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
Future<String> result = this.executor.submit(() -> {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopeConcurrencyTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
});
|
||||
then(latch.await(15000, TimeUnit.MILLISECONDS)).isTrue();
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.context.scope.refresh;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -81,25 +80,19 @@ public class RefreshScopeConfigurationScaleTests {
|
||||
final CountDownLatch latch = new CountDownLatch(n);
|
||||
List<Future<String>> results = new ArrayList<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
results.add(this.executor.submit(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopeConfigurationScaleTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
results.add(this.executor.submit(() -> {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopeConfigurationScaleTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
}));
|
||||
this.executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug("Refreshing.");
|
||||
RefreshScopeConfigurationScaleTests.this.scope.refreshAll();
|
||||
}
|
||||
this.executor.submit(() -> {
|
||||
logger.debug("Refreshing.");
|
||||
RefreshScopeConfigurationScaleTests.this.scope.refreshAll();
|
||||
});
|
||||
}
|
||||
then(latch.await(15000, TimeUnit.MILLISECONDS)).isTrue();
|
||||
|
||||
@@ -63,7 +63,7 @@ public class RefreshScopeConfigurationTests {
|
||||
* See gh-43
|
||||
*/
|
||||
@Test
|
||||
public void configurationWithRefreshScope() throws Exception {
|
||||
public void configurationWithRefreshScope() {
|
||||
this.context = new AnnotationConfigApplicationContext(Application.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, RefreshAutoConfiguration.class,
|
||||
LifecycleMvcEndpointAutoConfiguration.class);
|
||||
@@ -77,7 +77,7 @@ public class RefreshScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshScopeOnBean() throws Exception {
|
||||
public void refreshScopeOnBean() {
|
||||
this.context = new AnnotationConfigApplicationContext(ClientApp.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, RefreshAutoConfiguration.class,
|
||||
LifecycleMvcEndpointAutoConfiguration.class);
|
||||
@@ -89,7 +89,7 @@ public class RefreshScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshScopeOnNested() throws Exception {
|
||||
public void refreshScopeOnNested() {
|
||||
this.context = new AnnotationConfigApplicationContext(NestedApp.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, RefreshAutoConfiguration.class,
|
||||
LifecycleMvcEndpointAutoConfiguration.class);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class RefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testSimpleProperties() throws Exception {
|
||||
public void testSimpleProperties() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
then(this.service instanceof Advised).isTrue();
|
||||
// Change the dynamic property source...
|
||||
@@ -81,7 +81,7 @@ public class RefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefresh() throws Exception {
|
||||
public void testRefresh() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
String id1 = this.service.toString();
|
||||
// Change the dynamic property source...
|
||||
@@ -99,7 +99,7 @@ public class RefreshScopeIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefreshBean() throws Exception {
|
||||
public void testRefreshBean() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
String id1 = this.service.toString();
|
||||
// Change the dynamic property source...
|
||||
@@ -120,9 +120,7 @@ public class RefreshScopeIntegrationTests {
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testCheckedException() {
|
||||
Assertions.assertThrows(ServiceException.class, () -> {
|
||||
this.service.throwsException();
|
||||
});
|
||||
Assertions.assertThrows(ServiceException.class, () -> this.service.throwsException());
|
||||
}
|
||||
|
||||
public interface Service {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RefreshScopeLazyIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testSimpleProperties() throws Exception {
|
||||
public void testSimpleProperties() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
then(this.service instanceof Advised).isTrue();
|
||||
// Change the dynamic property source...
|
||||
@@ -83,7 +83,7 @@ public class RefreshScopeLazyIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefresh() throws Exception {
|
||||
public void testRefresh() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
String id1 = this.service.toString();
|
||||
// Change the dynamic property source...
|
||||
@@ -101,7 +101,7 @@ public class RefreshScopeLazyIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testRefreshBean() throws Exception {
|
||||
public void testRefreshBean() {
|
||||
then(this.service.getMessage()).isEqualTo("Hello scope!");
|
||||
String id1 = this.service.toString();
|
||||
// Change the dynamic property source...
|
||||
|
||||
@@ -56,7 +56,7 @@ public class RefreshScopeListBindingIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testAppendProperties() throws Exception {
|
||||
public void testAppendProperties() {
|
||||
then("[one, two]").isEqualTo(this.properties.getMessages().toString());
|
||||
then(this.properties instanceof Advised).isTrue();
|
||||
TestPropertyValues.of("test.messages[0]:foo").applyTo(this.environment);
|
||||
@@ -66,7 +66,7 @@ public class RefreshScopeListBindingIntegrationTests {
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void testReplaceProperties() throws Exception {
|
||||
public void testReplaceProperties() {
|
||||
then("[one, two]").isEqualTo(this.properties.getMessages().toString());
|
||||
then(this.properties instanceof Advised).isTrue();
|
||||
Map<String, Object> map = findTestProperties();
|
||||
@@ -104,7 +104,7 @@ public class RefreshScopeListBindingIntegrationTests {
|
||||
@ManagedResource
|
||||
protected static class TestProperties {
|
||||
|
||||
private List<String> messages = new ArrayList<String>();
|
||||
private List<String> messages = new ArrayList<>();
|
||||
|
||||
public List<String> getMessages() {
|
||||
return this.messages;
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.context.scope.refresh;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -72,25 +71,19 @@ public class RefreshScopePureScaleTests {
|
||||
final CountDownLatch latch = new CountDownLatch(n);
|
||||
List<Future<String>> results = new ArrayList<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
results.add(this.executor.submit(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopePureScaleTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
results.add(this.executor.submit(() -> {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopePureScaleTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
}));
|
||||
this.executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug("Refreshing.");
|
||||
RefreshScopePureScaleTests.this.scope.refreshAll();
|
||||
}
|
||||
this.executor.submit(() -> {
|
||||
logger.debug("Refreshing.");
|
||||
RefreshScopePureScaleTests.this.scope.refreshAll();
|
||||
});
|
||||
}
|
||||
then(latch.await(15000, TimeUnit.MILLISECONDS)).isTrue();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.context.scope.refresh;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -77,17 +76,14 @@ public class RefreshScopeScaleTests {
|
||||
final CountDownLatch latch = new CountDownLatch(n);
|
||||
Future<String> result = null;
|
||||
for (int i = 0; i < n; i++) {
|
||||
result = this.executor.submit(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopeScaleTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
result = this.executor.submit(() -> {
|
||||
logger.debug("Background started.");
|
||||
try {
|
||||
return RefreshScopeScaleTests.this.service.getMessage();
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
logger.debug("Background done.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
public class RefreshScopeSerializationTests {
|
||||
|
||||
@Test
|
||||
public void defaultApplicationContextId() throws Exception {
|
||||
public void defaultApplicationContextId() {
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestConfiguration.class)
|
||||
.properties("spring.cloud.bootstrap.enabled=true").web(WebApplicationType.NONE).run();
|
||||
then(context.getId()).isEqualTo("application-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializationIdReproducible() throws Exception {
|
||||
public void serializationIdReproducible() {
|
||||
String first = getBeanFactory().getSerializationId();
|
||||
String second = getBeanFactory().getSerializationId();
|
||||
then(first).isNotNull();
|
||||
|
||||
@@ -55,13 +55,13 @@ public class RefreshScopeWebIntegrationTests {
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
@Test
|
||||
public void scopeOnBeanDefinition() throws Exception {
|
||||
public void scopeOnBeanDefinition() {
|
||||
then(this.beanFactory.getBeanDefinition(ScopedProxyUtils.getTargetBeanName("application")).getScope())
|
||||
.isEqualTo("refresh");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanAccess() throws Exception {
|
||||
public void beanAccess() {
|
||||
this.application.hello();
|
||||
this.environmentManager.setProperty("message", "Hello Dave!");
|
||||
this.scope.refreshAll();
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RefreshEndpointTests {
|
||||
|
||||
@Test
|
||||
@Disabled // FIXME: legacy
|
||||
public void keysComputedWhenAdded() throws Exception {
|
||||
public void keysComputedWhenAdded() {
|
||||
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
|
||||
.properties("spring.cloud.bootstrap.enabled=true", "spring.cloud.bootstrap.name:none").run();
|
||||
RefreshScope scope = new RefreshScope();
|
||||
@@ -84,7 +84,7 @@ public class RefreshEndpointTests {
|
||||
|
||||
@Test
|
||||
@Disabled // FIXME: legacy
|
||||
public void keysComputedWhenOveridden() throws Exception {
|
||||
public void keysComputedWhenOveridden() {
|
||||
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
|
||||
.properties("spring.cloud.bootstrap.enabled=true", "spring.cloud.bootstrap.name:none").run();
|
||||
RefreshScope scope = new RefreshScope();
|
||||
@@ -97,7 +97,7 @@ public class RefreshEndpointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keysComputedWhenChangesInExternalProperties() throws Exception {
|
||||
public void keysComputedWhenChangesInExternalProperties() {
|
||||
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
|
||||
.properties("spring.cloud.bootstrap.name:none", "spring.cloud.bootstrap.enabled=true").run();
|
||||
RefreshScope scope = new RefreshScope();
|
||||
@@ -111,7 +111,7 @@ public class RefreshEndpointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springMainSourcesEmptyInRefreshCycle() throws Exception {
|
||||
public void springMainSourcesEmptyInRefreshCycle() {
|
||||
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
|
||||
.properties("spring.cloud.bootstrap.name:none").run();
|
||||
RefreshScope scope = new RefreshScope();
|
||||
@@ -128,7 +128,7 @@ public class RefreshEndpointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventsPublishedInOrder() throws Exception {
|
||||
public void eventsPublishedInOrder() {
|
||||
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
|
||||
.run();
|
||||
RefreshScope scope = new RefreshScope();
|
||||
@@ -170,7 +170,7 @@ public class RefreshEndpointTests {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
protected static class Empty implements SmartApplicationListener {
|
||||
|
||||
private List<ApplicationEvent> events = new ArrayList<ApplicationEvent>();
|
||||
private List<ApplicationEvent> events = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
|
||||
@@ -192,8 +192,7 @@ public class RefreshEndpointTests {
|
||||
|
||||
@Override
|
||||
public PropertySource<?> locate(Environment environment) {
|
||||
return new MapPropertySource("external",
|
||||
Collections.<String, Object>singletonMap("external.message", "I'm External"));
|
||||
return new MapPropertySource("external", Collections.singletonMap("external.message", "I'm External"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CachedRandomPropertySourceTests {
|
||||
|
||||
private HashMap<String, Map<String, Object>> createCache(HashMap<String, AtomicInteger> keyCount,
|
||||
HashMap<Map<String, Object>, String> typeToKeyLookup, HashMap<String, AtomicInteger> typeCount) {
|
||||
return new HashMap<String, Map<String, Object>>() {
|
||||
return new HashMap<>() {
|
||||
@Override
|
||||
public Map<String, Object> computeIfAbsent(String key,
|
||||
Function<? super String, ? extends Map<String, Object>> mappingFunction) {
|
||||
@@ -96,7 +96,7 @@ public class CachedRandomPropertySourceTests {
|
||||
|
||||
private HashMap<String, Object> createTypeCache(HashMap<Map<String, Object>, String> typeToKeyLookup,
|
||||
HashMap<String, AtomicInteger> typeCount) {
|
||||
return new HashMap<String, Object>() {
|
||||
return new HashMap<>() {
|
||||
@Override
|
||||
public Object computeIfAbsent(String key, Function<? super String, ?> mappingFunction) {
|
||||
if (!containsKey(key)) {
|
||||
|
||||
Reference in New Issue
Block a user