Polish
This commit is contained in:
@@ -157,7 +157,7 @@ public class FlywayAutoConfiguration {
|
||||
private String getProperty(Supplier<String> property,
|
||||
Supplier<String> defaultValue) {
|
||||
String value = property.get();
|
||||
return value == null ? defaultValue.get() : value;
|
||||
return (value == null ? defaultValue.get() : value);
|
||||
}
|
||||
|
||||
private void checkLocationExists(String... locations) {
|
||||
|
||||
@@ -57,16 +57,19 @@ public final class JettyCustomizer {
|
||||
propertyMapper.from(jettyProperties::getSelectors).whenNonNull()
|
||||
.to(factory::setSelectors);
|
||||
propertyMapper.from(serverProperties::getMaxHttpHeaderSize)
|
||||
.when(JettyCustomizer::isPositive).to(maxHttpHeaderSize ->
|
||||
customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize));
|
||||
.when(JettyCustomizer::isPositive)
|
||||
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
|
||||
maxHttpHeaderSize));
|
||||
propertyMapper.from(jettyProperties::getMaxHttpPostSize)
|
||||
.when(JettyCustomizer::isPositive)
|
||||
.to(maxHttpPostSize -> customizeMaxHttpPostSize(factory, maxHttpPostSize));
|
||||
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
|
||||
maxHttpPostSize));
|
||||
propertyMapper.from(serverProperties::getConnectionTimeout).whenNonNull()
|
||||
.to(connectionTimeout -> customizeConnectionTimeout(factory, connectionTimeout));
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory,
|
||||
connectionTimeout));
|
||||
propertyMapper.from(jettyProperties::getAccesslog)
|
||||
.when(ServerProperties.Jetty.Accesslog::isEnabled)
|
||||
.to(accesslog -> customizeAccessLog(factory, accesslog));
|
||||
.to((accesslog) -> customizeAccessLog(factory, accesslog));
|
||||
}
|
||||
|
||||
private static boolean isPositive(Integer value) {
|
||||
|
||||
@@ -58,29 +58,35 @@ public final class TomcatCustomizer {
|
||||
customizeRemoteIpValve(serverProperties, environment, factory);
|
||||
propertyMapper.from(tomcatProperties::getMaxThreads)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(maxThreads -> customizeMaxThreads(factory, tomcatProperties.getMaxThreads()));
|
||||
.to((maxThreads) -> customizeMaxThreads(factory,
|
||||
tomcatProperties.getMaxThreads()));
|
||||
propertyMapper.from(tomcatProperties::getMinSpareThreads)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(minSpareThreads -> customizeMinThreads(factory, minSpareThreads));
|
||||
propertyMapper.from(() -> determineMaxHttpHeaderSize(serverProperties, tomcatProperties))
|
||||
.to((minSpareThreads) -> customizeMinThreads(factory, minSpareThreads));
|
||||
propertyMapper
|
||||
.from(() -> determineMaxHttpHeaderSize(serverProperties,
|
||||
tomcatProperties))
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(maxHttpHeaderSize -> customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize));
|
||||
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
|
||||
maxHttpHeaderSize));
|
||||
propertyMapper.from(tomcatProperties::getMaxHttpPostSize)
|
||||
.when(maxHttpPostSize -> maxHttpPostSize != 0)
|
||||
.to(maxHttpPostSize -> customizeMaxHttpPostSize(factory, maxHttpPostSize));
|
||||
.when((maxHttpPostSize) -> maxHttpPostSize != 0)
|
||||
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
|
||||
maxHttpPostSize));
|
||||
propertyMapper.from(tomcatProperties::getAccesslog)
|
||||
.when(ServerProperties.Tomcat.Accesslog::isEnabled)
|
||||
.to(enabled -> customizeAccessLog(tomcatProperties, factory));
|
||||
.to((enabled) -> customizeAccessLog(tomcatProperties, factory));
|
||||
propertyMapper.from(tomcatProperties::getUriEncoding).whenNonNull()
|
||||
.to(factory::setUriEncoding);
|
||||
propertyMapper.from(serverProperties::getConnectionTimeout).whenNonNull()
|
||||
.to(connectionTimeout -> customizeConnectionTimeout(factory, connectionTimeout));
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory,
|
||||
connectionTimeout));
|
||||
propertyMapper.from(tomcatProperties::getMaxConnections)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(maxConnections -> customizeMaxConnections(factory, maxConnections));
|
||||
.to((maxConnections) -> customizeMaxConnections(factory, maxConnections));
|
||||
propertyMapper.from(tomcatProperties::getAcceptCount)
|
||||
.when(TomcatCustomizer::isPositive)
|
||||
.to(acceptCount -> customizeAcceptCount(factory, acceptCount));
|
||||
.to((acceptCount) -> customizeAcceptCount(factory, acceptCount));
|
||||
customizeStaticResources(serverProperties.getTomcat().getResource(), factory);
|
||||
}
|
||||
|
||||
@@ -234,4 +240,5 @@ public final class TomcatCustomizer {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,21 +63,21 @@ public final class UndertowCustomizer {
|
||||
.to(factory::setAccessLogSuffix);
|
||||
propertyMapper.from(accesslogProperties::isRotate)
|
||||
.to(factory::setAccessLogRotate);
|
||||
propertyMapper.from(() ->
|
||||
getOrDeduceUseForwardHeaders(serverProperties, environment)).to(
|
||||
factory::setUseForwardHeaders);
|
||||
propertyMapper
|
||||
.from(() -> getOrDeduceUseForwardHeaders(serverProperties, environment))
|
||||
.to(factory::setUseForwardHeaders);
|
||||
propertyMapper.from(serverProperties::getMaxHttpHeaderSize)
|
||||
.when(UndertowCustomizer::isPositive)
|
||||
.to(maxHttpHeaderSize ->
|
||||
customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize));
|
||||
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
|
||||
maxHttpHeaderSize));
|
||||
propertyMapper.from(undertowProperties::getMaxHttpPostSize)
|
||||
.when(UndertowCustomizer::isPositive)
|
||||
.to(maxHttpPostSize ->
|
||||
customizeMaxHttpPostSize(factory, maxHttpPostSize));
|
||||
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
|
||||
maxHttpPostSize));
|
||||
propertyMapper.from(serverProperties::getConnectionTimeout)
|
||||
.to(connectionTimeout ->
|
||||
customizeConnectionTimeout(factory, connectionTimeout));
|
||||
factory.addDeploymentInfoCustomizers(deploymentInfo -> deploymentInfo
|
||||
.to((connectionTimeout) -> customizeConnectionTimeout(factory,
|
||||
connectionTimeout));
|
||||
factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo
|
||||
.setEagerFilterInit(undertowProperties.isEagerFilterInit()));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,14 +67,14 @@ public class DefaultReactiveWebServerFactoryCustomizer
|
||||
map.from(this.serverProperties::getSsl).to(factory::setSsl);
|
||||
map.from(this.serverProperties::getCompression).to(factory::setCompression);
|
||||
map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
|
||||
map.from(() -> factory).whenInstanceOf(TomcatReactiveWebServerFactory.class)
|
||||
.to(tomcatFactory -> TomcatCustomizer.customizeTomcat(
|
||||
this.serverProperties, this.environment, tomcatFactory));
|
||||
map.from(() -> factory).whenInstanceOf(JettyReactiveWebServerFactory.class)
|
||||
.to(jettyFactory -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
map.from(() -> factory).whenInstanceOf(TomcatReactiveWebServerFactory.class).to(
|
||||
(tomcatFactory) -> TomcatCustomizer.customizeTomcat(this.serverProperties,
|
||||
this.environment, tomcatFactory));
|
||||
map.from(() -> factory).whenInstanceOf(JettyReactiveWebServerFactory.class).to(
|
||||
(jettyFactory) -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
this.environment, jettyFactory));
|
||||
map.from(() -> factory).whenInstanceOf(UndertowReactiveWebServerFactory.class)
|
||||
.to(undertowFactory -> UndertowCustomizer.customizeUndertow(
|
||||
.to((undertowFactory) -> UndertowCustomizer.customizeUndertow(
|
||||
this.serverProperties, this.environment, undertowFactory));
|
||||
}
|
||||
|
||||
|
||||
@@ -83,17 +83,17 @@ public class DefaultServletWebServerFactoryCustomizer
|
||||
map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
|
||||
map.from(this.serverProperties::getServerHeader).to(factory::setServerHeader);
|
||||
map.from(() -> factory).whenInstanceOf(TomcatServletWebServerFactory.class)
|
||||
.to(tomcatFactory -> {
|
||||
.to((tomcatFactory) -> {
|
||||
TomcatCustomizer.customizeTomcat(this.serverProperties,
|
||||
this.environment, tomcatFactory);
|
||||
TomcatServletCustomizer.customizeTomcat(this.serverProperties,
|
||||
this.environment, tomcatFactory);
|
||||
});
|
||||
map.from(() -> factory).whenInstanceOf(JettyServletWebServerFactory.class)
|
||||
.to(jettyFactory -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
map.from(() -> factory).whenInstanceOf(JettyServletWebServerFactory.class).to(
|
||||
(jettyFactory) -> JettyCustomizer.customizeJetty(this.serverProperties,
|
||||
this.environment, jettyFactory));
|
||||
map.from(() -> factory).whenInstanceOf(UndertowServletWebServerFactory.class)
|
||||
.to(undertowFactory -> UndertowCustomizer.customizeUndertow(
|
||||
.to((undertowFactory) -> UndertowCustomizer.customizeUndertow(
|
||||
this.serverProperties, this.environment, undertowFactory));
|
||||
map.from(this.serverProperties.getServlet()::getContextParameters)
|
||||
.to(factory::setInitParameters);
|
||||
|
||||
@@ -60,11 +60,12 @@ public class CassandraRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(Cluster.class);
|
||||
assertThat(getInitialEntitySet(context)).hasSize(1);
|
||||
});
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(Cluster.class);
|
||||
assertThat(getInitialEntitySet(context)).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -58,16 +58,17 @@ public class MongoReactiveRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(ReactiveCityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(ReactiveCityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -53,16 +53,17 @@ public class MongoRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CityRepository.class);
|
||||
assertThat(context).hasSingleBean(MongoClient.class);
|
||||
MongoMappingContext mappingContext = context
|
||||
.getBean(MongoMappingContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(entities).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,8 +81,9 @@ public class MongoRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void autoConfigurationShouldNotKickInEvenIfManualConfigDidNotCreateAnyRepositories() {
|
||||
this.contextRunner.withUserConfiguration(SortOfInvalidCustomConfiguration.class).run(
|
||||
(context) -> assertThat(context).doesNotHaveBean(CityRepository.class));
|
||||
this.contextRunner.withUserConfiguration(SortOfInvalidCustomConfiguration.class)
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(CityRepository.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -74,7 +74,8 @@ public class AuthenticationManagerConfigurationTests {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(TestConfigWithClientRegistrationRepository.class,
|
||||
AuthenticationManagerConfiguration.class)
|
||||
.run(((context) -> assertThat(context).doesNotHaveBean(InMemoryUserDetailsManager.class)));
|
||||
.run(((context) -> assertThat(context)
|
||||
.doesNotHaveBean(InMemoryUserDetailsManager.class)));
|
||||
}
|
||||
|
||||
private void testPasswordEncoding(Class<?> configClass, String providedPassword,
|
||||
|
||||
Reference in New Issue
Block a user