pull/9055/merge
Phillip Webb 8 years ago
parent 3abd8d3adf
commit a841a6a11d

@ -51,16 +51,11 @@ public class RedisReactiveAutoConfiguration {
public ReactiveRedisTemplate<Object, Object> reactiveRedisTemplate( public ReactiveRedisTemplate<Object, Object> reactiveRedisTemplate(
ReactiveRedisConnectionFactory reactiveRedisConnectionFactory, ReactiveRedisConnectionFactory reactiveRedisConnectionFactory,
ResourceLoader resourceLoader) { ResourceLoader resourceLoader) {
JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(
JdkSerializationRedisSerializer jdkSerializer = resourceLoader.getClassLoader());
new JdkSerializationRedisSerializer(resourceLoader.getClassLoader()); RedisSerializationContext<Object, Object> serializationContext = RedisSerializationContext
.newSerializationContext().key(jdkSerializer).value(jdkSerializer)
RedisSerializationContext<Object, Object> serializationContext = .hashKey(jdkSerializer).hashValue(jdkSerializer).build();
RedisSerializationContext.newSerializationContext()
.key(jdkSerializer)
.value(jdkSerializer)
.hashKey(jdkSerializer)
.hashValue(jdkSerializer).build();
return new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory, return new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory,
serializationContext); serializationContext);
} }

@ -107,8 +107,7 @@ public class FlywayAutoConfiguration {
this.dataSource = dataSource.getIfUnique(); this.dataSource = dataSource.getIfUnique();
this.flywayDataSource = flywayDataSource.getIfAvailable(); this.flywayDataSource = flywayDataSource.getIfAvailable();
this.migrationStrategy = migrationStrategy.getIfAvailable(); this.migrationStrategy = migrationStrategy.getIfAvailable();
this.flywayCallbacks = flywayCallbacks this.flywayCallbacks = flywayCallbacks.getIfAvailable(Collections::emptyList);
.getIfAvailable(Collections::emptyList);
} }
@PostConstruct @PostConstruct

@ -56,7 +56,6 @@ public class HazelcastClientFactory {
this.clientConfig = clientConfig; this.clientConfig = clientConfig;
} }
private ClientConfig getClientConfig(Resource clientConfigLocation) private ClientConfig getClientConfig(Resource clientConfigLocation)
throws IOException { throws IOException {
URL configUrl = clientConfigLocation.getURL(); URL configUrl = clientConfigLocation.getURL();
@ -69,8 +68,8 @@ public class HazelcastClientFactory {
*/ */
public HazelcastInstance getHazelcastInstance() { public HazelcastInstance getHazelcastInstance() {
if (StringUtils.hasText(this.clientConfig.getInstanceName())) { if (StringUtils.hasText(this.clientConfig.getInstanceName())) {
return HazelcastClient.getHazelcastClientByName( return HazelcastClient
this.clientConfig.getInstanceName()); .getHazelcastClientByName(this.clientConfig.getInstanceName());
} }
return HazelcastClient.newHazelcastClient(this.clientConfig); return HazelcastClient.newHazelcastClient(this.clientConfig);
} }

@ -48,8 +48,8 @@ public abstract class HazelcastConfigResourceCondition extends ResourceCondition
protected ConditionOutcome getResourceOutcome(ConditionContext context, protected ConditionOutcome getResourceOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) { AnnotatedTypeMetadata metadata) {
if (System.getProperty(this.configSystemProperty) != null) { if (System.getProperty(this.configSystemProperty) != null) {
return ConditionOutcome.match(startConditionMessage() return ConditionOutcome.match(startConditionMessage().because(
.because("System property '" + this.configSystemProperty + "' is set.")); "System property '" + this.configSystemProperty + "' is set."));
} }
return super.getResourceOutcome(context, metadata); return super.getResourceOutcome(context, metadata);
} }

@ -137,8 +137,7 @@ public class ThymeleafAutoConfiguration {
Collection<ITemplateResolver> templateResolvers, Collection<ITemplateResolver> templateResolvers,
ObjectProvider<Collection<IDialect>> dialectsProvider) { ObjectProvider<Collection<IDialect>> dialectsProvider) {
this.templateResolvers = templateResolvers; this.templateResolvers = templateResolvers;
this.dialects = dialectsProvider this.dialects = dialectsProvider.getIfAvailable(Collections::emptyList);
.getIfAvailable(Collections::emptyList);
} }
@Bean @Bean
@ -221,8 +220,7 @@ public class ThymeleafAutoConfiguration {
ThymeleafReactiveConfiguration(Collection<ITemplateResolver> templateResolvers, ThymeleafReactiveConfiguration(Collection<ITemplateResolver> templateResolvers,
ObjectProvider<Collection<IDialect>> dialectsProvider) { ObjectProvider<Collection<IDialect>> dialectsProvider) {
this.templateResolvers = templateResolvers; this.templateResolvers = templateResolvers;
this.dialects = dialectsProvider this.dialects = dialectsProvider.getIfAvailable(Collections::emptyList);
.getIfAvailable(Collections::emptyList);
} }
@Bean @Bean

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -46,12 +46,10 @@ public class RedisReactiveAutoConfigurationTests {
@Test @Test
public void testDefaultRedisConfiguration() { public void testDefaultRedisConfiguration() {
load(); load();
Map<String, ReactiveRedisTemplate> beans = this.context.getBeansOfType( Map<String, ?> beans = this.context.getBeansOfType(ReactiveRedisTemplate.class);
ReactiveRedisTemplate.class);
assertThat(beans).containsOnlyKeys("reactiveRedisTemplate"); assertThat(beans).containsOnlyKeys("reactiveRedisTemplate");
} }
private void load(String... environment) { private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); EnvironmentTestUtils.addEnvironment(ctx, environment);

@ -78,8 +78,8 @@ public class HazelcastAutoConfigurationClientTests {
@Test @Test
public void systemProperty() throws IOException { public void systemProperty() throws IOException {
System.setProperty(HazelcastClientConfiguration.CONFIG_SYSTEM_PROPERTY, System.setProperty(HazelcastClientConfiguration.CONFIG_SYSTEM_PROPERTY,
"classpath:org/springframework/boot/autoconfigure/hazelcast/" + "classpath:org/springframework/boot/autoconfigure/hazelcast/"
"hazelcast-client-specific.xml"); + "hazelcast-client-specific.xml");
try { try {
load(); load();
HazelcastInstance hazelcastInstance = this.context HazelcastInstance hazelcastInstance = this.context
@ -120,7 +120,8 @@ public class HazelcastAutoConfigurationClientTests {
@Test @Test
public void clientConfigTakesPrecedence() { public void clientConfigTakesPrecedence() {
load(HazelcastServerAndClientConfig.class, "spring.hazelcast.config=this-is-ignored.xml"); load(HazelcastServerAndClientConfig.class,
"spring.hazelcast.config=this-is-ignored.xml");
HazelcastInstance hazelcastInstance = this.context HazelcastInstance hazelcastInstance = this.context
.getBean(HazelcastInstance.class); .getBean(HazelcastInstance.class);
assertThat(hazelcastInstance).isInstanceOf(HazelcastClientProxy.class); assertThat(hazelcastInstance).isInstanceOf(HazelcastClientProxy.class);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -19,6 +19,8 @@ package org.springframework.boot.system;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@ -59,8 +61,17 @@ public class EmbeddedServerPortFileWriterTests {
@Parameters(name = "{0}") @Parameters(name = "{0}")
public static Object[] parameters() { public static Object[] parameters() {
BiFunction<String, Integer, ? extends WebServerInitializedEvent> servletEvent = ( Map<String, BiFunction<String, Integer, WebServerInitializedEvent>> parameters = new LinkedHashMap<>();
String name, Integer port) -> { parameters.put("Servlet",
EmbeddedServerPortFileWriterTests::servletEventParameter);
parameters.put("Reactive",
EmbeddedServerPortFileWriterTests::reactiveEventParameter);
return parameters.entrySet().stream()
.map((e) -> new Object[] { e.getKey(), e.getValue() }).toArray();
}
private static WebServerInitializedEvent servletEventParameter(String name,
Integer port) {
ServletWebServerApplicationContext applicationContext = mock( ServletWebServerApplicationContext applicationContext = mock(
ServletWebServerApplicationContext.class); ServletWebServerApplicationContext.class);
given(applicationContext.getNamespace()).willReturn(name); given(applicationContext.getNamespace()).willReturn(name);
@ -69,18 +80,16 @@ public class EmbeddedServerPortFileWriterTests {
ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent( ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(
source, applicationContext); source, applicationContext);
return event; return event;
}; }
BiFunction<String, Integer, ? extends WebServerInitializedEvent> reactiveEvent = (
String name, Integer port) -> { private static WebServerInitializedEvent reactiveEventParameter(String name,
Integer port) {
ReactiveWebServerApplicationContext applicationContext = mock( ReactiveWebServerApplicationContext applicationContext = mock(
ReactiveWebServerApplicationContext.class); ReactiveWebServerApplicationContext.class);
given(applicationContext.getNamespace()).willReturn(name); given(applicationContext.getNamespace()).willReturn(name);
WebServer source = mock(WebServer.class); WebServer source = mock(WebServer.class);
given(source.getPort()).willReturn(port); given(source.getPort()).willReturn(port);
return new ReactiveWebServerInitializedEvent(source, applicationContext); return new ReactiveWebServerInitializedEvent(source, applicationContext);
};
return new Object[] { new Object[] { "Servlet", servletEvent },
new Object[] { "Reactive", reactiveEvent } };
} }
private final BiFunction<String, Integer, ? extends WebServerInitializedEvent> eventFactory; private final BiFunction<String, Integer, ? extends WebServerInitializedEvent> eventFactory;

@ -261,11 +261,11 @@ public class UndertowServletWebServerFactoryTests
} }
private ServletContainer getServletContainerFromNewFactory() { private ServletContainer getServletContainerFromNewFactory() {
UndertowServletWebServer container = (UndertowServletWebServer) UndertowServletWebServer container = (UndertowServletWebServer) getFactory()
getFactory().getWebServer(); .getWebServer();
try { try {
return ((DeploymentManager) ReflectionTestUtils.getField(container, "manager")) return ((DeploymentManager) ReflectionTestUtils.getField(container,
.getDeployment().getServletContainer(); "manager")).getDeployment().getServletContainer();
} }
finally { finally {
container.stop(); container.stop();

Loading…
Cancel
Save