pull/7512/head
Phillip Webb 8 years ago
parent 2be554456e
commit 9fdb563d5a

@ -58,8 +58,8 @@ public class ValidationAutoConfiguration {
@Override @Override
public ConditionOutcome getMatchOutcome(ConditionContext context, public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) { AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage.forCondition( ConditionMessage.Builder message = ConditionMessage
getClass().getName()); .forCondition(getClass().getName());
try { try {
Validation.buildDefaultValidatorFactory().getValidator(); Validation.buildDefaultValidatorFactory().getValidator();
return ConditionOutcome.match(message.available("JSR-303 provider")); return ConditionOutcome.match(message.available("JSR-303 provider"));

@ -66,7 +66,8 @@ public class CassandraAutoConfigurationTests {
public void createCustomizeCluster() { public void createCustomizeCluster() {
load(ClusterConfig.class); load(ClusterConfig.class);
assertThat(this.context.getBeanNamesForType(Cluster.class).length).isEqualTo(1); assertThat(this.context.getBeanNamesForType(Cluster.class).length).isEqualTo(1);
assertThat(this.context.getBeanNamesForType(ClusterCustomizer.class).length).isEqualTo(1); assertThat(this.context.getBeanNamesForType(ClusterCustomizer.class).length)
.isEqualTo(1);
} }
private void load(String... environment) { private void load(String... environment) {
@ -85,7 +86,6 @@ public class CassandraAutoConfigurationTests {
this.context = ctx; this.context = ctx;
} }
@Configuration @Configuration
static class ClusterConfig { static class ClusterConfig {

@ -70,8 +70,9 @@ public class SessionAutoConfigurationHazelcastTests
"spring.session.hazelcast.flush-mode=immediate"); "spring.session.hazelcast.flush-mode=immediate");
HazelcastSessionRepository repository = validateSessionRepository( HazelcastSessionRepository repository = validateSessionRepository(
HazelcastSessionRepository.class); HazelcastSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue( assertThat(new DirectFieldAccessor(repository)
"hazelcastFlushMode")).isEqualTo(HazelcastFlushMode.IMMEDIATE); .getPropertyValue("hazelcastFlushMode"))
.isEqualTo(HazelcastFlushMode.IMMEDIATE);
} }
@Configuration @Configuration

@ -97,7 +97,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
} }
@Test @Test
@SuppressWarnings("unchecked")
public void mongoSessionStore() { public void mongoSessionStore() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class, load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class), MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
@ -106,7 +105,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
} }
@Test @Test
@SuppressWarnings("unchecked")
public void mongoSessionStoreWithCustomizations() { public void mongoSessionStoreWithCustomizations() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class, load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class), MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),

@ -65,7 +65,8 @@ public class ValidationAutoConfigurationTests {
load(SampleConfiguration.class); load(SampleConfiguration.class);
assertThat(this.context.getBean(MethodValidationPostProcessor.class)) assertThat(this.context.getBean(MethodValidationPostProcessor.class))
.isSameAs(this.context.getBean("testMethodValidationPostProcessor")); .isSameAs(this.context.getBean("testMethodValidationPostProcessor"));
assertThat(this.context.getBeansOfType(MethodValidationPostProcessor.class)).hasSize(1); assertThat(this.context.getBeansOfType(MethodValidationPostProcessor.class))
.hasSize(1);
} }
public void load(Class<?> config) { public void load(Class<?> config) {
@ -84,6 +85,7 @@ public class ValidationAutoConfigurationTests {
public void doSomething(@Size(min = 3, max = 10) String name) { public void doSomething(@Size(min = 3, max = 10) String name) {
} }
} }
@Configuration @Configuration

@ -28,8 +28,8 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Test for {{@link ValidationAutoConfiguration} when Hibernate validator is present * Test for {@link ValidationAutoConfiguration} when Hibernate validator is present but no
* but no EL implementation is available. * EL implementation is available.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */

@ -435,10 +435,8 @@ public class ServerPropertiesTests {
map.put("server.tomcat.port-header", "x-my-forward-port"); map.put("server.tomcat.port-header", "x-my-forward-port");
map.put("server.tomcat.protocol-header-https-value", "On"); map.put("server.tomcat.protocol-header-https-value", "On");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
assertThat(container.getEngineValves()).hasSize(1); assertThat(container.getEngineValves()).hasSize(1);
Valve valve = container.getEngineValves().iterator().next(); Valve valve = container.getEngineValves().iterator().next();
assertThat(valve).isInstanceOf(RemoteIpValve.class); assertThat(valve).isInstanceOf(RemoteIpValve.class);
@ -455,7 +453,6 @@ public class ServerPropertiesTests {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.accept-count", "10"); map.put("server.tomcat.accept-count", "10");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
@ -469,7 +466,6 @@ public class ServerPropertiesTests {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.max-connections", "5"); map.put("server.tomcat.max-connections", "5");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
@ -483,7 +479,6 @@ public class ServerPropertiesTests {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.max-http-post-size", "10000"); map.put("server.tomcat.max-http-post-size", "10000");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
@ -498,7 +493,6 @@ public class ServerPropertiesTests {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("server.max-http-post-size", "2000"); map.put("server.max-http-post-size", "2000");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container

Loading…
Cancel
Save