This commit is contained in:
Phillip Webb
2015-09-02 20:17:28 -07:00
parent db41fb16c0
commit 6193b640a4
57 changed files with 364 additions and 310 deletions

View File

@@ -16,9 +16,6 @@
package org.springframework.boot.autoconfigure;
import static org.springframework.util.StringUtils.commaDelimitedListToStringArray;
import static org.springframework.util.StringUtils.trimAllWhitespace;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Iterator;
@@ -44,6 +41,9 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.StringUtils;
import static org.springframework.util.StringUtils.commaDelimitedListToStringArray;
import static org.springframework.util.StringUtils.trimAllWhitespace;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link MessageSource}.
*
@@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
* @author Eddú Meléndez
*/
@Configuration
@ConditionalOnMissingBean(value=MessageSource.class, search=SearchStrategy.CURRENT)
@ConditionalOnMissingBean(value = MessageSource.class, search = SearchStrategy.CURRENT)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@Conditional(ResourceBundleCondition.class)
@EnableConfigurationProperties
@@ -81,8 +81,8 @@ public class MessageSourceAutoConfiguration {
/**
* Set whether to fall back to the system Locale if no files for a specific Locale
* have been found. if this is turned off, the only fallback will be the default
* file (e.g. "messages.properties" for basename "messages").
* have been found. if this is turned off, the only fallback will be the default file
* (e.g. "messages.properties" for basename "messages").
*/
private boolean fallbackToSystemLocale = true;
@@ -91,7 +91,7 @@ public class MessageSourceAutoConfiguration {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
if (StringUtils.hasText(this.basename)) {
messageSource
.setBasenames(commaDelimitedListToStringArray(trimAllWhitespace(this.basename)));
.setBasenames(commaDelimitedListToStringArray(trimAllWhitespace(this.basename)));
}
if (this.encoding != null) {
messageSource.setDefaultEncoding(this.encoding.name());
@@ -167,7 +167,7 @@ public class MessageSourceAutoConfiguration {
private Resource[] getResources(ClassLoader classLoader, String name) {
try {
return new SkipPatternPathMatchingResourcePatternResolver(classLoader)
.getResources("classpath*:" + name + "*.properties");
.getResources("classpath*:" + name + "*.properties");
}
catch (Exception ex) {
return NO_RESOURCES;
@@ -181,7 +181,7 @@ public class MessageSourceAutoConfiguration {
* contain messages.properties.
*/
private static class SkipPatternPathMatchingResourcePatternResolver extends
PathMatchingResourcePatternResolver {
PathMatchingResourcePatternResolver {
private static final ClassLoader ROOT_CLASSLOADER;
static {
@@ -198,14 +198,14 @@ public class MessageSourceAutoConfiguration {
}
private static final String[] SKIPPED = { "aspectjweaver-", "hibernate-core-",
"hsqldb-", "jackson-annotations-", "jackson-core-", "jackson-databind-",
"javassist-", "snakeyaml-", "spring-aop-", "spring-beans-",
"spring-boot-", "spring-boot-actuator-", "spring-boot-autoconfigure-",
"spring-core-", "spring-context-", "spring-data-commons-",
"spring-expression-", "spring-jdbc-", "spring-orm-", "spring-tx-",
"spring-web-", "spring-webmvc-", "tomcat-embed-", "joda-time-",
"hibernate-entitymanager-", "hibernate-validator-", "logback-classic-",
"logback-core-", "thymeleaf-" };
"hsqldb-", "jackson-annotations-", "jackson-core-", "jackson-databind-",
"javassist-", "snakeyaml-", "spring-aop-", "spring-beans-",
"spring-boot-", "spring-boot-actuator-", "spring-boot-autoconfigure-",
"spring-core-", "spring-context-", "spring-data-commons-",
"spring-expression-", "spring-jdbc-", "spring-orm-", "spring-tx-",
"spring-web-", "spring-webmvc-", "tomcat-embed-", "joda-time-",
"hibernate-entitymanager-", "hibernate-validator-", "logback-classic-",
"logback-core-", "thymeleaf-" };
public SkipPatternPathMatchingResourcePatternResolver(ClassLoader classLoader) {
super(classLoader);

View File

@@ -63,9 +63,8 @@ public @interface SpringBootApplication {
String[] excludeName() default {};
/**
* Base packages to scan for annotated components.
* <p>Use {@link #scanBasePackageClasses} for a type-safe alternative to
* String-based package names.
* Base packages to scan for annotated components. Use {@link #scanBasePackageClasses}
* for a type-safe alternative to String-based package names.
* @return base packages to scan
* @since 1.3.0
*/
@@ -73,10 +72,11 @@ public @interface SpringBootApplication {
String[] scanBasePackages() default {};
/**
* Type-safe alternative to {@link #scanBasePackages} for specifying the packages
* to scan for annotated components. The package of each class specified will be scanned.
* <p>Consider creating a special no-op marker class or interface in each package
* that serves no purpose other than being referenced by this attribute.
* Type-safe alternative to {@link #scanBasePackages} for specifying the packages to
* scan for annotated components. The package of each class specified will be scanned.
* <p>
* Consider creating a special no-op marker class or interface in each package that
* serves no purpose other than being referenced by this attribute.
* @return base packages to scan
* @since 1.3.0
*/

View File

@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jdbc;
import java.nio.charset.Charset;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.beans.factory.BeanClassLoaderAware;
@@ -48,8 +49,8 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB
private String name = "testdb";
/**
* Fully qualified name of the connection pool implementation to use. By default,
* it is auto-detected from the classpath.
* Fully qualified name of the connection pool implementation to use. By default, it
* is auto-detected from the classpath.
*/
private Class<? extends DataSource> type;

View File

@@ -134,8 +134,8 @@ public class JpaProperties {
/**
* DDL mode. This is actually a shortcut for the "hibernate.hbm2ddl.auto"
* property. Default to "create-drop" when using an embedded database,
* "none" otherwise.
* property. Default to "create-drop" when using an embedded database, "none"
* otherwise.
*/
private String ddlAuto;

View File

@@ -69,7 +69,6 @@ public class AuthenticationManagerConfiguration {
private static Log logger = LogFactory
.getLog(AuthenticationManagerConfiguration.class);
@SuppressWarnings("unused")
@Autowired
private List<SecurityPrerequisite> dependencies;
@@ -112,7 +111,7 @@ public class AuthenticationManagerConfiguration {
*/
@Order(Ordered.LOWEST_PRECEDENCE - 100)
private static class SpringBootAuthenticationConfigurerAdapter extends
GlobalAuthenticationConfigurerAdapter {
GlobalAuthenticationConfigurerAdapter {
private final SecurityProperties securityProperties;
@@ -152,7 +151,7 @@ public class AuthenticationManagerConfiguration {
* </ul>
*/
private static class DefaultInMemoryUserDetailsManagerConfigurer extends
InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> {
InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> {
private final SecurityProperties securityProperties;
@@ -169,7 +168,7 @@ public class AuthenticationManagerConfiguration {
User user = this.securityProperties.getUser();
if (user.isDefaultPassword()) {
logger.info("\n\nUsing default security password: " + user.getPassword()
+ "\n");
+ "\n");
}
Set<String> roles = new LinkedHashSet<String>(user.getRole());
withUser(user.getName()).password(user.getPassword()).roles(
@@ -197,7 +196,7 @@ public class AuthenticationManagerConfiguration {
*/
@Component
protected static class AuthenticationManagerConfigurationListener implements
SmartInitializingSingleton {
SmartInitializingSingleton {
@Autowired
private AuthenticationEventPublisher eventPublisher;
@@ -219,7 +218,7 @@ public class AuthenticationManagerConfiguration {
private void configureAuthenticationManager(AuthenticationManager manager) {
if (manager instanceof ProviderManager) {
((ProviderManager) manager)
.setAuthenticationEventPublisher(this.eventPublisher);
.setAuthenticationEventPublisher(this.eventPublisher);
}
}

View File

@@ -50,8 +50,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
@EnableConfigurationProperties
@Import({ SpringBootWebSecurityConfiguration.class,
AuthenticationManagerConfiguration.class,
BootGlobalAuthenticationConfiguration.class,
SecurityDataConfiguration.class })
BootGlobalAuthenticationConfiguration.class, SecurityDataConfiguration.class })
public class SecurityAutoConfiguration {
@Bean

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -39,4 +40,4 @@ public class SecurityDataConfiguration {
return new SecurityEvaluationContextExtension();
}
}
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security;
import javax.servlet.Filter;
@@ -44,16 +45,17 @@ import org.springframework.security.web.context.AbstractSecurityWebApplicationIn
@AutoConfigureAfter(SpringBootWebSecurityConfiguration.class)
public class SecurityFilterAutoConfiguration {
private static final String DEFAULT_FILTER_NAME = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME;
@Bean
@ConditionalOnBean(name = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
@ConditionalOnBean(name = DEFAULT_FILTER_NAME)
public FilterRegistrationBean securityFilterChainRegistration(
@Qualifier(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME) Filter securityFilter,
@Qualifier(DEFAULT_FILTER_NAME) Filter securityFilter,
SecurityProperties securityProperties) {
FilterRegistrationBean registration = new FilterRegistrationBean(securityFilter);
registration.setOrder(securityProperties.getFilterOrder());
registration
.setName(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME);
registration.setName(DEFAULT_FILTER_NAME);
return registration;
}
}
}

View File

@@ -40,8 +40,7 @@ public class SecurityProperties implements SecurityPrerequisite {
* useful place to put user-defined access rules if you want to override the default
* access rules.
*/
public static final int ACCESS_OVERRIDE_ORDER = SecurityProperties.BASIC_AUTH_ORDER
- 2;
public static final int ACCESS_OVERRIDE_ORDER = SecurityProperties.BASIC_AUTH_ORDER - 2;
/**
* Order applied to the WebSecurityConfigurerAdapter that is used to configure basic
@@ -62,8 +61,7 @@ public class SecurityProperties implements SecurityPrerequisite {
* other filters registered with the container). There is no connection between this
* and the <code>@Order</code> on a WebSecurityConfigurer.
*/
public static final int DEFAULT_FILTER_ORDER = FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER
- 100;
public static final int DEFAULT_FILTER_ORDER = FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100;
/**
* Enable secure channel for all requests.

View File

@@ -31,9 +31,10 @@ import org.springframework.context.annotation.Conditional;
* @author Stephane Nicoll
* @since 1.3.0
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Conditional(OnEnabledResourceChainCondition.class)
public @interface ConditionalOnEnabledResourceChain {
}

View File

@@ -34,14 +34,16 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
class OnEnabledResourceChainCondition extends SpringBootCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
ResourceProperties resourceProperties = new ResourceProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(resourceProperties, "spring.resources");
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConfigurableEnvironment environment = (ConfigurableEnvironment) context
.getEnvironment();
ResourceProperties properties = new ResourceProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
Boolean match = resourceProperties.getChain().getEnabled();
return new ConditionOutcome(match, "Resource chain is " + (match ? "enabled" : "disabled" + ")"));
Boolean match = properties.getChain().getEnabled();
return new ConditionOutcome(match, "Resource chain is "
+ (match ? "enabled" : "disabled" + ")"));
}
}

View File

@@ -283,7 +283,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
}
if (container instanceof TomcatEmbeddedServletContainerFactory) {
getTomcat()
.customizeTomcat((TomcatEmbeddedServletContainerFactory) container);
.customizeTomcat((TomcatEmbeddedServletContainerFactory) container);
}
if (container instanceof UndertowEmbeddedServletContainerFactory) {
getUndertow().customizeUndertow(
@@ -1015,7 +1015,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
* configuration.
*/
private static class SessionConfiguringInitializer implements
ServletContextInitializer {
ServletContextInitializer {
private final Session session;

View File

@@ -96,7 +96,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass({ Servlet.class, DispatcherServlet.class,
WebMvcConfigurerAdapter.class })
WebMvcConfigurerAdapter.class })
@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 10)
@AutoConfigureAfter(DispatcherServletAutoConfiguration.class)
@@ -313,7 +313,7 @@ public class WebMvcAutoConfiguration {
public ResourceHttpRequestHandler faviconRequestHandler() {
ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler();
requestHandler
.setLocations(this.resourceProperties.getFaviconLocations());
.setLocations(this.resourceProperties.getFaviconLocations());
return requestHandler;
}

View File

@@ -43,8 +43,8 @@ public class MessageSourceAutoConfigurationTests {
@After
public void closeContext() {
if (context != null) {
context.close();
if (this.context != null) {
this.context.close();
}
}
@@ -72,7 +72,8 @@ public class MessageSourceAutoConfigurationTests {
@Test
public void testMultipleMessageSourceCreated() throws Exception {
load("spring.messages.basename:test/messages,test/messages2");
assertEquals("bar", this.context.getMessage("foo", null, "Foo message", Locale.UK));
assertEquals("bar",
this.context.getMessage("foo", null, "Foo message", Locale.UK));
assertEquals("bar-bar",
this.context.getMessage("foo-foo", null, "Foo-Foo message", Locale.UK));
}
@@ -124,4 +125,5 @@ public class MessageSourceAutoConfigurationTests {
protected static class Config {
}
}

View File

@@ -216,17 +216,17 @@ public class BatchAutoConfigurationTests {
public void testRenamePrefix() throws Exception {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.datasource.name:batchtest",
"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
"spring.batch.tablePrefix:PREFIX_");
"spring.datasource.name:batchtest",
"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
"spring.batch.tablePrefix:PREFIX_");
this.context.register(TestConfiguration.class,
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(JobLauncher.class));
assertEquals(0, new JdbcTemplate(this.context.getBean(DataSource.class))
.queryForList("select * from PREFIX_JOB_EXECUTION").size());
.queryForList("select * from PREFIX_JOB_EXECUTION").size());
JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
assertEquals(0, jobExplorer.findRunningJobExecutions("test").size());
JobRepository jobRepository = this.context.getBean(JobRepository.class);

View File

@@ -164,7 +164,9 @@ public class JobLauncherCommandLineRunnerTests {
protected static class BatchConfiguration implements BatchConfigurer {
private ResourcelessTransactionManager transactionManager = new ResourcelessTransactionManager();
private JobRepository jobRepository;
private MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean(
this.transactionManager);
@@ -198,6 +200,7 @@ public class JobLauncherCommandLineRunnerTests {
public JobExplorer getJobExplorer() throws Exception {
return new MapJobExplorerFactoryBean(this.jobRepositoryFactory).getObject();
}
}
}

View File

@@ -26,14 +26,13 @@ import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.Random;
import java.util.logging.Logger;
import javax.sql.DataSource;
import com.zaxxer.hikari.HikariDataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.EnvironmentTestUtils;
@@ -43,6 +42,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import com.zaxxer.hikari.HikariDataSource;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -158,8 +159,8 @@ public class DataSourceAutoConfigurationTests {
public void explicitType() {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
"spring.datasource.url:jdbc:hsqldb:mem:testdb",
"spring.datasource.type:" + HikariDataSource.class.getName());
"spring.datasource.url:jdbc:hsqldb:mem:testdb", "spring.datasource.type:"
+ HikariDataSource.class.getName());
this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
@@ -271,7 +272,8 @@ public class DataSourceAutoConfigurationTests {
}
@SuppressWarnings("unused") // see testExplicitDriverClassClearsUserName
@SuppressWarnings("unused")
// see testExplicitDriverClassClearsUserName
public static class DatabaseDriver implements Driver {
@Override

View File

@@ -16,12 +16,6 @@
package org.springframework.boot.autoconfigure.security;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List;
import org.junit.After;
@@ -63,6 +57,12 @@ import org.springframework.security.web.FilterChainProxy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* Tests for {@link SecurityAutoConfiguration}.
*
@@ -105,7 +105,7 @@ public class SecurityAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertEquals(
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER-100,
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100,
this.context.getBean("securityFilterChainRegistration",
FilterRegistrationBean.class).getOrder());
}
@@ -136,7 +136,7 @@ public class SecurityAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertEquals(
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER-100,
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100,
this.context.getBean("securityFilterChainRegistration",
FilterRegistrationBean.class).getOrder());
}
@@ -355,16 +355,14 @@ public class SecurityAutoConfigurationTests {
public void testSecurityEvaluationContextExtensionSupport() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(AuthenticationManagerCustomizer.class,
SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(SecurityEvaluationContextExtension.class));
}
private static final class AuthenticationListener implements
ApplicationListener<AbstractAuthenticationEvent> {
ApplicationListener<AbstractAuthenticationEvent> {
private ApplicationEvent event;
@@ -410,7 +408,7 @@ public class SecurityAutoConfigurationTests {
@Configuration
protected static class WorkaroundSecurityCustomizer extends
WebSecurityConfigurerAdapter {
WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationManagerBuilder builder;
@@ -435,7 +433,7 @@ public class SecurityAutoConfigurationTests {
@Configuration
@Order(-1)
protected static class AuthenticationManagerCustomizer extends
GlobalAuthenticationConfigurerAdapter {
GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
@@ -446,7 +444,7 @@ public class SecurityAutoConfigurationTests {
@Configuration
protected static class UserDetailsSecurityCustomizer extends
WebSecurityConfigurerAdapter {
WebSecurityConfigurerAdapter {
private UserDetailsService userDetails;

View File

@@ -200,11 +200,13 @@ public class ThymeleafAutoConfigurationTests {
this.context.register(ThymeleafAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class).size());
assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class)
.size());
}
@Test
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() throws Exception {
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled()
throws Exception {
this.context.register(ThymeleafAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,

View File

@@ -193,11 +193,13 @@ public class VelocityAutoConfigurationTests {
@Test
public void registerResourceHandlingFilterDisabledByDefault() throws Exception {
registerAndRefreshContext();
assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class).size());
assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class)
.size());
}
@Test
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() throws Exception {
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled()
throws Exception {
registerAndRefreshContext("spring.resources.chain.enabled:true");
assertNotNull(this.context.getBean(ResourceUrlEncodingFilter.class));
}

View File

@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web;
import org.junit.After;
import org.junit.Test;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -71,7 +70,6 @@ public class ConditionalOnEnabledResourceChainTests {
assertTrue(this.context.containsBean("foo"));
}
private void load(String... environment) {
this.context.register(Config.class);
EnvironmentTestUtils.addEnvironment(this.context, environment);