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