Commit cbb48373 authored by Johnny Lim's avatar Johnny Lim Committed by Stephane Nicoll

Polish

Closes gh-10948
parent 2de0247c
...@@ -134,7 +134,7 @@ public class MetricsAutoConfigurationTests { ...@@ -134,7 +134,7 @@ public class MetricsAutoConfigurationTests {
} }
private DataSource createDataSource() { private DataSource createDataSource() {
String url = "jdbc:hsqldb:mem:test-" + UUID.randomUUID().toString(); String url = "jdbc:hsqldb:mem:test-" + UUID.randomUUID();
return DataSourceBuilder.create().url(url).build(); return DataSourceBuilder.create().url(url).build();
} }
......
...@@ -63,15 +63,15 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS ...@@ -63,15 +63,15 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS
@Override @Override
public void bindTo(MeterRegistry registry) { public void bindTo(MeterRegistry registry) {
registerGuage(registry, this.configurer, this.tags, registerGauge(registry, this.configurer, this.tags,
"spring.integration.channelNames", "spring.integration.channelNames",
"The number of spring integration channels", "The number of spring integration channels",
(configurer) -> configurer.getChannelNames().length); (configurer) -> configurer.getChannelNames().length);
registerGuage(registry, this.configurer, this.tags, registerGauge(registry, this.configurer, this.tags,
"spring.integration.handlerNames", "spring.integration.handlerNames",
"The number of spring integration handlers", "The number of spring integration handlers",
(configurer) -> configurer.getHandlerNames().length); (configurer) -> configurer.getHandlerNames().length);
registerGuage(registry, this.configurer, this.tags, registerGauge(registry, this.configurer, this.tags,
"spring.integration.sourceNames", "spring.integration.sourceNames",
"The number of spring integration sources", "The number of spring integration sources",
(configurer) -> configurer.getSourceNames().length); (configurer) -> configurer.getSourceNames().length);
...@@ -105,7 +105,7 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS ...@@ -105,7 +105,7 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS
registerTimedGauge(registry, handlerMetrics, tagsWithHandler, registerTimedGauge(registry, handlerMetrics, tagsWithHandler,
"spring.integration.handler.duration.mean", "spring.integration.handler.duration.mean",
"The mean handler duration", MessageHandlerMetrics::getMeanDuration); "The mean handler duration", MessageHandlerMetrics::getMeanDuration);
registerGuage(registry, handlerMetrics, tagsWithHandler, registerGauge(registry, handlerMetrics, tagsWithHandler,
"spring.integration.handler.activeCount", "spring.integration.handler.activeCount",
"The number of active handlers", "The number of active handlers",
MessageHandlerMetrics::getActiveCount); MessageHandlerMetrics::getActiveCount);
...@@ -133,7 +133,7 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS ...@@ -133,7 +133,7 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS
} }
} }
private <T> void registerGuage(MeterRegistry registry, T object, Iterable<Tag> tags, private <T> void registerGauge(MeterRegistry registry, T object, Iterable<Tag> tags,
String name, String description, ToDoubleFunction<T> value) { String name, String description, ToDoubleFunction<T> value) {
Gauge.Builder<?> builder = Gauge.builder(name, object, value); Gauge.Builder<?> builder = Gauge.builder(name, object, value);
builder.tags(this.tags).description(description).register(registry); builder.tags(this.tags).description(description).register(registry);
......
...@@ -45,7 +45,7 @@ public class HealthTests { ...@@ -45,7 +45,7 @@ public class HealthTests {
public void createWithStatus() throws Exception { public void createWithStatus() throws Exception {
Health health = Health.status(Status.UP).build(); Health health = Health.status(Status.UP).build();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().size()).isEqualTo(0); assertThat(health.getDetails()).isEmpty();
} }
@Test @Test
...@@ -100,7 +100,7 @@ public class HealthTests { ...@@ -100,7 +100,7 @@ public class HealthTests {
public void unknown() throws Exception { public void unknown() throws Exception {
Health health = new Health.Builder().unknown().build(); Health health = new Health.Builder().unknown().build();
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN); assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
assertThat(health.getDetails().size()).isEqualTo(0); assertThat(health.getDetails()).isEmpty();
} }
@Test @Test
...@@ -114,7 +114,7 @@ public class HealthTests { ...@@ -114,7 +114,7 @@ public class HealthTests {
public void up() throws Exception { public void up() throws Exception {
Health health = new Health.Builder().up().build(); Health health = new Health.Builder().up().build();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().size()).isEqualTo(0); assertThat(health.getDetails()).isEmpty();
} }
@Test @Test
...@@ -130,28 +130,28 @@ public class HealthTests { ...@@ -130,28 +130,28 @@ public class HealthTests {
public void down() throws Exception { public void down() throws Exception {
Health health = Health.down().build(); Health health = Health.down().build();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().size()).isEqualTo(0); assertThat(health.getDetails()).isEmpty();
} }
@Test @Test
public void outOfService() throws Exception { public void outOfService() throws Exception {
Health health = Health.outOfService().build(); Health health = Health.outOfService().build();
assertThat(health.getStatus()).isEqualTo(Status.OUT_OF_SERVICE); assertThat(health.getStatus()).isEqualTo(Status.OUT_OF_SERVICE);
assertThat(health.getDetails().size()).isEqualTo(0); assertThat(health.getDetails()).isEmpty();
} }
@Test @Test
public void statusCode() throws Exception { public void statusCode() throws Exception {
Health health = Health.status("UP").build(); Health health = Health.status("UP").build();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().size()).isEqualTo(0); assertThat(health.getDetails()).isEmpty();
} }
@Test @Test
public void status() throws Exception { public void status() throws Exception {
Health health = Health.status(Status.UP).build(); Health health = Health.status(Status.UP).build();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().size()).isEqualTo(0); assertThat(health.getDetails()).isEmpty();
} }
} }
...@@ -50,7 +50,7 @@ public class EnvironmentInfoContributorTests { ...@@ -50,7 +50,7 @@ public class EnvironmentInfoContributorTests {
public void extractNoEntry() { public void extractNoEntry() {
TestPropertyValues.of("foo=bar").applyTo(this.environment); TestPropertyValues.of("foo=bar").applyTo(this.environment);
Info actual = contributeFrom(this.environment); Info actual = contributeFrom(this.environment);
assertThat(actual.getDetails().size()).isEqualTo(0); assertThat(actual.getDetails()).isEmpty();
} }
@Test @Test
......
...@@ -68,7 +68,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. ...@@ -68,7 +68,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/** /**
* Tests for {@link WebMvcMetricsFilter} * Tests for {@link WebMvcMetricsFilter}.
* *
* @author Jon Schneider * @author Jon Schneider
*/ */
......
...@@ -154,7 +154,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration { ...@@ -154,7 +154,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
private boolean runningOnWebSphere() { private boolean runningOnWebSphere() {
return ClassUtils.isPresent( return ClassUtils.isPresent(
"com.ibm.websphere.jtaextensions." + "ExtendedJTATransaction", "com.ibm.websphere.jtaextensions.ExtendedJTATransaction",
getClass().getClassLoader()); getClass().getClassLoader());
} }
...@@ -175,7 +175,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration { ...@@ -175,7 +175,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
} }
catch (LinkageError ex) { catch (LinkageError ex) {
// NoClassDefFoundError can happen if Hibernate 4.2 is used and some // NoClassDefFoundError can happen if Hibernate 4.2 is used and some
// containers (e.g. JBoss EAP 6) wraps it in the superclass LinkageError // containers (e.g. JBoss EAP 6) wrap it in the superclass LinkageError
if (!isUsingJndi()) { if (!isUsingJndi()) {
throw new IllegalStateException("Unable to set Hibernate JTA " throw new IllegalStateException("Unable to set Hibernate JTA "
+ "platform, are you using the correct " + "platform, are you using the correct "
......
...@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
/** /**
* Tests for {@link DataSourceInitializer}. * Tests for {@link DataSourceInitializerInvoker}.
* *
* @author Dave Syer * @author Dave Syer
* @author Stephane Nicoll * @author Stephane Nicoll
...@@ -61,7 +61,7 @@ public class DataSourceInitializerInvokerTests { ...@@ -61,7 +61,7 @@ public class DataSourceInitializerInvokerTests {
.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class))
.withPropertyValues("spring.datasource.initialization-mode=never", .withPropertyValues("spring.datasource.initialization-mode=never",
"spring.datasource.url:jdbc:hsqldb:mem:init-" "spring.datasource.url:jdbc:hsqldb:mem:init-"
+ UUID.randomUUID().toString()); + UUID.randomUUID());
@Test @Test
public void dataSourceInitialized() { public void dataSourceInitialized() {
......
...@@ -102,7 +102,7 @@ public class DataSourceInitializerTests { ...@@ -102,7 +102,7 @@ public class DataSourceInitializerTests {
private HikariDataSource createDataSource() { private HikariDataSource createDataSource() {
return DataSourceBuilder.create().type(HikariDataSource.class) return DataSourceBuilder.create().type(HikariDataSource.class)
.url("jdbc:h2:mem:" + UUID.randomUUID().toString()).build(); .url("jdbc:h2:mem:" + UUID.randomUUID()).build();
} }
} }
...@@ -113,7 +113,7 @@ public class DataSourceJmxConfigurationTests { ...@@ -113,7 +113,7 @@ public class DataSourceJmxConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
String jdbcUrl = "jdbc:hsqldb:mem:test-" + UUID.randomUUID().toString(); String jdbcUrl = "jdbc:hsqldb:mem:test-" + UUID.randomUUID();
TestPropertyValues.of(environment).and("spring.datasource.url=" + jdbcUrl) TestPropertyValues.of(environment).and("spring.datasource.url=" + jdbcUrl)
.applyTo(context); .applyTo(context);
if (config != null) { if (config != null) {
......
...@@ -254,7 +254,7 @@ public abstract class AbstractJpaAutoConfigurationTests { ...@@ -254,7 +254,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
} }
private DataSource createRandomDataSource() { private DataSource createRandomDataSource() {
String url = "jdbc:h2:mem:init-" + UUID.randomUUID().toString(); String url = "jdbc:h2:mem:init-" + UUID.randomUUID();
return DataSourceBuilder.create().url(url).build(); return DataSourceBuilder.create().url(url).build();
} }
...@@ -275,7 +275,7 @@ public abstract class AbstractJpaAutoConfigurationTests { ...@@ -275,7 +275,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
} }
private DataSource createRandomDataSource() { private DataSource createRandomDataSource() {
String url = "jdbc:h2:mem:init-" + UUID.randomUUID().toString(); String url = "jdbc:h2:mem:init-" + UUID.randomUUID();
return DataSourceBuilder.create().url(url).build(); return DataSourceBuilder.create().url(url).build();
} }
......
...@@ -147,7 +147,7 @@ public class HttpEncodingAutoConfigurationTests { ...@@ -147,7 +147,7 @@ public class HttpEncodingAutoConfigurationTests {
Map<String, WebServerFactoryCustomizer<?>> beans = getWebServerFactoryCustomizerBeans(); Map<String, WebServerFactoryCustomizer<?>> beans = getWebServerFactoryCustomizerBeans();
assertThat(beans.size()).isEqualTo(1); assertThat(beans.size()).isEqualTo(1);
assertThat(this.context.getBean(MockServletWebServerFactory.class) assertThat(this.context.getBean(MockServletWebServerFactory.class)
.getLocaleCharsetMappings().size()).isEqualTo(0); .getLocaleCharsetMappings()).isEmpty();
} }
@Test @Test
......
...@@ -190,7 +190,7 @@ public class WebMvcAutoConfigurationTests { ...@@ -190,7 +190,7 @@ public class WebMvcAutoConfigurationTests {
.run((context) -> { .run((context) -> {
Map<String, List<Resource>> locations = getResourceMappingLocations( Map<String, List<Resource>> locations = getResourceMappingLocations(
context); context);
assertThat(locations.size()).isEqualTo(0); assertThat(locations).isEmpty();
}); });
} }
......
...@@ -261,7 +261,7 @@ public class FileSystemWatcherTests { ...@@ -261,7 +261,7 @@ public class FileSystemWatcherTests {
this.watcher.start(); this.watcher.start();
FileCopyUtils.copy("abc".getBytes(), file); FileCopyUtils.copy("abc".getBytes(), file);
Thread.sleep(100); Thread.sleep(100);
assertThat(this.changes.size()).isEqualTo(0); assertThat(this.changes).isEmpty();
FileCopyUtils.copy("abc".getBytes(), trigger); FileCopyUtils.copy("abc".getBytes(), trigger);
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles(); ChangedFiles changedFiles = getSingleChangedFiles();
......
...@@ -54,13 +54,13 @@ public class ChangeableUrlsTests { ...@@ -54,13 +54,13 @@ public class ChangeableUrlsTests {
@Test @Test
public void fileUrl() throws Exception { public void fileUrl() throws Exception {
URL url = this.temporaryFolder.newFile().toURI().toURL(); URL url = this.temporaryFolder.newFile().toURI().toURL();
assertThat(ChangeableUrls.fromUrls(url).size()).isEqualTo(0); assertThat(ChangeableUrls.fromUrls(url)).isEmpty();
} }
@Test @Test
public void httpUrl() throws Exception { public void httpUrl() throws Exception {
URL url = new URL("http://spring.io"); URL url = new URL("http://spring.io");
assertThat(ChangeableUrls.fromUrls(url).size()).isEqualTo(0); assertThat(ChangeableUrls.fromUrls(url)).isEmpty();
} }
@Test @Test
...@@ -69,7 +69,7 @@ public class ChangeableUrlsTests { ...@@ -69,7 +69,7 @@ public class ChangeableUrlsTests {
makeUrl("spring-boot-autoconfigure"), makeUrl("spring-boot-actuator"), makeUrl("spring-boot-autoconfigure"), makeUrl("spring-boot-actuator"),
makeUrl("spring-boot-starter"), makeUrl("spring-boot-starter"),
makeUrl("spring-boot-starter-some-thing")); makeUrl("spring-boot-starter-some-thing"));
assertThat(urls.size()).isEqualTo(0); assertThat(urls).isEmpty();
} }
@Test @Test
......
...@@ -168,7 +168,7 @@ public class RestartClassLoaderTests { ...@@ -168,7 +168,7 @@ public class RestartClassLoaderTests {
String name = PACKAGE_PATH + "/Sample.txt"; String name = PACKAGE_PATH + "/Sample.txt";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
List<URL> resources = toList(this.reloadClassLoader.getResources(name)); List<URL> resources = toList(this.reloadClassLoader.getResources(name));
assertThat(resources.size()).isEqualTo(0); assertThat(resources).isEmpty();
} }
@Test @Test
......
...@@ -52,7 +52,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp ...@@ -52,7 +52,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
@Test @Test
public void runWithSystemPropertiesShouldSetAndRemoveProperties() { public void runWithSystemPropertiesShouldSetAndRemoveProperties() {
String key = "test." + UUID.randomUUID().toString(); String key = "test." + UUID.randomUUID();
assertThat(System.getProperties().containsKey(key)).isFalse(); assertThat(System.getProperties().containsKey(key)).isFalse();
get().withSystemProperties(key + "=value") get().withSystemProperties(key + "=value")
.run((context) -> assertThat(System.getProperties()).containsEntry(key, .run((context) -> assertThat(System.getProperties()).containsEntry(key,
...@@ -63,7 +63,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp ...@@ -63,7 +63,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
@Test @Test
public void runWithSystemPropertiesWhenContextFailsShouldRemoveProperties() public void runWithSystemPropertiesWhenContextFailsShouldRemoveProperties()
throws Exception { throws Exception {
String key = "test." + UUID.randomUUID().toString(); String key = "test." + UUID.randomUUID();
assertThat(System.getProperties().containsKey(key)).isFalse(); assertThat(System.getProperties().containsKey(key)).isFalse();
get().withSystemProperties(key + "=value") get().withSystemProperties(key + "=value")
.withUserConfiguration(FailingConfig.class) .withUserConfiguration(FailingConfig.class)
...@@ -74,7 +74,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp ...@@ -74,7 +74,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
@Test @Test
public void runWithSystemPropertiesShouldRestoreOriginalProperties() public void runWithSystemPropertiesShouldRestoreOriginalProperties()
throws Exception { throws Exception {
String key = "test." + UUID.randomUUID().toString(); String key = "test." + UUID.randomUUID();
System.setProperty(key, "value"); System.setProperty(key, "value");
try { try {
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
...@@ -91,7 +91,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp ...@@ -91,7 +91,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
@Test @Test
public void runWithSystemPropertiesWhenValueIsNullShouldRemoveProperty() public void runWithSystemPropertiesWhenValueIsNullShouldRemoveProperty()
throws Exception { throws Exception {
String key = "test." + UUID.randomUUID().toString(); String key = "test." + UUID.randomUUID();
System.setProperty(key, "value"); System.setProperty(key, "value");
try { try {
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
......
...@@ -310,7 +310,7 @@ public class RandomAccessDataFileTests { ...@@ -310,7 +310,7 @@ public class RandomAccessDataFileTests {
Field filesField = filePool.getClass().getDeclaredField("files"); Field filesField = filePool.getClass().getDeclaredField("files");
filesField.setAccessible(true); filesField.setAccessible(true);
Queue<?> queue = (Queue<?>) filesField.get(filePool); Queue<?> queue = (Queue<?>) filesField.get(filePool);
assertThat(queue.size()).isEqualTo(0); assertThat(queue).isEmpty();
} }
@Test @Test
......
...@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Phillip Webb * @author Phillip Webb
*/ */
public class BackCompatibiltyBinderIntegrationTests { public class BackCompatibilityBinderIntegrationTests {
@Test @Test
public void bindWhenBindingCamelCaseToEnvironmentWithExtractUnderscore() public void bindWhenBindingCamelCaseToEnvironmentWithExtractUnderscore()
...@@ -49,7 +49,7 @@ public class BackCompatibiltyBinderIntegrationTests { ...@@ -49,7 +49,7 @@ public class BackCompatibiltyBinderIntegrationTests {
} }
@Test @Test
public void bindWhenUsingSystemEnvronmentToOverride() { public void bindWhenUsingSystemEnvironmentToOverride() {
MockEnvironment environment = new MockEnvironment(); MockEnvironment environment = new MockEnvironment();
SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource( SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource(
"override", Collections.singletonMap("foo.password", "test")); "override", Collections.singletonMap("foo.password", "test"));
......
...@@ -70,10 +70,6 @@ class SpringApplicationExtensionsTests { ...@@ -70,10 +70,6 @@ class SpringApplicationExtensionsTests {
assertEquals(environment, context.environment) assertEquals(environment, context.environment)
} }
@Configuration
internal open class ExampleConfig
@Configuration @Configuration
internal open class ExampleWebConfig { internal open class ExampleWebConfig {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment