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

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

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

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

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

@ -137,8 +137,7 @@ public class ThymeleafAutoConfiguration {
Collection<ITemplateResolver> templateResolvers,
ObjectProvider<Collection<IDialect>> dialectsProvider) {
this.templateResolvers = templateResolvers;
this.dialects = dialectsProvider
.getIfAvailable(Collections::emptyList);
this.dialects = dialectsProvider.getIfAvailable(Collections::emptyList);
}
@Bean
@ -221,8 +220,7 @@ public class ThymeleafAutoConfiguration {
ThymeleafReactiveConfiguration(Collection<ITemplateResolver> templateResolvers,
ObjectProvider<Collection<IDialect>> dialectsProvider) {
this.templateResolvers = templateResolvers;
this.dialects = dialectsProvider
.getIfAvailable(Collections::emptyList);
this.dialects = dialectsProvider.getIfAvailable(Collections::emptyList);
}
@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");
* you may not use this file except in compliance with the License.

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

@ -78,8 +78,8 @@ public class HazelcastAutoConfigurationClientTests {
@Test
public void systemProperty() throws IOException {
System.setProperty(HazelcastClientConfiguration.CONFIG_SYSTEM_PROPERTY,
"classpath:org/springframework/boot/autoconfigure/hazelcast/" +
"hazelcast-client-specific.xml");
"classpath:org/springframework/boot/autoconfigure/hazelcast/"
+ "hazelcast-client-specific.xml");
try {
load();
HazelcastInstance hazelcastInstance = this.context
@ -120,7 +120,8 @@ public class HazelcastAutoConfigurationClientTests {
@Test
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
.getBean(HazelcastInstance.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");
* 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.FileReader;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
@ -59,28 +61,35 @@ public class EmbeddedServerPortFileWriterTests {
@Parameters(name = "{0}")
public static Object[] parameters() {
BiFunction<String, Integer, ? extends WebServerInitializedEvent> servletEvent = (
String name, Integer port) -> {
ServletWebServerApplicationContext applicationContext = mock(
ServletWebServerApplicationContext.class);
given(applicationContext.getNamespace()).willReturn(name);
WebServer source = mock(WebServer.class);
given(source.getPort()).willReturn(port);
ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(
source, applicationContext);
return event;
};
BiFunction<String, Integer, ? extends WebServerInitializedEvent> reactiveEvent = (
String name, Integer port) -> {
ReactiveWebServerApplicationContext applicationContext = mock(
ReactiveWebServerApplicationContext.class);
given(applicationContext.getNamespace()).willReturn(name);
WebServer source = mock(WebServer.class);
given(source.getPort()).willReturn(port);
return new ReactiveWebServerInitializedEvent(source, applicationContext);
};
return new Object[] { new Object[] { "Servlet", servletEvent },
new Object[] { "Reactive", reactiveEvent } };
Map<String, BiFunction<String, Integer, WebServerInitializedEvent>> parameters = new LinkedHashMap<>();
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.class);
given(applicationContext.getNamespace()).willReturn(name);
WebServer source = mock(WebServer.class);
given(source.getPort()).willReturn(port);
ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(
source, applicationContext);
return event;
}
private static WebServerInitializedEvent reactiveEventParameter(String name,
Integer port) {
ReactiveWebServerApplicationContext applicationContext = mock(
ReactiveWebServerApplicationContext.class);
given(applicationContext.getNamespace()).willReturn(name);
WebServer source = mock(WebServer.class);
given(source.getPort()).willReturn(port);
return new ReactiveWebServerInitializedEvent(source, applicationContext);
}
private final BiFunction<String, Integer, ? extends WebServerInitializedEvent> eventFactory;

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

Loading…
Cancel
Save