Merge branch '2.0.x'

This commit is contained in:
Phillip Webb
2018-05-04 16:31:46 -07:00
127 changed files with 419 additions and 210 deletions

View File

@@ -458,6 +458,7 @@ public class RabbitProperties {
public void setCheckoutTimeout(Duration checkoutTimeout) {
this.checkoutTimeout = checkoutTimeout;
}
}
public static class Connection {

View File

@@ -75,8 +75,7 @@ public class CacheAutoConfiguration {
@Bean
public CacheManagerValidator cacheAutoConfigurationValidator(
CacheProperties cacheProperties,
ObjectProvider<CacheManager> cacheManager) {
CacheProperties cacheProperties, ObjectProvider<CacheManager> cacheManager) {
return new CacheManagerValidator(cacheProperties, cacheManager);
}

View File

@@ -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.
@@ -77,4 +77,5 @@ class FreeMarkerServletWebConfiguration extends AbstractFreeMarkerConfiguration
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
return new ResourceUrlEncodingFilter();
}
}

View File

@@ -34,4 +34,5 @@ public interface GsonBuilderCustomizer {
* @param gsonBuilder the GsonBuilder to customize
*/
void customize(GsonBuilder gsonBuilder);
}

View File

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

View File

@@ -62,8 +62,8 @@ class DataSourceBeanCreationFailureAnalyzer
if (!StringUtils.hasText(cause.getProperties().getUrl())) {
description.append("'url' attribute is not specified and ");
}
description.append(
String.format("no embedded datasource could be configured.%n"));
description
.append(String.format("no embedded datasource could be configured.%n"));
description.append(String.format("%nReason: %s%n", cause.getMessage()));
return description.toString();
}

View File

@@ -142,6 +142,7 @@ public final class StaticResourceRequest {
getDelegateMatchers());
return matcher.matches(exchange);
}
}
}

View File

@@ -191,6 +191,7 @@ public class SessionAutoConfiguration {
// Ignore
}
}
}
/**

View File

@@ -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,6 +75,7 @@ public class TransactionAutoConfiguration {
public TransactionTemplate transactionTemplate() {
return new TransactionTemplate(this.transactionManager);
}
}
@Configuration

View File

@@ -957,6 +957,7 @@ public class ServerProperties {
public void setLogLatency(boolean logLatency) {
this.logLatency = logLatency;
}
}
}

View File

@@ -88,8 +88,12 @@ public class DispatcherServletAutoConfiguration {
private final WebMvcProperties webMvcProperties;
public DispatcherServletConfiguration(WebMvcProperties webMvcProperties) {
private final ServerProperties serverProperties;
public DispatcherServletConfiguration(WebMvcProperties webMvcProperties,
ServerProperties serverProperties) {
this.webMvcProperties = webMvcProperties;
this.serverProperties = serverProperties;
}
@Bean(name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
@@ -112,6 +116,12 @@ public class DispatcherServletAutoConfiguration {
return resolver;
}
@Bean
public DispatcherServletPathProvider mainDispatcherServletPathProvider() {
return () -> DispatcherServletConfiguration.this.serverProperties.getServlet()
.getPath();
}
}
@Configuration

View File

@@ -0,0 +1,33 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.servlet;
import org.springframework.web.servlet.DispatcherServlet;
/**
* Interface that provides the path of the {@link DispatcherServlet} in an application
* context.
*
* @author Madhura Bhave
* @since 2.0.2
*/
@FunctionalInterface
public interface DispatcherServletPathProvider {
String getServletPath();
}

View File

@@ -752,11 +752,10 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
public void autoConfiguredCacheManagerCanBeSwapped() {
this.contextRunner
.withUserConfiguration(CacheManagerPostProcessorConfiguration.class)
.withPropertyValues("spring.cache.type=caffeine")
.run((context) -> {
.withPropertyValues("spring.cache.type=caffeine").run((context) -> {
getCacheManager(context, SimpleCacheManager.class);
CacheManagerPostProcessor postProcessor = context.getBean(
CacheManagerPostProcessor.class);
CacheManagerPostProcessor postProcessor = context
.getBean(CacheManagerPostProcessor.class);
assertThat(postProcessor.cacheManagers).hasSize(1);
assertThat(postProcessor.cacheManagers.get(0))
.isInstanceOf(CaffeineCacheManager.class);
@@ -1043,14 +1042,12 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
private final List<CacheManager> cacheManagers = new ArrayList<>();
@Override
public Object postProcessBeforeInitialization(Object bean,
String beanName) {
public Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean,
String beanName) {
public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof CacheManager) {
this.cacheManagers.add((CacheManager) bean);
return new SimpleCacheManager();

View File

@@ -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.
@@ -158,6 +158,7 @@ public class CassandraDataAutoConfigurationTests {
public String convert(Person o) {
return null;
}
}
private static class Person {

View File

@@ -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.
@@ -186,6 +186,7 @@ public class CouchbaseDataAutoConfigurationTests {
public Boolean convert(CouchbaseProperties value) {
return true;
}
}
}

View File

@@ -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.
@@ -76,6 +76,7 @@ public class ElasticsearchNodeTemplate {
Arrays.asList(Netty4Plugin.class));
new File("target/es/node/logs").mkdirs();
}
}
public final class ElasticsearchNode {

View File

@@ -291,6 +291,7 @@ public class GsonAutoConfigurationTests {
private String data = "nested";
}
}
}

View File

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

View File

@@ -80,16 +80,16 @@ public class IntegrationAutoConfigurationTests {
.withUserConfiguration(CustomIntegrationComponentScanConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(TestGateway.class);
assertThat(context).doesNotHaveBean(
IntegrationComponentScanConfiguration.class);
assertThat(context)
.doesNotHaveBean(IntegrationComponentScanConfiguration.class);
});
}
@Test
public void noMBeanServerAvailable() {
ApplicationContextRunner contextRunnerWithoutJmx = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
IntegrationAutoConfiguration.class));
.withConfiguration(
AutoConfigurations.of(IntegrationAutoConfiguration.class));
contextRunnerWithoutJmx.run((context) -> {
assertThat(context).hasSingleBean(TestGateway.class);
assertThat(context)

View File

@@ -232,6 +232,7 @@ public class ActiveMQAutoConfigurationTests {
factory.setUserName("foobar");
};
}
}
}

View File

@@ -96,4 +96,5 @@ public class ArtemisEmbeddedConfigurationFactoryTests {
.getAddressConfigurations();
assertThat(addressConfigurations).hasSize(2);
}
}

View File

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

View File

@@ -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.
@@ -55,6 +55,7 @@ public class JsonbAutoConfigurationTests {
public void setData(String data) {
this.data = data;
}
}
}

View File

@@ -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.
@@ -127,6 +127,7 @@ public class MustacheAutoConfigurationTests {
return Mustache.compiler().standardsMode(true)
.withLoader(mustacheTemplateLoader);
}
}
}

View File

@@ -87,21 +87,24 @@ public class QuartzAutoConfigurationTests {
@Test
public void withDataSourceUseMemoryByDefault() {
this.contextRunner.withConfiguration(AutoConfigurations.of(
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class)).run((context) -> {
assertThat(context).hasSingleBean(Scheduler.class);
Scheduler scheduler = context.getBean(Scheduler.class);
assertThat(scheduler.getMetaData().getJobStoreClass())
.isAssignableFrom(RAMJobStore.class);
});
this.contextRunner
.withConfiguration(
AutoConfigurations.of(DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class))
.run((context) -> {
assertThat(context).hasSingleBean(Scheduler.class);
Scheduler scheduler = context.getBean(Scheduler.class);
assertThat(scheduler.getMetaData().getJobStoreClass())
.isAssignableFrom(RAMJobStore.class);
});
}
@Test
public void withDataSource() {
this.contextRunner.withUserConfiguration(QuartzJobsConfiguration.class)
.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class))
.withConfiguration(
AutoConfigurations.of(DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class))
.withPropertyValues("spring.quartz.job-store-type=jdbc")
.run(assertDataSourceJobStore("dataSource"));
}
@@ -109,8 +112,8 @@ public class QuartzAutoConfigurationTests {
@Test
public void withDataSourceNoTransactionManager() {
this.contextRunner.withUserConfiguration(QuartzJobsConfiguration.class)
.withConfiguration(AutoConfigurations.of(
DataSourceAutoConfiguration.class))
.withConfiguration(
AutoConfigurations.of(DataSourceAutoConfiguration.class))
.withPropertyValues("spring.quartz.job-store-type=jdbc")
.run(assertDataSourceJobStore("dataSource"));
}
@@ -131,13 +134,13 @@ public class QuartzAutoConfigurationTests {
Scheduler scheduler = context.getBean(Scheduler.class);
assertThat(scheduler.getMetaData().getJobStoreClass())
.isAssignableFrom(LocalDataSourceJobStore.class);
JdbcTemplate jdbcTemplate = new JdbcTemplate(context.getBean(
datasourceName, DataSource.class));
JdbcTemplate jdbcTemplate = new JdbcTemplate(
context.getBean(datasourceName, DataSource.class));
assertThat(jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM QRTZ_JOB_DETAILS", Integer.class)).isEqualTo(2);
assertThat(jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM QRTZ_SIMPLE_TRIGGERS", Integer.class))
.isEqualTo(0);
.isEqualTo(0);
};
}
@@ -185,8 +188,9 @@ public class QuartzAutoConfigurationTests {
@Test
public void withQuartzProperties() {
this.contextRunner.withPropertyValues(
"spring.quartz.properties.org.quartz.scheduler.instanceId=FOO")
this.contextRunner
.withPropertyValues(
"spring.quartz.properties.org.quartz.scheduler.instanceId=FOO")
.run((context) -> {
assertThat(context).hasSingleBean(Scheduler.class);
Scheduler scheduler = context.getBean(Scheduler.class);
@@ -204,8 +208,6 @@ public class QuartzAutoConfigurationTests {
});
}
@Import(ComponentThatUsesScheduler.class)
@Configuration
protected static class BaseQuartzConfiguration {

View File

@@ -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.
@@ -203,6 +203,7 @@ public class TransactionAutoConfigurationTests {
public AnotherServiceImpl anotherService() {
return new AnotherServiceImpl();
}
}
@Configuration

View File

@@ -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.
@@ -304,6 +304,7 @@ public class ValidationAutoConfigurationTests {
interface AnotherSampleService {
void doSomething(@Min(42) Integer counter);
}
@Validated
@@ -313,6 +314,7 @@ public class ValidationAutoConfigurationTests {
public void doSomething(Integer counter) {
}
}
@Configuration
@@ -382,6 +384,7 @@ public class ValidationAutoConfigurationTests {
}
}
}
}

View File

@@ -373,6 +373,7 @@ public class WebFluxAutoConfigurationTests {
public CodecCustomizer firstCodecCustomizer() {
return mock(CodecCustomizer.class);
}
}
@Configuration
@@ -388,6 +389,7 @@ public class WebFluxAutoConfigurationTests {
public ViewResolver anotherViewResolver() {
return mock(ViewResolver.class);
}
}
@Configuration
@@ -407,6 +409,7 @@ public class WebFluxAutoConfigurationTests {
public HttpHandler httpHandler() {
return (serverHttpRequest, serverHttpResponse) -> null;
}
}
@Configuration

View File

@@ -311,6 +311,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
public String bodyValidation(@Valid @RequestBody DummyBody body) {
return body.getContent();
}
}
}

View File

@@ -107,6 +107,8 @@ public class DispatcherServletAutoConfigurationTests {
assertThat(registration.getUrlMappings().toString())
.isEqualTo("[/spring/*]");
assertThat(registration.getMultipartConfig()).isNull();
assertThat(context.getBean(DispatcherServletPathProvider.class)
.getServletPath()).isEqualTo("/spring");
});
}

View File

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

View File

@@ -109,4 +109,5 @@ public class TomcatServletWebServerFactoryCustomizerTests {
this.customizer.customize(factory);
return factory;
}
}

View File

@@ -829,12 +829,13 @@ public class WebMvcAutoConfigurationTests {
@Test
public void contentNegotiationStrategySkipsPathExtension() throws Exception {
ContentNegotiationStrategy delegate = mock(ContentNegotiationStrategy.class);
ContentNegotiationStrategy strategy = new WebMvcAutoConfiguration
.OptionalPathExtensionContentNegotiationStrategy(delegate);
ContentNegotiationStrategy strategy = new WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy(
delegate);
MockHttpServletRequest request = new MockHttpServletRequest();
request.setAttribute(PathExtensionContentNegotiationStrategy.class
.getName() + ".SKIP", Boolean.TRUE);
request.setAttribute(
PathExtensionContentNegotiationStrategy.class.getName() + ".SKIP",
Boolean.TRUE);
ServletWebRequest webRequest = new ServletWebRequest(request);
List<MediaType> mediaTypes = strategy.resolveMediaTypes(webRequest);
assertThat(mediaTypes).containsOnly(MediaType.ALL);

View File

@@ -68,8 +68,7 @@ public class WelcomePageHandlerMappingTests {
.run((context) -> {
WelcomePageHandlerMapping handler = context
.getBean(WelcomePageHandlerMapping.class);
assertThat(handler.getOrder())
.isEqualTo(2);
assertThat(handler.getOrder()).isEqualTo(2);
});
}