Remove some deprecated API usage, switch to newer JDK api usages, refactor.

This commit is contained in:
Olga Maciaszek-Sharma
2022-11-08 13:57:03 +01:00
parent 6f39b7ed22
commit efe5131a36
106 changed files with 279 additions and 410 deletions

View File

@@ -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) {

View File

@@ -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}"))));
};
}

View File

@@ -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");

View File

@@ -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));
}
}

View File

@@ -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

View File

@@ -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...

View File

@@ -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...

View File

@@ -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));

View File

@@ -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);

View File

@@ -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:

View File

@@ -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",

View File

@@ -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");

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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...

View File

@@ -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;

View File

@@ -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();

View File

@@ -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.");
}
});
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -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"));
}
}

View File

@@ -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)) {