This commit is contained in:
Phillip Webb
2015-06-04 00:37:15 -07:00
parent fca192fa41
commit 412b7b9e50
47 changed files with 272 additions and 242 deletions

View File

@@ -84,6 +84,7 @@ public @interface EnableAutoConfiguration {
* Exclude specific auto-configuration class names such that they will never be
* applied.
* @return the class names to exclude
* @since 1.3.0
*/
String[] excludeName() default {};

View File

@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
@@ -73,8 +74,8 @@ class EnableAutoConfigurationImportSelector implements DeferredImportSelector,
SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,
this.beanClassLoader)));
// Remove those specifically disabled
List<String> excluded = new ArrayList<String>();
// Remove those specifically excluded
Set<String> excluded = new LinkedHashSet<String>();
excluded.addAll(Arrays.asList(attributes.getStringArray("exclude")));
excluded.addAll(Arrays.asList(attributes.getStringArray("excludeName")));
factories.removeAll(excluded);

View File

@@ -57,6 +57,7 @@ public @interface SpringBootApplication {
* Exclude specific auto-configuration class names such that they will never be
* applied.
* @return the class names to exclude
* @since 1.3.0
*/
String[] excludeName() default {};

View File

@@ -106,7 +106,8 @@ public class RabbitAutoConfiguration {
protected static class RabbitConnectionFactoryCreator {
@Bean
public ConnectionFactory rabbitConnectionFactory(RabbitProperties config) throws Exception {
public ConnectionFactory rabbitConnectionFactory(RabbitProperties config)
throws Exception {
RabbitConnectionFactoryBean factory = new RabbitConnectionFactoryBean();
if (config.getHost() != null) {
factory.setHost(config.getHost());
@@ -131,12 +132,13 @@ public class RabbitAutoConfiguration {
Properties properties = ssl.createSslProperties();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
properties.store(outputStream, "SSL config");
factory.setSslPropertiesLocation(
new ByteArrayResource(outputStream.toByteArray()));
factory.setSslPropertiesLocation(new ByteArrayResource(outputStream
.toByteArray()));
}
}
factory.afterPropertiesSet();
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(factory.getObject());
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
factory.getObject());
connectionFactory.setAddresses(config.getAddresses());
return connectionFactory;
}

View File

@@ -73,7 +73,6 @@ public class RabbitProperties {
*/
private Integer requestedHeartbeat;
public String getHost() {
if (this.addresses == null) {
return this.host;
@@ -161,7 +160,7 @@ public class RabbitProperties {
}
public Ssl getSsl() {
return ssl;
return this.ssl;
}
public String getVirtualHost() {
@@ -173,7 +172,7 @@ public class RabbitProperties {
}
public Integer getRequestedHeartbeat() {
return requestedHeartbeat;
return this.requestedHeartbeat;
}
public void setRequestedHeartbeat(Integer requestedHeartbeat) {
@@ -208,7 +207,7 @@ public class RabbitProperties {
private String trustStorePassword;
public boolean isEnabled() {
return enabled;
return this.enabled;
}
public void setEnabled(boolean enabled) {
@@ -216,7 +215,7 @@ public class RabbitProperties {
}
public String getKeyStore() {
return keyStore;
return this.keyStore;
}
public void setKeyStore(String keyStore) {
@@ -224,7 +223,7 @@ public class RabbitProperties {
}
public String getKeyStorePassword() {
return keyStorePassword;
return this.keyStorePassword;
}
public void setKeyStorePassword(String keyStorePassword) {
@@ -232,7 +231,7 @@ public class RabbitProperties {
}
public String getTrustStore() {
return trustStore;
return this.trustStore;
}
public void setTrustStore(String trustStore) {
@@ -240,7 +239,7 @@ public class RabbitProperties {
}
public String getTrustStorePassword() {
return trustStorePassword;
return this.trustStorePassword;
}
public void setTrustStorePassword(String trustStorePassword) {
@@ -249,7 +248,8 @@ public class RabbitProperties {
/**
* Create the ssl configuration as expected by the
* {@link org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean RabbitConnectionFactoryBean}.
* {@link org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean
* RabbitConnectionFactoryBean}.
* @return the ssl configuration
*/
public Properties createSslProperties() {

View File

@@ -62,6 +62,7 @@ class BasicBatchConfigurer implements BatchConfigurer {
/**
* Create a new {@link BasicBatchConfigurer} instance.
* @param properties the batch properties
* @param dataSource the underlying data source
*/
public BasicBatchConfigurer(BatchProperties properties, DataSource dataSource) {
@@ -70,6 +71,7 @@ class BasicBatchConfigurer implements BatchConfigurer {
/**
* Create a new {@link BasicBatchConfigurer} instance.
* @param properties the batch properties
* @param dataSource the underlying data source
* @param entityManagerFactory the entity manager factory (or {@code null})
*/

View File

@@ -141,7 +141,8 @@ public class BatchAutoConfiguration {
@ConditionalOnBean(name = "entityManagerFactory")
public BatchConfigurer jpaBatchConfigurer(DataSource dataSource,
EntityManagerFactory entityManagerFactory) {
return new BasicBatchConfigurer(this.properties, dataSource, entityManagerFactory);
return new BasicBatchConfigurer(this.properties, dataSource,
entityManagerFactory);
}
@Bean

View File

@@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.condition;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -86,7 +87,7 @@ public class ConditionEvaluationReport {
* Records the name of the classes that have been excluded from condition evaluation
* @param exclusions the names of the excluded classes
*/
public void recordExclusions(List<String> exclusions) {
public void recordExclusions(Collection<String> exclusions) {
Assert.notNull(exclusions, "exclusions must not be null");
this.exclusions = new ArrayList<String>(exclusions);
}

View File

@@ -47,13 +47,13 @@ class JndiSessionConfiguration {
@Bean
@ConditionalOnMissingBean
public Session session() {
String jndiName = this.properties.getJndiName();
try {
return new JndiLocatorDelegate()
.lookup(this.properties.getJndiName(), Session.class);
return new JndiLocatorDelegate().lookup(jndiName, Session.class);
}
catch (NamingException e) {
catch (NamingException ex) {
throw new IllegalStateException(String.format(
"Unable to find Session in JNDI location %s", this.properties.getJndiName()));
"Unable to find Session in JNDI location %s", jndiName), ex);
}
}

View File

@@ -118,4 +118,5 @@ public class MailProperties {
public String getJndiName() {
return this.jndiName;
}
}

View File

@@ -16,7 +16,9 @@
package org.springframework.boot.autoconfigure.mail;
import java.util.Map;
import java.util.Properties;
import javax.activation.MimeType;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
@@ -65,25 +67,33 @@ public class MailSenderAutoConfiguration {
sender.setSession(this.session);
}
else {
sender.setHost(this.properties.getHost());
if (this.properties.getPort() != null) {
sender.setPort(this.properties.getPort());
}
sender.setUsername(this.properties.getUsername());
sender.setPassword(this.properties.getPassword());
sender.setDefaultEncoding(this.properties.getDefaultEncoding());
if (!this.properties.getProperties().isEmpty()) {
Properties properties = new Properties();
properties.putAll(this.properties.getProperties());
sender.setJavaMailProperties(properties);
}
applyProperties(sender);
}
return sender;
}
private void applyProperties(JavaMailSenderImpl sender) {
sender.setHost(this.properties.getHost());
if (this.properties.getPort() != null) {
sender.setPort(this.properties.getPort());
}
sender.setUsername(this.properties.getUsername());
sender.setPassword(this.properties.getPassword());
sender.setDefaultEncoding(this.properties.getDefaultEncoding());
if (!this.properties.getProperties().isEmpty()) {
sender.setJavaMailProperties(asProperties(this.properties.getProperties()));
}
}
private Properties asProperties(Map<String, String> source) {
Properties properties = new Properties();
properties.putAll(source);
return properties;
}
/**
* Condition to trigger the creation of a {@link JavaMailSenderImpl}. This kicks in
* if either the host or jndi name property is set.
* Condition to trigger the creation of a {@link JavaMailSenderImpl}. This kicks in if
* either the host or jndi name property is set.
*/
static class MailSenderCondition extends AnyNestedCondition {

View File

@@ -37,7 +37,6 @@ import org.springframework.social.connect.ConnectionFactory;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.web.GenericConnectionStatusView;
import org.springframework.social.facebook.api.Facebook;
import org.springframework.social.facebook.api.impl.FacebookTemplate;
import org.springframework.social.facebook.connect.FacebookConnectionFactory;
import org.springframework.web.servlet.View;

View File

@@ -463,14 +463,36 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
if (getBasedir() != null) {
factory.setBaseDirectory(getBasedir());
}
customizeBackgroundProcessorDelay(factory);
customizeHeaders(factory);
if (this.maxThreads > 0) {
customizeMaxThreads(factory);
}
if (this.maxHttpHeaderSize > 0) {
customizeMaxHttpHeaderSize(factory);
}
customizeCompression(factory);
if (this.accessLogEnabled) {
customizeAccessLog(factory);
}
if (getUriEncoding() != null) {
factory.setUriEncoding(getUriEncoding());
}
}
private void customizeBackgroundProcessorDelay(
TomcatEmbeddedServletContainerFactory factory) {
factory.addContextCustomizers(new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
context.setBackgroundProcessorDelay(Tomcat.this.backgroundProcessorDelay);
}
});
});
}
private void customizeHeaders(TomcatEmbeddedServletContainerFactory factory) {
String remoteIpHeader = getRemoteIpHeader();
String protocolHeader = getProtocolHeader();
if (StringUtils.hasText(remoteIpHeader)
@@ -482,35 +504,42 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
valve.setPortHeader(getPortHeader());
factory.addContextValves(valve);
}
}
if (this.maxThreads > 0) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
@SuppressWarnings("rawtypes")
AbstractProtocol protocol = (AbstractProtocol) handler;
protocol.setMaxThreads(Tomcat.this.maxThreads);
}
@SuppressWarnings("rawtypes")
private void customizeMaxThreads(TomcatEmbeddedServletContainerFactory factory) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol protocol = (AbstractProtocol) handler;
protocol.setMaxThreads(Tomcat.this.maxThreads);
}
});
}
if (this.maxHttpHeaderSize > 0) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractHttp11Protocol) {
@SuppressWarnings("rawtypes")
AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler;
protocol.setMaxHttpHeaderSize(Tomcat.this.maxHttpHeaderSize);
}
}
});
}
@SuppressWarnings("rawtypes")
private void customizeMaxHttpHeaderSize(
TomcatEmbeddedServletContainerFactory factory) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractHttp11Protocol) {
AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler;
protocol.setMaxHttpHeaderSize(Tomcat.this.maxHttpHeaderSize);
}
});
}
}
});
}
private void customizeCompression(TomcatEmbeddedServletContainerFactory factory) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
@@ -535,22 +564,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
}
});
}
if (this.accessLogEnabled) {
AccessLogValve valve = new AccessLogValve();
String accessLogPattern = getAccessLogPattern();
if (accessLogPattern != null) {
valve.setPattern(accessLogPattern);
}
else {
valve.setPattern("common");
}
valve.setSuffix(".log");
factory.addContextValves(valve);
}
if (getUriEncoding() != null) {
factory.setUriEncoding(getUriEncoding());
}
private void customizeAccessLog(TomcatEmbeddedServletContainerFactory factory) {
AccessLogValve valve = new AccessLogValve();
String accessLogPattern = getAccessLogPattern();
valve.setPattern(accessLogPattern == null ? "common" : accessLogPattern);
valve.setSuffix(".log");
factory.addContextValves(valve);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 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.
@@ -19,7 +19,8 @@ package org.springframework.boot.autoconfigure;
import org.springframework.boot.test.AbstractConfigurationClassTests;
/**
* Tests for the autoconfigure module's <code>@Configuration</code> classes
* Tests for the auto-configure module's {@code @Configuration} classes.
*
* @author Andy Wilkinson
*/
public class AutoConfigureConfigurationClassTests extends AbstractConfigurationClassTests {

View File

@@ -81,7 +81,8 @@ public class EnableAutoConfigurationImportSelectorTests {
@Test
public void classExclusionsAreApplied() {
configureExclusions(new String[]{FreeMarkerAutoConfiguration.class.getName()}, new String[0]);
configureExclusions(new String[] { FreeMarkerAutoConfiguration.class.getName() },
new String[0]);
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
assertThat(imports.length,
is(equalTo(getAutoConfigurationClassNames().size() - 1)));
@@ -91,7 +92,8 @@ public class EnableAutoConfigurationImportSelectorTests {
@Test
public void classNamesExclusionsAreApplied() {
configureExclusions(new String[0], new String[]{VelocityAutoConfiguration.class.getName()});
configureExclusions(new String[0],
new String[] { VelocityAutoConfiguration.class.getName() });
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
assertThat(imports.length,
is(equalTo(getAutoConfigurationClassNames().size() - 1)));
@@ -101,12 +103,13 @@ public class EnableAutoConfigurationImportSelectorTests {
@Test
public void bothExclusionsAreApplied() {
configureExclusions(new String[]{VelocityAutoConfiguration.class.getName()},
new String[]{FreeMarkerAutoConfiguration.class.getName()});
configureExclusions(new String[] { VelocityAutoConfiguration.class.getName() },
new String[] { FreeMarkerAutoConfiguration.class.getName() });
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
assertThat(imports.length,
is(equalTo(getAutoConfigurationClassNames().size() - 2)));
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(),
assertThat(
ConditionEvaluationReport.get(this.beanFactory).getExclusions(),
containsInAnyOrder(FreeMarkerAutoConfiguration.class.getName(),
VelocityAutoConfiguration.class.getName()));
}
@@ -116,8 +119,10 @@ public class EnableAutoConfigurationImportSelectorTests {
this.annotationMetadata.getAnnotationAttributes(
EnableAutoConfiguration.class.getName(), true)).willReturn(
this.annotationAttributes);
given(this.annotationAttributes.getStringArray("exclude")).willReturn(classExclusion);
given(this.annotationAttributes.getStringArray("excludeName")).willReturn(nameExclusion);
given(this.annotationAttributes.getStringArray("exclude")).willReturn(
classExclusion);
given(this.annotationAttributes.getStringArray("excludeName")).willReturn(
nameExclusion);
}
private List<String> getAutoConfigurationClassNames() {

View File

@@ -212,13 +212,15 @@ public class RabbitAutoConfigurationTests {
public void enableSsl() {
load(TestConfiguration.class, "spring.rabbitmq.ssl.enabled:true");
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = getTargetConnectionFactory();
assertTrue("SocketFactory must use SSL", rabbitConnectionFactory.getSocketFactory() instanceof SSLSocketFactory);
assertTrue("SocketFactory must use SSL",
rabbitConnectionFactory.getSocketFactory() instanceof SSLSocketFactory);
}
@Test // Make sure that we at least attempt to load the store
@Test
// Make sure that we at least attempt to load the store
public void enableSslWithExtraConfig() {
thrown.expectMessage("foo");
thrown.expectMessage("does not exist");
this.thrown.expectMessage("foo");
this.thrown.expectMessage("does not exist");
load(TestConfiguration.class, "spring.rabbitmq.ssl.enabled:true",
"spring.rabbitmq.ssl.keyStore=foo",
"spring.rabbitmq.ssl.keyStorePassword=secret",
@@ -229,8 +231,8 @@ public class RabbitAutoConfigurationTests {
private com.rabbitmq.client.ConnectionFactory getTargetConnectionFactory() {
CachingConnectionFactory connectionFactory = this.context
.getBean(CachingConnectionFactory.class);
return (com.rabbitmq.client.ConnectionFactory)
new DirectFieldAccessor(connectionFactory).getPropertyValue("rabbitConnectionFactory");
return (com.rabbitmq.client.ConnectionFactory) new DirectFieldAccessor(
connectionFactory).getPropertyValue("rabbitConnectionFactory");
}
private void load(Class<?> config, String... environment) {

View File

@@ -69,7 +69,7 @@ public class DataSourceJsonSerializationTests {
public void serializerWithMixin() throws Exception {
DataSource dataSource = new DataSource();
ObjectMapper mapper = new ObjectMapper();
mapper.addMixInAnnotations(DataSource.class, DataSourceJson.class);
mapper.addMixIn(DataSource.class, DataSourceJson.class);
String value = mapper.writeValueAsString(dataSource);
assertTrue(value.contains("\"url\":"));
assertEquals(1, StringUtils.countOccurrencesOf(value, "\"url\""));

View File

@@ -79,9 +79,10 @@ public class DataSourceTransactionManagerAutoConfigurationTests {
EmbeddedDataSourceConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class);
this.context.refresh();
assertEquals("No transaction manager should be been created", 1,
this.context.getBeansOfType(PlatformTransactionManager.class).size());
assertEquals("Wrong transaction manager", this.context.getBean("myTransactionManager"),
assertEquals("No transaction manager should be been created", 1, this.context
.getBeansOfType(PlatformTransactionManager.class).size());
assertEquals("Wrong transaction manager",
this.context.getBean("myTransactionManager"),
this.context.getBean(PlatformTransactionManager.class));
}

View File

@@ -16,6 +16,12 @@
package org.springframework.boot.autoconfigure.mail;
import java.util.Properties;
import javax.mail.Session;
import javax.naming.Context;
import javax.naming.NamingException;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -31,12 +37,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import javax.mail.Session;
import javax.naming.Context;
import javax.naming.NamingException;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -78,7 +78,8 @@ public class MailSenderAutoConfigurationTests {
if (this.initialContextFactory != null) {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
this.initialContextFactory);
} else {
}
else {
System.clearProperty(Context.INITIAL_CONTEXT_FACTORY);
}
if (this.context != null) {
@@ -138,20 +139,18 @@ public class MailSenderAutoConfigurationTests {
@Test
public void jndiSessionAvailable() throws NamingException {
Session session = configureJndiSession("foo");
Session session = configureJndiSession("foo");
load(EmptyConfig.class, "spring.mail.jndi-name:foo");
Session sessionBean = this.context.getBean(Session.class);
assertEquals(session, sessionBean);
assertEquals(sessionBean, this.context.getBean(JavaMailSenderImpl.class).getSession());
assertEquals(sessionBean, this.context.getBean(JavaMailSenderImpl.class)
.getSession());
}
@Test
public void jndiSessionIgnoredIfJndiNameNotSet() throws NamingException {
configureJndiSession("foo");
load(EmptyConfig.class, "spring.mail.host:smtp.acme.org");
assertEquals(0, this.context.getBeanNamesForType(Session.class).length);
assertNotNull(this.context.getBean(JavaMailSender.class));
}
@@ -159,23 +158,20 @@ public class MailSenderAutoConfigurationTests {
@Test
public void jndiSessionNotUsedIfJndiNameNotSet() throws NamingException {
configureJndiSession("foo");
load(EmptyConfig.class);
assertEquals(0, this.context.getBeanNamesForType(Session.class).length);
assertEquals(0, this.context.getBeanNamesForType(JavaMailSender.class).length);
assertEquals(0, this.context.getBeanNamesForType(JavaMailSender.class).length);
}
@Test
public void jndiSessionNotAvailableWithJndiName() throws NamingException {
thrown.expect(BeanCreationException.class);
thrown.expectMessage("Unable to find Session in JNDI location foo");
this.thrown.expect(BeanCreationException.class);
this.thrown.expectMessage("Unable to find Session in JNDI location foo");
load(EmptyConfig.class, "spring.mail.jndi-name:foo");
}
private Session configureJndiSession(String name)
throws IllegalStateException, NamingException {
private Session configureJndiSession(String name) throws IllegalStateException,
NamingException {
Properties properties = new Properties();
Session session = Session.getDefaultInstance(properties);
TestableInitialContextFactory.bind(name, session);

View File

@@ -18,8 +18,6 @@ package org.springframework.boot.autoconfigure.mobile;
import org.junit.After;
import org.junit.Test;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.PropertyAccessor;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -38,6 +36,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.mobile.device.view.AbstractDeviceDelegatingViewResolver;
import org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -93,7 +92,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
try {
this.context.getBean(ThymeleafViewResolver.class);
}
catch (NoSuchBeanDefinitionException e) {
catch (NoSuchBeanDefinitionException ex) {
// expected. ThymeleafViewResolver shouldn't be defined.
}
assertTrue(deviceDelegatingViewResolver.getOrder() == internalResourceViewResolver
@@ -114,7 +113,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
try {
this.context.getBean(ThymeleafViewResolver.class);
}
catch (NoSuchBeanDefinitionException e) {
catch (NoSuchBeanDefinitionException ex) {
// expected. ThymeleafViewResolver shouldn't be defined.
}
this.context.getBean("deviceDelegatingViewResolver",
@@ -177,7 +176,8 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
.getBean("deviceDelegatingViewResolver",
LiteDeviceDelegatingViewResolver.class);
DirectFieldAccessor accessor = new DirectFieldAccessor(liteDeviceDelegatingViewResolver);
DirectFieldAccessor accessor = new DirectFieldAccessor(
liteDeviceDelegatingViewResolver);
assertEquals(false, accessor.getPropertyValue("enableFallback"));
assertEquals("", accessor.getPropertyValue("normalPrefix"));
assertEquals("mobile/", accessor.getPropertyValue("mobilePrefix"));
@@ -224,7 +224,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
"spring.mobile.devicedelegatingviewresolver.enabled:true",
"spring.mobile.devicedelegatingviewresolver.normalSuffix:.nor");
assertEquals(".nor", accessor.getPropertyValue("normalSuffix"));
assertEquals(".nor", accessor.getPropertyValue("normalSuffix"));
}
@Test
@@ -232,7 +232,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
"spring.mobile.devicedelegatingviewresolver.enabled:true",
"spring.mobile.devicedelegatingviewresolver.mobileSuffix:.mob");
assertEquals(".mob", accessor.getPropertyValue("mobileSuffix"));
assertEquals(".mob", accessor.getPropertyValue("mobileSuffix"));
}
@Test
@@ -243,7 +243,8 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
assertEquals(".tab", accessor.getPropertyValue("tabletSuffix"));
}
private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor(String... configuration) {
private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor(
String... configuration) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, configuration);
this.context.register(Config.class, WebMvcAutoConfiguration.class,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 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-2014 the original author or authors.
* Copyright 2012-2015 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.