Polish formatting

pull/3555/merge
Phillip Webb 9 years ago
parent f39e8a25cf
commit 4279ffeddf

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -104,11 +103,8 @@ class EnableAutoConfigurationImportSelector implements DeferredImportSelector,
private List<String> getExcludeAutoConfigurationsProperty() { private List<String> getExcludeAutoConfigurationsProperty() {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(this.environment, RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(this.environment,
"spring.autoconfigure."); "spring.autoconfigure.");
String[] value = resolver.getProperty("exclude", String[].class); String[] exclude = resolver.getProperty("exclude", String[].class);
if (value != null) { return (Arrays.asList(exclude == null ? new String[0] : exclude));
return Arrays.asList(value);
}
return Collections.emptyList();
} }
@Override @Override

@ -23,7 +23,7 @@ import org.springframework.context.annotation.Configuration;
/** /**
* {@link EnableAutoConfiguration Auto-configuration} for {@link ConfigurationProperties} * {@link EnableAutoConfiguration Auto-configuration} for {@link ConfigurationProperties}
* annotated beans. Automatically any bean annotated with {@code @ConfigurationProperties}. * beans. Automatically any bean annotated with {@code @ConfigurationProperties}.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 1.3.0 * @since 1.3.0

@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.mail;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import javax.activation.MimeType; import javax.activation.MimeType;
import javax.mail.Session; import javax.mail.Session;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;

@ -109,8 +109,8 @@ public class EnableAutoConfigurationImportSelectorTests {
@Test @Test
public void propertyExclusionsAreApplied() { public void propertyExclusionsAreApplied() {
configureExclusions(new String[0], new String[0], new String[] { configureExclusions(new String[0], new String[0],
FreeMarkerAutoConfiguration.class.getName()}); new String[] { FreeMarkerAutoConfiguration.class.getName() });
String[] imports = this.importSelector.selectImports(this.annotationMetadata); String[] imports = this.importSelector.selectImports(this.annotationMetadata);
assertThat(imports.length, assertThat(imports.length,
is(equalTo(getAutoConfigurationClassNames().size() - 1))); is(equalTo(getAutoConfigurationClassNames().size() - 1)));
@ -121,8 +121,8 @@ public class EnableAutoConfigurationImportSelectorTests {
@Test @Test
public void severalPropertyExclusionsAreApplied() { public void severalPropertyExclusionsAreApplied() {
configureExclusions(new String[0], new String[0], new String[] { configureExclusions(new String[0], new String[0], new String[] {
FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration FreeMarkerAutoConfiguration.class.getName(),
.class.getName()}); VelocityAutoConfiguration.class.getName() });
String[] imports = this.importSelector.selectImports(this.annotationMetadata); String[] imports = this.importSelector.selectImports(this.annotationMetadata);
assertThat(imports.length, assertThat(imports.length,
@ -160,8 +160,7 @@ public class EnableAutoConfigurationImportSelectorTests {
nameExclusion); nameExclusion);
if (propertyExclusion.length > 0) { if (propertyExclusion.length > 0) {
String value = StringUtils.arrayToCommaDelimitedString(propertyExclusion); String value = StringUtils.arrayToCommaDelimitedString(propertyExclusion);
this.environment.setProperty("spring.autoconfigure.exclude", this.environment.setProperty("spring.autoconfigure.exclude", value);
value);
} }
} }

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.context;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@ -45,8 +44,8 @@ public class ConfigurationPropertiesAutoConfigurationTests {
@Test @Test
public void processAnnotatedBean() { public void processAnnotatedBean() {
load(new Class[] {SampleBean.class, ConfigurationPropertiesAutoConfiguration.class}, load(new Class[] { SampleBean.class,
"foo.name:test"); ConfigurationPropertiesAutoConfiguration.class }, "foo.name:test");
assertThat(this.context.getBean(SampleBean.class).getName(), is("test")); assertThat(this.context.getBean(SampleBean.class).getName(), is("test"));
} }
@ -56,18 +55,16 @@ public class ConfigurationPropertiesAutoConfigurationTests {
assertThat(this.context.getBean(SampleBean.class).getName(), is("default")); assertThat(this.context.getBean(SampleBean.class).getName(), is("default"));
} }
private void load(Class<?>[] configs, private void load(Class<?>[] configs, String... environment) {
String... environment) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
this.context.register(configs); this.context.register(configs);
EnvironmentTestUtils.addEnvironment(this.context, environment); EnvironmentTestUtils.addEnvironment(this.context, environment);
this.context.refresh(); this.context.refresh();
} }
@Component @Component
@ConfigurationProperties("foo") @ConfigurationProperties("foo")
private static class SampleBean { static class SampleBean {
private String name = "default"; private String name = "default";

@ -170,20 +170,20 @@ public class SpringBootWebSecurityConfigurationTests {
// gh-3447 // gh-3447
@Test @Test
public void testHiddenHttpMethodFilterOrderedFirst() public void testHiddenHttpMethodFilterOrderedFirst() throws Exception {
throws Exception {
this.context = SpringApplication.run(DenyPostRequestConfig.class, this.context = SpringApplication.run(DenyPostRequestConfig.class,
"--server.port=0"); "--server.port=0");
int port = Integer.parseInt(this.context.getEnvironment().getProperty("local.server.port")); int port = Integer.parseInt(this.context.getEnvironment().getProperty(
"local.server.port"));
TestRestTemplate rest = new TestRestTemplate(); TestRestTemplate rest = new TestRestTemplate();
// not overriding causes forbidden // not overriding causes forbidden
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
ResponseEntity<Object> result = rest.postForEntity("http://localhost:" + port + "/", form, Object.class); ResponseEntity<Object> result = rest.postForEntity("http://localhost:" + port
+ "/", form, Object.class);
assertEquals(HttpStatus.FORBIDDEN, result.getStatusCode()); assertEquals(HttpStatus.FORBIDDEN, result.getStatusCode());
// override method with GET // override method with GET
form = new LinkedMultiValueMap<String, String>(); form = new LinkedMultiValueMap<String, String>();
form.add("_method", "GET"); form.add("_method", "GET");
@ -257,9 +257,8 @@ public class SpringBootWebSecurityConfigurationTests {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http http.authorizeRequests().antMatchers(HttpMethod.POST, "/**").denyAll();
.authorizeRequests()
.antMatchers(HttpMethod.POST, "/**").denyAll();
} }
} }
} }

Loading…
Cancel
Save