This commit is contained in:
Andy Wilkinson 2018-02-08 11:15:36 +00:00
parent 70c613819d
commit a09c64e18c
12 changed files with 31 additions and 24 deletions

View File

@ -117,7 +117,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void propertyBasedMeterFilter() {
this.contextRunner.withPropertyValues("management.metrics.enable.my.org=false")
.run(context -> {
.run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
registry.timer("my.org.timer");
assertThat(registry.find("my.org.timer").timer()).isNull();

View File

@ -50,8 +50,10 @@ public class EmbeddedLdapAutoConfigurationTests {
@Test
public void testSetDefaultPort() {
this.contextRunner.withPropertyValues("spring.ldap.embedded.port:1234",
"spring.ldap.embedded.base-dn:dc=spring,dc=org").run(context -> {
this.contextRunner
.withPropertyValues("spring.ldap.embedded.port:1234",
"spring.ldap.embedded.base-dn:dc=spring,dc=org")
.run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
assertThat(server.getListenPort()).isEqualTo(1234);
@ -62,7 +64,7 @@ public class EmbeddedLdapAutoConfigurationTests {
public void testRandomPortWithEnvironment() {
this.contextRunner
.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org")
.run(context -> {
.run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
assertThat(server.getListenPort()).isEqualTo(context.getEnvironment()
@ -90,7 +92,7 @@ public class EmbeddedLdapAutoConfigurationTests {
.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org",
"spring.ldap.embedded.credential.username:uid=root",
"spring.ldap.embedded.credential.password:boot")
.run(context -> {
.run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
BindResult result = server.bind("uid=root", "boot");
@ -102,7 +104,7 @@ public class EmbeddedLdapAutoConfigurationTests {
public void testSetPartitionSuffix() {
this.contextRunner
.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org")
.run(context -> {
.run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
assertThat(server.getBaseDNs())
@ -114,7 +116,7 @@ public class EmbeddedLdapAutoConfigurationTests {
public void testSetLdifFile() {
this.contextRunner
.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org")
.run(context -> {
.run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
assertThat(server
@ -129,7 +131,7 @@ public class EmbeddedLdapAutoConfigurationTests {
.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org")
.withConfiguration(AutoConfigurations.of(LdapAutoConfiguration.class,
LdapDataAutoConfiguration.class))
.run(context -> {
.run((context) -> {
assertThat(context.getBeanNamesForType(LdapTemplate.class).length)
.isEqualTo(1);
LdapTemplate ldapTemplate = context.getBean(LdapTemplate.class);
@ -143,7 +145,7 @@ public class EmbeddedLdapAutoConfigurationTests {
this.contextRunner
.withPropertyValues("spring.ldap.embedded.validation.enabled:false",
"spring.ldap.embedded.base-dn:dc=spring,dc=org")
.run(context -> {
.run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
assertThat(server.getSchema()).isNull();
@ -155,7 +157,7 @@ public class EmbeddedLdapAutoConfigurationTests {
this.contextRunner.withPropertyValues(
"spring.ldap.embedded.validation.schema:classpath:custom-schema.ldif",
"spring.ldap.embedded.ldif:classpath:custom-schema-sample.ldif",
"spring.ldap.embedded.base-dn:dc=spring,dc=org").run(context -> {
"spring.ldap.embedded.base-dn:dc=spring,dc=org").run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
@ -174,7 +176,7 @@ public class EmbeddedLdapAutoConfigurationTests {
"spring.ldap.embedded.ldif:classpath:schema-multi-basedn.ldif",
"spring.ldap.embedded.base-dn[0]:dc=spring,dc=org",
"spring.ldap.embedded.base-dn[1]:dc=pivotal,dc=io")
.run(context -> {
.run((context) -> {
InMemoryDirectoryServer server = context
.getBean(InMemoryDirectoryServer.class);
assertThat(server

View File

@ -41,7 +41,7 @@ public class WebFluxSecurityConfigurationTests {
this.contextRunner
.withUserConfiguration(WebFilterChainProxyConfiguration.class,
WebFluxSecurityConfiguration.class)
.run(context -> assertThat(context)
.run((context) -> assertThat(context)
.doesNotHaveBean(WebFluxSecurityConfiguration.class));
}

View File

@ -64,7 +64,7 @@ final class JavaPluginAction implements PluginApplicationAction {
disableJarTask(project);
configureBuildTask(project);
BootJar bootJar = configureBootJarTask(project);
configureArtifactPublication(project, bootJar);
configureArtifactPublication(bootJar);
configureBootRunTask(project);
configureUtf8Encoding(project);
configureParametersCompilerArg(project);
@ -98,7 +98,7 @@ final class JavaPluginAction implements PluginApplicationAction {
return bootJar;
}
private void configureArtifactPublication(Project project, BootJar bootJar) {
private void configureArtifactPublication(BootJar bootJar) {
ArchivePublishArtifact artifact = new ArchivePublishArtifact(bootJar);
this.singlePublishedArtifact.addCandidate(artifact);
}
@ -140,14 +140,12 @@ final class JavaPluginAction implements PluginApplicationAction {
}
private void configureAdditionalMetadataLocations(Project project) {
project.afterEvaluate((evaluated) -> {
project.afterEvaluate((evaluated) ->
evaluated.getTasks().withType(JavaCompile.class,
(compile) -> configureAdditionalMetadataLocations(project, compile));
});
this::configureAdditionalMetadataLocations));
}
private void configureAdditionalMetadataLocations(Project project,
JavaCompile compile) {
private void configureAdditionalMetadataLocations(JavaCompile compile) {
compile.doFirst((task) -> {
if (hasConfigurationProcessorOnClasspath(compile)) {
findMatchingSourceSet(compile).ifPresent((sourceSet) -> {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@ -27,6 +27,7 @@ import org.gradle.api.Project;
*
* @author Andy Wilkinson
*/
@SuppressWarnings("serial")
public class BuildInfoProperties implements Serializable {
private final transient Project project;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@ -30,6 +30,7 @@ import org.springframework.boot.loader.tools.FileUtils;
* @author Andy Wilkinson
* @since 2.0.0
*/
@SuppressWarnings("serial")
public class LaunchScriptConfiguration implements Serializable {
private final Map<String, String> properties = new HashMap<>();

View File

@ -129,21 +129,21 @@ class JavaBeanBinder implements BeanBinder {
name = Introspector.decapitalize(name.substring(3));
this.properties
.computeIfAbsent(name,
n -> new BeanProperty(n, this.resolvableType))
(n) -> new BeanProperty(n, this.resolvableType))
.addGetter(method);
}
else if (name.startsWith("is") && parameterCount == 0) {
name = Introspector.decapitalize(name.substring(2));
this.properties
.computeIfAbsent(name,
n -> new BeanProperty(n, this.resolvableType))
(n) -> new BeanProperty(n, this.resolvableType))
.addGetter(method);
}
else if (name.startsWith("set") && parameterCount == 1) {
name = Introspector.decapitalize(name.substring(3));
this.properties
.computeIfAbsent(name,
n -> new BeanProperty(n, this.resolvableType))
(n) -> new BeanProperty(n, this.resolvableType))
.addSetter(method);
}
}

View File

@ -287,6 +287,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
assertThat(foo.getFoos().get("1")).isNotNull();
}
@SuppressWarnings("rawtypes")
@Test
public void bindToBeanWithGenerics() {
this.context = new AnnotationConfigApplicationContext();

View File

@ -280,6 +280,7 @@ public class BinderTests {
this.binder.bind("foo", target);
}
@SuppressWarnings("rawtypes")
@Test
public void bindToBeanWithUnresolvableGenerics() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();

View File

@ -28,6 +28,7 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@SuppressWarnings("deprecation")
@Bean
public InMemoryUserDetailsManager inMemoryUserDetailsManager() {
return new InMemoryUserDetailsManager(

View File

@ -87,6 +87,7 @@ public class SampleSecureWebFluxCustomSecurityTests {
@Configuration
static class SecurityConfiguration {
@SuppressWarnings("deprecation")
@Bean
public MapReactiveUserDetailsService userDetailsService() {
return new MapReactiveUserDetailsService(

View File

@ -70,6 +70,7 @@ public class SampleMethodSecurityApplication implements WebMvcConfigurer {
@Configuration
protected static class AuthenticationSecurity {
@SuppressWarnings("deprecation")
@Bean
public InMemoryUserDetailsManager inMemoryUserDetailsManager() throws Exception {
return new InMemoryUserDetailsManager(