Polish
This commit is contained in:
@@ -64,8 +64,8 @@ public class GsonProperties {
|
||||
private LongSerializationPolicy longSerializationPolicy;
|
||||
|
||||
/**
|
||||
* Naming policy that should be applied to an object's field during serialization
|
||||
* and deserialization.
|
||||
* Naming policy that should be applied to an object's field during serialization and
|
||||
* deserialization.
|
||||
*/
|
||||
private FieldNamingPolicy fieldNamingPolicy;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -75,7 +75,8 @@ class GsonHttpMessageConvertersConfiguration {
|
||||
|
||||
}
|
||||
|
||||
private static class JacksonAndJsonbUnavailableCondition extends NoneNestedConditions {
|
||||
private static class JacksonAndJsonbUnavailableCondition
|
||||
extends NoneNestedConditions {
|
||||
|
||||
JacksonAndJsonbUnavailableCondition() {
|
||||
super(ConfigurationPhase.REGISTER_BEAN);
|
||||
|
||||
@@ -53,7 +53,8 @@ public class SessionProperties {
|
||||
|
||||
public SessionProperties(ObjectProvider<ServerProperties> serverProperties) {
|
||||
ServerProperties properties = serverProperties.getIfUnique();
|
||||
Session session = (properties == null ? null : properties.getServlet().getSession());
|
||||
Session session = (properties == null ? null
|
||||
: properties.getServlet().getSession());
|
||||
this.timeout = (session == null ? null : session.getTimeout());
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ public class SessionProperties {
|
||||
/**
|
||||
* Return the session timeout.
|
||||
* @return the session timeout
|
||||
* @see ServerProperties.Servlet#getSession()
|
||||
* @see Session#getTimeout()
|
||||
*/
|
||||
public Duration getTimeout() {
|
||||
return this.timeout;
|
||||
|
||||
@@ -35,8 +35,7 @@ import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Customization for Jetty-specific features common
|
||||
* for both Servlet and Reactive servers.
|
||||
* Customization for Jetty-specific features common for both Servlet and Reactive servers.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 2.0.0
|
||||
@@ -58,16 +57,14 @@ public final class JettyCustomizer {
|
||||
factory.setSelectors(jettyProperties.getSelectors());
|
||||
}
|
||||
if (serverProperties.getMaxHttpHeaderSize() > 0) {
|
||||
customizeMaxHttpHeaderSize(factory,
|
||||
serverProperties.getMaxHttpHeaderSize());
|
||||
customizeMaxHttpHeaderSize(factory, serverProperties.getMaxHttpHeaderSize());
|
||||
}
|
||||
if (jettyProperties.getMaxHttpPostSize() > 0) {
|
||||
customizeMaxHttpPostSize(factory, jettyProperties.getMaxHttpPostSize());
|
||||
}
|
||||
|
||||
if (serverProperties.getConnectionTimeout() != null) {
|
||||
customizeConnectionTimeout(factory,
|
||||
serverProperties.getConnectionTimeout());
|
||||
customizeConnectionTimeout(factory, serverProperties.getConnectionTimeout());
|
||||
}
|
||||
if (jettyProperties.getAccesslog().isEnabled()) {
|
||||
customizeAccessLog(factory, jettyProperties.getAccesslog());
|
||||
@@ -86,8 +83,7 @@ public final class JettyCustomizer {
|
||||
private static void customizeConnectionTimeout(
|
||||
ConfigurableJettyWebServerFactory factory, Duration connectionTimeout) {
|
||||
factory.addServerCustomizers((server) -> {
|
||||
for (org.eclipse.jetty.server.Connector connector : server
|
||||
.getConnectors()) {
|
||||
for (org.eclipse.jetty.server.Connector connector : server.getConnectors()) {
|
||||
if (connector instanceof AbstractConnector) {
|
||||
((AbstractConnector) connector)
|
||||
.setIdleTimeout(connectionTimeout.toMillis());
|
||||
@@ -123,8 +119,8 @@ public final class JettyCustomizer {
|
||||
});
|
||||
}
|
||||
|
||||
private static void customizeMaxHttpPostSize(ConfigurableJettyWebServerFactory factory,
|
||||
int maxHttpPostSize) {
|
||||
private static void customizeMaxHttpPostSize(
|
||||
ConfigurableJettyWebServerFactory factory, int maxHttpPostSize) {
|
||||
factory.addServerCustomizers(new JettyServerCustomizer() {
|
||||
|
||||
@Override
|
||||
@@ -136,8 +132,7 @@ public final class JettyCustomizer {
|
||||
Handler... handlers) {
|
||||
for (Handler handler : handlers) {
|
||||
if (handler instanceof ContextHandler) {
|
||||
((ContextHandler) handler)
|
||||
.setMaxFormContentSize(maxHttpPostSize);
|
||||
((ContextHandler) handler).setMaxFormContentSize(maxHttpPostSize);
|
||||
}
|
||||
else if (handler instanceof HandlerWrapper) {
|
||||
setHandlerMaxHttpPostSize(maxHttpPostSize,
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Customization for Tomcat-specific features common
|
||||
* for both Servlet and Reactive servers.
|
||||
* Customization for Tomcat-specific features common for both Servlet and Reactive
|
||||
* servers.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 2.0.0
|
||||
@@ -50,8 +50,8 @@ public final class TomcatCustomizer {
|
||||
factory.setBaseDirectory(tomcatProperties.getBasedir());
|
||||
}
|
||||
if (tomcatProperties.getBackgroundProcessorDelay() != null) {
|
||||
factory.setBackgroundProcessorDelay((int) tomcatProperties
|
||||
.getBackgroundProcessorDelay().getSeconds());
|
||||
factory.setBackgroundProcessorDelay(
|
||||
(int) tomcatProperties.getBackgroundProcessorDelay().getSeconds());
|
||||
}
|
||||
customizeRemoteIpValve(serverProperties, environment, factory);
|
||||
if (tomcatProperties.getMaxThreads() > 0) {
|
||||
@@ -76,8 +76,7 @@ public final class TomcatCustomizer {
|
||||
factory.setUriEncoding(tomcatProperties.getUriEncoding());
|
||||
}
|
||||
if (serverProperties.getConnectionTimeout() != null) {
|
||||
customizeConnectionTimeout(factory,
|
||||
serverProperties.getConnectionTimeout());
|
||||
customizeConnectionTimeout(factory, serverProperties.getConnectionTimeout());
|
||||
}
|
||||
if (tomcatProperties.getMaxConnections() > 0) {
|
||||
customizeMaxConnections(factory, tomcatProperties.getMaxConnections());
|
||||
@@ -99,8 +98,8 @@ public final class TomcatCustomizer {
|
||||
});
|
||||
}
|
||||
|
||||
private static void customizeMaxConnections(ConfigurableTomcatWebServerFactory factory,
|
||||
int maxConnections) {
|
||||
private static void customizeMaxConnections(
|
||||
ConfigurableTomcatWebServerFactory factory, int maxConnections) {
|
||||
factory.addConnectorCustomizers((connector) -> {
|
||||
ProtocolHandler handler = connector.getProtocolHandler();
|
||||
if (handler instanceof AbstractProtocol) {
|
||||
@@ -129,8 +128,8 @@ public final class TomcatCustomizer {
|
||||
if (StringUtils.hasText(protocolHeader) || StringUtils.hasText(remoteIpHeader)
|
||||
|| getOrDeduceUseForwardHeaders(properties, environment)) {
|
||||
RemoteIpValve valve = new RemoteIpValve();
|
||||
valve.setProtocolHeader(StringUtils.hasLength(protocolHeader)
|
||||
? protocolHeader : "X-Forwarded-Proto");
|
||||
valve.setProtocolHeader(StringUtils.hasLength(protocolHeader) ? protocolHeader
|
||||
: "X-Forwarded-Proto");
|
||||
if (StringUtils.hasLength(remoteIpHeader)) {
|
||||
valve.setRemoteIpHeader(remoteIpHeader);
|
||||
}
|
||||
@@ -213,7 +212,8 @@ public final class TomcatCustomizer {
|
||||
factory.addEngineValves(valve);
|
||||
}
|
||||
|
||||
private static void customizeStaticResources(ServerProperties.Tomcat.Resource resource,
|
||||
private static void customizeStaticResources(
|
||||
ServerProperties.Tomcat.Resource resource,
|
||||
ConfigurableTomcatWebServerFactory factory) {
|
||||
if (resource.getCacheTtl() == null) {
|
||||
return;
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebSer
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Customization for Undertow-specific features common
|
||||
* for both Servlet and Reactive servers.
|
||||
* Customization for Undertow-specific features common for both Servlet and Reactive
|
||||
* servers.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@@ -62,18 +62,16 @@ public final class UndertowCustomizer {
|
||||
factory.setAccessLogPrefix(accesslogProperties.getPrefix());
|
||||
factory.setAccessLogSuffix(accesslogProperties.getSuffix());
|
||||
factory.setAccessLogRotate(accesslogProperties.isRotate());
|
||||
factory.setUseForwardHeaders(getOrDeduceUseForwardHeaders(serverProperties, environment));
|
||||
factory.setUseForwardHeaders(
|
||||
getOrDeduceUseForwardHeaders(serverProperties, environment));
|
||||
if (serverProperties.getMaxHttpHeaderSize() > 0) {
|
||||
customizeMaxHttpHeaderSize(factory,
|
||||
serverProperties.getMaxHttpHeaderSize());
|
||||
customizeMaxHttpHeaderSize(factory, serverProperties.getMaxHttpHeaderSize());
|
||||
}
|
||||
if (undertowProperties.getMaxHttpPostSize() > 0) {
|
||||
customizeMaxHttpPostSize(factory,
|
||||
undertowProperties.getMaxHttpPostSize());
|
||||
customizeMaxHttpPostSize(factory, undertowProperties.getMaxHttpPostSize());
|
||||
}
|
||||
if (serverProperties.getConnectionTimeout() != null) {
|
||||
customizeConnectionTimeout(factory,
|
||||
serverProperties.getConnectionTimeout());
|
||||
customizeConnectionTimeout(factory, serverProperties.getConnectionTimeout());
|
||||
}
|
||||
factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo
|
||||
.setEagerFilterInit(undertowProperties.isEagerFilterInit()));
|
||||
@@ -82,8 +80,7 @@ public final class UndertowCustomizer {
|
||||
private static void customizeConnectionTimeout(
|
||||
ConfigurableUndertowWebServerFactory factory, Duration connectionTimeout) {
|
||||
factory.addBuilderCustomizers((builder) -> builder.setSocketOption(
|
||||
UndertowOptions.NO_REQUEST_TIMEOUT,
|
||||
(int) connectionTimeout.toMillis()));
|
||||
UndertowOptions.NO_REQUEST_TIMEOUT, (int) connectionTimeout.toMillis()));
|
||||
}
|
||||
|
||||
private static void customizeMaxHttpHeaderSize(
|
||||
|
||||
@@ -35,8 +35,9 @@ import org.springframework.core.env.Environment;
|
||||
* @author Brian Clozel
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class DefaultReactiveWebServerFactoryCustomizer implements
|
||||
WebServerFactoryCustomizer<ConfigurableReactiveWebServerFactory>, EnvironmentAware, Ordered {
|
||||
public class DefaultReactiveWebServerFactoryCustomizer
|
||||
implements WebServerFactoryCustomizer<ConfigurableReactiveWebServerFactory>,
|
||||
EnvironmentAware, Ordered {
|
||||
|
||||
private final ServerProperties serverProperties;
|
||||
|
||||
|
||||
@@ -192,7 +192,8 @@ public abstract class AbstractErrorWebExceptionHandler
|
||||
.append("<p>This application has no configured error view, so you are seeing this as a fallback.</p>")
|
||||
.append("<div id='created'>").append(timestamp.toString())
|
||||
.append("</div>").append("<div>There was an unexpected error (type=")
|
||||
.append(HtmlUtils.htmlEscape(error.get("error").toString())).append(", status=")
|
||||
.append(HtmlUtils.htmlEscape(error.get("error").toString()))
|
||||
.append(", status=")
|
||||
.append(HtmlUtils.htmlEscape(error.get("status").toString()))
|
||||
.append(").</div>").append("<div>")
|
||||
.append(HtmlUtils.htmlEscape(error.get("message").toString()))
|
||||
|
||||
@@ -118,8 +118,8 @@ public class DefaultErrorAttributes implements ErrorAttributes {
|
||||
errorAttributes.put("trace", stackTrace.toString());
|
||||
}
|
||||
|
||||
private void handleException(Map<String, Object> errorAttributes,
|
||||
Throwable error, boolean includeStackTrace) {
|
||||
private void handleException(Map<String, Object> errorAttributes, Throwable error,
|
||||
boolean includeStackTrace) {
|
||||
if (this.includeException) {
|
||||
errorAttributes.put("exception", error.getClass().getName());
|
||||
}
|
||||
|
||||
@@ -217,22 +217,23 @@ public class WebMvcAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||
configurer.setUseSuffixPatternMatch(this.mvcProperties
|
||||
.getPathMatch().isUseSuffixPattern());
|
||||
configurer.setUseRegisteredSuffixPatternMatch(this.mvcProperties
|
||||
.getPathMatch().isUseRegisteredSuffixPattern());
|
||||
configurer.setUseSuffixPatternMatch(
|
||||
this.mvcProperties.getPathMatch().isUseSuffixPattern());
|
||||
configurer.setUseRegisteredSuffixPatternMatch(
|
||||
this.mvcProperties.getPathMatch().isUseRegisteredSuffixPattern());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
||||
WebMvcProperties.ContentNegotiation contentNegotiation
|
||||
= this.mvcProperties.getContentNegotiation();
|
||||
WebMvcProperties.ContentNegotiation contentNegotiation = this.mvcProperties
|
||||
.getContentNegotiation();
|
||||
configurer.favorPathExtension(contentNegotiation.isFavorPathExtension());
|
||||
configurer.favorParameter(contentNegotiation.isFavorParameter());
|
||||
if (contentNegotiation.getParameterName() != null) {
|
||||
configurer.parameterName(contentNegotiation.getParameterName());
|
||||
}
|
||||
Map<String, MediaType> mediaTypes = this.mvcProperties.getContentNegotiation().getMediaTypes();
|
||||
Map<String, MediaType> mediaTypes = this.mvcProperties.getContentNegotiation()
|
||||
.getMediaTypes();
|
||||
for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
|
||||
configurer.mediaType(mediaType.getKey(), mediaType.getValue());
|
||||
}
|
||||
@@ -324,8 +325,8 @@ public class WebMvcAutoConfiguration {
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations(
|
||||
"classpath:/META-INF/resources/webjars/")
|
||||
.setCachePeriod(getSeconds(cachePeriod))
|
||||
.setCacheControl(cacheControl));
|
||||
.setCachePeriod(getSeconds(cachePeriod))
|
||||
.setCacheControl(cacheControl));
|
||||
}
|
||||
String staticPathPattern = this.mvcProperties.getStaticPathPattern();
|
||||
if (!registry.hasMappingForPattern(staticPathPattern)) {
|
||||
@@ -333,8 +334,8 @@ public class WebMvcAutoConfiguration {
|
||||
registry.addResourceHandler(staticPathPattern)
|
||||
.addResourceLocations(getResourceLocations(
|
||||
this.resourceProperties.getStaticLocations()))
|
||||
.setCachePeriod(getSeconds(cachePeriod))
|
||||
.setCacheControl(cacheControl));
|
||||
.setCachePeriod(getSeconds(cachePeriod))
|
||||
.setCacheControl(cacheControl));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -273,20 +273,21 @@ public class WebMvcProperties {
|
||||
public static class ContentNegotiation {
|
||||
|
||||
/**
|
||||
* Whether the path extension in the URL path should be used to determine
|
||||
* the requested media type. If enabled a request "/users.pdf" will be
|
||||
* interpreted as a request for "application/pdf" regardless of the 'Accept' header.
|
||||
* Whether the path extension in the URL path should be used to determine the
|
||||
* requested media type. If enabled a request "/users.pdf" will be interpreted as
|
||||
* a request for "application/pdf" regardless of the 'Accept' header.
|
||||
*/
|
||||
private boolean favorPathExtension = false;
|
||||
|
||||
/**
|
||||
* Whether a request parameter ("format" by default) should be used to
|
||||
* determine the requested media type.
|
||||
* Whether a request parameter ("format" by default) should be used to determine
|
||||
* the requested media type.
|
||||
*/
|
||||
private boolean favorParameter = false;
|
||||
|
||||
/**
|
||||
* Maps file extensions to media types for content negotiation, e.g. yml to text/yaml.
|
||||
* Maps file extensions to media types for content negotiation, e.g. yml to
|
||||
* text/yaml.
|
||||
*/
|
||||
private Map<String, MediaType> mediaTypes = new LinkedHashMap<>();
|
||||
|
||||
@@ -331,16 +332,16 @@ public class WebMvcProperties {
|
||||
public static class PathMatch {
|
||||
|
||||
/**
|
||||
* Whether to use suffix pattern match (".*") when matching patterns to
|
||||
* requests. If enabled a method mapped to "/users" also matches to "/users.*".
|
||||
* Whether to use suffix pattern match (".*") when matching patterns to requests.
|
||||
* If enabled a method mapped to "/users" also matches to "/users.*".
|
||||
*/
|
||||
private boolean useSuffixPattern = false;
|
||||
|
||||
/**
|
||||
* Whether suffix pattern matching should work only against extensions
|
||||
* registered with "spring.mvc.content-negotiation.media-types.*".
|
||||
* This is generally recommended to reduce ambiguity and to
|
||||
* avoid issues such as when a "." appears in the path for other reasons.
|
||||
* Whether suffix pattern matching should work only against extensions registered
|
||||
* with "spring.mvc.content-negotiation.media-types.*". This is generally
|
||||
* recommended to reduce ambiguity and to avoid issues such as when a "." appears
|
||||
* in the path for other reasons.
|
||||
*/
|
||||
private boolean useRegisteredSuffixPattern = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,9 +35,7 @@ import org.springframework.messaging.converter.MessageConverter;
|
||||
import org.springframework.messaging.converter.StringMessageConverter;
|
||||
import org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
|
||||
import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
|
||||
/**
|
||||
@@ -56,7 +54,7 @@ public class WebSocketMessagingAutoConfiguration {
|
||||
ObjectMapper.class })
|
||||
@ConditionalOnClass({ ObjectMapper.class, AbstractMessageBrokerConfiguration.class })
|
||||
static class WebSocketMessageConverterConfiguration
|
||||
extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@@ -64,11 +62,6 @@ public class WebSocketMessagingAutoConfiguration {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
// The user must register their own endpoints
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configureMessageConverters(
|
||||
List<MessageConverter> messageConverters) {
|
||||
|
||||
@@ -321,8 +321,7 @@ public class CacheAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void redisCacheWithCustomizers() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(RedisWithCustomizersConfiguration.class)
|
||||
this.contextRunner.withUserConfiguration(RedisWithCustomizersConfiguration.class)
|
||||
.withPropertyValues("spring.cache.type=" + "redis")
|
||||
.run(dunno("allCacheManagerCustomizer", "redisCacheManagerCustomizer"));
|
||||
}
|
||||
@@ -954,8 +953,7 @@ public class CacheAutoConfigurationTests {
|
||||
@Bean
|
||||
public org.springframework.data.redis.cache.RedisCacheConfiguration customRedisCacheConfiguration() {
|
||||
return org.springframework.data.redis.cache.RedisCacheConfiguration
|
||||
.defaultCacheConfig()
|
||||
.entryTtl(java.time.Duration.ofSeconds(30))
|
||||
.defaultCacheConfig().entryTtl(java.time.Duration.ofSeconds(30))
|
||||
.prefixKeysWith("bar");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,8 +67,8 @@ public class MongoRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testNoRepositoryConfiguration() {
|
||||
this.runner.withUserConfiguration(EmptyConfiguration.class).run((context) ->
|
||||
assertThat(context).hasSingleBean(MongoClient.class));
|
||||
this.runner.withUserConfiguration(EmptyConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(MongoClient.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,8 +60,7 @@ public class DataSourceInitializerInvokerTests {
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class))
|
||||
.withPropertyValues("spring.datasource.initialization-mode=never",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:init-"
|
||||
+ UUID.randomUUID());
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:init-" + UUID.randomUUID());
|
||||
|
||||
@Test
|
||||
public void dataSourceInitialized() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -194,8 +194,7 @@ public class MailSenderAutoConfigurationTests {
|
||||
verify(mailSender, never()).testConnection();
|
||||
}
|
||||
|
||||
private Session configureJndiSession(String name)
|
||||
throws IllegalStateException {
|
||||
private Session configureJndiSession(String name) throws IllegalStateException {
|
||||
Properties properties = new Properties();
|
||||
Session session = Session.getDefaultInstance(properties);
|
||||
TestableInitialContextFactory.bind(name, session);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,8 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
|
||||
context.refresh();
|
||||
int port = context.getWebServer().getPort();
|
||||
String password = this.outputCapture.toString()
|
||||
.split("Using generated security password: ")[1].split("\n")[0].trim();
|
||||
.split("Using generated security password: ")[1].split("\n")[0]
|
||||
.trim();
|
||||
new TestRestTemplate("user", password)
|
||||
.getForEntity("http://localhost:" + port, Object.class);
|
||||
// If early initialization occurred a ConverterNotFoundException is thrown
|
||||
|
||||
@@ -153,24 +153,24 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
|
||||
|
||||
@Test
|
||||
public void sessionCookieConfigurationIsPickedUp() {
|
||||
new WebApplicationContextRunner(
|
||||
WebApplicationContextRunner webRunner = new WebApplicationContextRunner(
|
||||
AnnotationConfigServletWebServerApplicationContext::new)
|
||||
.withConfiguration(AutoConfigurations
|
||||
.of(ServletWebServerFactoryAutoConfiguration.class))
|
||||
.withUserConfiguration(SessionRepositoryConfiguration.class)
|
||||
.withPropertyValues("server.port=0",
|
||||
"server.servlet.session.cookie.name=testname")
|
||||
.run((context) -> {
|
||||
SessionRepositoryFilter<?> filter = context
|
||||
.getBean(SessionRepositoryFilter.class);
|
||||
CookieHttpSessionIdResolver sessionIdResolver = (CookieHttpSessionIdResolver) ReflectionTestUtils
|
||||
.getField(filter, "httpSessionIdResolver");
|
||||
DefaultCookieSerializer cookieSerializer = (DefaultCookieSerializer) ReflectionTestUtils
|
||||
.getField(sessionIdResolver, "cookieSerializer");
|
||||
String cookieName = (String) ReflectionTestUtils
|
||||
.getField(cookieSerializer, "cookieName");
|
||||
assertThat(cookieName).isEqualTo("testname");
|
||||
});
|
||||
"server.servlet.session.cookie.name=testname");
|
||||
webRunner.run((context) -> {
|
||||
SessionRepositoryFilter<?> filter = context
|
||||
.getBean(SessionRepositoryFilter.class);
|
||||
CookieHttpSessionIdResolver sessionIdResolver = (CookieHttpSessionIdResolver) ReflectionTestUtils
|
||||
.getField(filter, "httpSessionIdResolver");
|
||||
DefaultCookieSerializer cookieSerializer = (DefaultCookieSerializer) ReflectionTestUtils
|
||||
.getField(sessionIdResolver, "cookieSerializer");
|
||||
String cookieName = (String) ReflectionTestUtils.getField(cookieSerializer,
|
||||
"cookieName");
|
||||
assertThat(cookieName).isEqualTo("testname");
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -170,7 +170,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
public void defaultTomcatBackgroundProcessorDelay() {
|
||||
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory();
|
||||
this.customizer.customize(factory);
|
||||
TomcatWebServer webServer = (TomcatWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
TomcatWebServer webServer = (TomcatWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
assertThat(webServer.getTomcat().getEngine().getBackgroundProcessorDelay())
|
||||
.isEqualTo(30);
|
||||
webServer.stop();
|
||||
@@ -183,7 +184,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
bindProperties(map);
|
||||
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory();
|
||||
this.customizer.customize(factory);
|
||||
TomcatWebServer webServer = (TomcatWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
TomcatWebServer webServer = (TomcatWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
assertThat(webServer.getTomcat().getEngine().getBackgroundProcessorDelay())
|
||||
.isEqualTo(5);
|
||||
webServer.stop();
|
||||
@@ -261,7 +263,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
bindProperties(map);
|
||||
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory(0);
|
||||
this.customizer.customize(factory);
|
||||
TomcatWebServer server = (TomcatWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
TomcatWebServer server = (TomcatWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
server.start();
|
||||
try {
|
||||
assertThat(((AbstractProtocol<?>) server.getTomcat().getConnector()
|
||||
@@ -279,7 +282,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
bindProperties(map);
|
||||
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory(0);
|
||||
this.customizer.customize(factory);
|
||||
TomcatWebServer server = (TomcatWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
TomcatWebServer server = (TomcatWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
server.start();
|
||||
try {
|
||||
assertThat(((AbstractProtocol<?>) server.getTomcat().getConnector()
|
||||
@@ -297,7 +301,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
bindProperties(map);
|
||||
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory(0);
|
||||
this.customizer.customize(factory);
|
||||
TomcatWebServer server = (TomcatWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
TomcatWebServer server = (TomcatWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
server.start();
|
||||
try {
|
||||
assertThat(server.getTomcat().getConnector().getMaxPostSize())
|
||||
@@ -315,7 +320,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
bindProperties(map);
|
||||
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory(0);
|
||||
this.customizer.customize(factory);
|
||||
TomcatWebServer server = (TomcatWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
TomcatWebServer server = (TomcatWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
server.start();
|
||||
try {
|
||||
assertThat(server.getTomcat().getConnector().getMaxPostSize()).isEqualTo(-1);
|
||||
@@ -340,7 +346,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
bindProperties(map);
|
||||
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory(0);
|
||||
this.customizer.customize(factory);
|
||||
TomcatWebServer server = (TomcatWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
TomcatWebServer server = (TomcatWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
server.start();
|
||||
try {
|
||||
Tomcat tomcat = server.getTomcat();
|
||||
@@ -382,7 +389,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
map.put("server.jetty.accesslog.enabled", "true");
|
||||
bindProperties(map);
|
||||
this.customizer.customize(factory);
|
||||
JettyWebServer webServer = (JettyWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
JettyWebServer webServer = (JettyWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
try {
|
||||
NCSARequestLog requestLog = getNCSARequestLog(webServer);
|
||||
assertThat(requestLog.getFilename()).isNull();
|
||||
@@ -417,7 +425,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
map.put("server.jetty.accesslog.log-latency", "true");
|
||||
bindProperties(map);
|
||||
this.customizer.customize(factory);
|
||||
JettyWebServer webServer = (JettyWebServer) factory.getWebServer(mock(HttpHandler.class));
|
||||
JettyWebServer webServer = (JettyWebServer) factory
|
||||
.getWebServer(mock(HttpHandler.class));
|
||||
NCSARequestLog requestLog = getNCSARequestLog(webServer);
|
||||
try {
|
||||
assertThat(requestLog.getFilename()).isEqualTo(logFile.getAbsolutePath());
|
||||
@@ -461,7 +470,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
|
||||
@Test
|
||||
public void setUseForwardHeadersUndertow() {
|
||||
this.properties.setUseForwardHeaders(true);
|
||||
UndertowReactiveWebServerFactory factory = spy(new UndertowReactiveWebServerFactory());
|
||||
UndertowReactiveWebServerFactory factory = spy(
|
||||
new UndertowReactiveWebServerFactory());
|
||||
this.customizer.customize(factory);
|
||||
verify(factory).setUseForwardHeaders(true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,8 +54,9 @@ public class ReactiveWebServerAutoConfigurationTests {
|
||||
.hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(WebServerFactoryCustomizer.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(DefaultReactiveWebServerFactoryCustomizer.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.context
|
||||
.getBeansOfType(DefaultReactiveWebServerFactoryCustomizer.class))
|
||||
.hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -233,8 +233,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
|
||||
.contentType(MediaType.TEXT_HTML).expectBody(String.class)
|
||||
.returnResult().getResponseBody();
|
||||
assertThat(body).contains("Whitelabel Error Page")
|
||||
.doesNotContain("<script>")
|
||||
.contains("<script>");
|
||||
.doesNotContain("<script>").contains("<script>");
|
||||
this.output.expect(
|
||||
allOf(containsString("Failed to handle request [GET /html]"),
|
||||
containsString("IllegalStateException")));
|
||||
|
||||
@@ -471,9 +471,10 @@ public class WebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customMediaTypes() {
|
||||
this.contextRunner.withPropertyValues(
|
||||
"spring.mvc.content-negotiation.media-types.yaml:text/yaml",
|
||||
"spring.mvc.content-negotiation.favor-path-extension:true")
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.mvc.content-negotiation.media-types.yaml:text/yaml",
|
||||
"spring.mvc.content-negotiation.favor-path-extension:true")
|
||||
.run((context) -> {
|
||||
RequestMappingHandlerAdapter adapter = context
|
||||
.getBean(RequestMappingHandlerAdapter.class);
|
||||
@@ -744,7 +745,8 @@ public class WebMvcAutoConfigurationTests {
|
||||
@Test
|
||||
public void defaultPathMatching() {
|
||||
this.contextRunner.run((context) -> {
|
||||
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
|
||||
RequestMappingHandlerMapping handlerMapping = context
|
||||
.getBean(RequestMappingHandlerMapping.class);
|
||||
assertThat(handlerMapping.useSuffixPatternMatch()).isFalse();
|
||||
assertThat(handlerMapping.useRegisteredSuffixPatternMatch()).isFalse();
|
||||
});
|
||||
@@ -756,34 +758,40 @@ public class WebMvcAutoConfigurationTests {
|
||||
.withPropertyValues("spring.mvc.path-match.use-suffix-pattern:true",
|
||||
"spring.mvc.path-match.use-registered-suffix-pattern:true")
|
||||
.run((context) -> {
|
||||
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
|
||||
assertThat(handlerMapping.useSuffixPatternMatch()).isTrue();
|
||||
assertThat(handlerMapping.useRegisteredSuffixPatternMatch()).isTrue();
|
||||
});
|
||||
RequestMappingHandlerMapping handlerMapping = context
|
||||
.getBean(RequestMappingHandlerMapping.class);
|
||||
assertThat(handlerMapping.useSuffixPatternMatch()).isTrue();
|
||||
assertThat(handlerMapping.useRegisteredSuffixPatternMatch()).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultContentNegotiation() {
|
||||
this.contextRunner.run((context) -> {
|
||||
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
|
||||
ContentNegotiationManager contentNegotiationManager = handlerMapping.getContentNegotiationManager();
|
||||
RequestMappingHandlerMapping handlerMapping = context
|
||||
.getBean(RequestMappingHandlerMapping.class);
|
||||
ContentNegotiationManager contentNegotiationManager = handlerMapping
|
||||
.getContentNegotiationManager();
|
||||
assertThat(contentNegotiationManager.getStrategies())
|
||||
.doesNotHaveAnyElementsOfTypes(WebMvcAutoConfiguration
|
||||
.OptionalPathExtensionContentNegotiationStrategy.class);
|
||||
.doesNotHaveAnyElementsOfTypes(
|
||||
WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pathExtensionContentNegotiation() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.mvc.content-negotiation.favor-path-extension:true")
|
||||
.withPropertyValues(
|
||||
"spring.mvc.content-negotiation.favor-path-extension:true")
|
||||
.run((context) -> {
|
||||
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
|
||||
ContentNegotiationManager contentNegotiationManager = handlerMapping.getContentNegotiationManager();
|
||||
assertThat(contentNegotiationManager.getStrategies())
|
||||
.hasAtLeastOneElementOfType(WebMvcAutoConfiguration
|
||||
.OptionalPathExtensionContentNegotiationStrategy.class);
|
||||
});
|
||||
RequestMappingHandlerMapping handlerMapping = context
|
||||
.getBean(RequestMappingHandlerMapping.class);
|
||||
ContentNegotiationManager contentNegotiationManager = handlerMapping
|
||||
.getContentNegotiationManager();
|
||||
assertThat(contentNegotiationManager.getStrategies())
|
||||
.hasAtLeastOneElementOfType(
|
||||
WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -791,10 +799,13 @@ public class WebMvcAutoConfigurationTests {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.mvc.content-negotiation.favor-parameter:true")
|
||||
.run((context) -> {
|
||||
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
|
||||
ContentNegotiationManager contentNegotiationManager = handlerMapping.getContentNegotiationManager();
|
||||
RequestMappingHandlerMapping handlerMapping = context
|
||||
.getBean(RequestMappingHandlerMapping.class);
|
||||
ContentNegotiationManager contentNegotiationManager = handlerMapping
|
||||
.getContentNegotiationManager();
|
||||
assertThat(contentNegotiationManager.getStrategies())
|
||||
.hasAtLeastOneElementOfType(ParameterContentNegotiationStrategy.class);
|
||||
.hasAtLeastOneElementOfType(
|
||||
ParameterContentNegotiationStrategy.class);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -75,7 +75,8 @@ public class WelcomePageHandlerMappingTests {
|
||||
public void handlesRequestForStaticPageThatAcceptsAll() {
|
||||
this.contextRunner.withUserConfiguration(StaticResourceConfiguration.class)
|
||||
.run((context) -> MockMvcBuilders.webAppContextSetup(context).build()
|
||||
.perform(get("/").accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.perform(get("/").accept(MediaType.ALL))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(forwardedUrl("index.html")));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,11 +57,11 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
|
||||
import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
import org.springframework.web.socket.messaging.WebSocketStompClient;
|
||||
import org.springframework.web.socket.sockjs.client.RestTemplateXhrTransport;
|
||||
import org.springframework.web.socket.sockjs.client.SockJsClient;
|
||||
@@ -213,7 +213,7 @@ public class WebSocketMessagingAutoConfigurationTests {
|
||||
WebSocketMessagingAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class })
|
||||
static class WebSocketMessagingConfiguration
|
||||
extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
|
||||
Reference in New Issue
Block a user