Polish
Closes gh-11418
This commit is contained in:
committed by
Stephane Nicoll
parent
644359920b
commit
3c5ccb1166
@@ -72,6 +72,8 @@ public class AutoConfigurationImportSelector
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(AutoConfigurationImportSelector.class);
|
||||
|
||||
private static final String PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE = "spring.autoconfigure.exclude";
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private Environment environment;
|
||||
@@ -213,13 +215,12 @@ public class AutoConfigurationImportSelector
|
||||
}
|
||||
|
||||
private List<String> getExcludeAutoConfigurationsProperty() {
|
||||
String name = "spring.autoconfigure.exclude";
|
||||
if (getEnvironment() instanceof ConfigurableEnvironment) {
|
||||
Binder binder = Binder.get(getEnvironment());
|
||||
return binder.bind(name, String[].class).map(Arrays::asList)
|
||||
return binder.bind(PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE, String[].class).map(Arrays::asList)
|
||||
.orElse(Collections.emptyList());
|
||||
}
|
||||
String[] excludes = getEnvironment().getProperty(name, String[].class);
|
||||
String[] excludes = getEnvironment().getProperty(PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE, String[].class);
|
||||
return (excludes == null ? Collections.emptyList() : Arrays.asList(excludes));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.web.servlet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -35,7 +36,7 @@ import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
/**
|
||||
* An {@link AbstractUrlHandlerMapping} for an application's welcome page. Supports both
|
||||
* static and templated files. If both a static and templated index page is available, the
|
||||
* static and templated files. If both a static and templated index page are available, the
|
||||
* static page is preferred.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
@@ -45,6 +46,8 @@ final class WelcomePageHandlerMapping extends AbstractUrlHandlerMapping {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(WelcomePageHandlerMapping.class);
|
||||
|
||||
private static final List<MediaType> MEDIA_TYPES_ALL = Collections.singletonList(MediaType.ALL);
|
||||
|
||||
WelcomePageHandlerMapping(TemplateAvailabilityProviders templateAvailabilityProviders,
|
||||
ApplicationContext applicationContext, Optional<Resource> welcomePage,
|
||||
String staticPathPattern) {
|
||||
@@ -85,8 +88,10 @@ final class WelcomePageHandlerMapping extends AbstractUrlHandlerMapping {
|
||||
|
||||
private List<MediaType> getAcceptedMediaTypes(HttpServletRequest request) {
|
||||
String acceptHeader = request.getHeader(HttpHeaders.ACCEPT);
|
||||
return MediaType.parseMediaTypes(
|
||||
StringUtils.hasText(acceptHeader) ? acceptHeader : "*/*");
|
||||
if (StringUtils.hasText(acceptHeader)) {
|
||||
return MediaType.parseMediaTypes(acceptHeader);
|
||||
}
|
||||
return MEDIA_TYPES_ALL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CassandraRepositoriesAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enablingNoRepositoriesDisablesReactiveRepositories() {
|
||||
public void enablingNoRepositoriesDisablesImperativeRepositories() {
|
||||
this.runner.withUserConfiguration(TestConfiguration.class)
|
||||
.withPropertyValues("spring.data.cassandra.repositories.type=none")
|
||||
.run((context) -> assertThat(context)
|
||||
|
||||
@@ -97,7 +97,7 @@ public class MongoRepositoriesAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enablingNoRepositoriesDisablesReactiveRepositories() {
|
||||
public void enablingNoRepositoriesDisablesImperativeRepositories() {
|
||||
this.runner.withUserConfiguration(TestConfiguration.class)
|
||||
.withPropertyValues("spring.data.mongodb.repositories.type=none")
|
||||
.run((context) -> assertThat(context)
|
||||
|
||||
@@ -293,7 +293,7 @@ public class SecurityAutoConfigurationTests {
|
||||
protected static class TestUserDetailsServiceConfiguration {
|
||||
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager myUserDetailsService() {
|
||||
public InMemoryUserDetailsManager myUserDetailsManager() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
User.withUsername("foo").password("bar").roles("USER").build());
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WelcomePageHandlerMappingTests {
|
||||
public void handlesRequestForStaticPageThatAcceptsAll() {
|
||||
this.contextRunner.withUserConfiguration(StaticResourceConfiguration.class)
|
||||
.run((context) -> MockMvcBuilders.webAppContextSetup(context).build()
|
||||
.perform(get("/").accept("*/*")).andExpect(status().isOk())
|
||||
.perform(get("/").accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andExpect(forwardedUrl("index.html")));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user