Commit c9726898 authored by Phillip Webb's avatar Phillip Webb

Polish

parent d301d0f4
...@@ -68,17 +68,19 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter { ...@@ -68,17 +68,19 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter {
// disabled // disabled
return getDisabledResponse(); return getDisabledResponse();
} }
LogLevel logLevel;
try { try {
String level = configuration.get("configuredLevel"); LogLevel logLevel = getLogLevel(configuration);
logLevel = level == null ? null : LogLevel.valueOf(level.toUpperCase()); this.delegate.setLogLevel(name, logLevel);
return ResponseEntity.ok().build();
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
return ResponseEntity.badRequest().build(); return ResponseEntity.badRequest().build();
} }
}
this.delegate.setLogLevel(name, logLevel); private LogLevel getLogLevel(Map<String, String> configuration) {
return ResponseEntity.ok().build(); String level = configuration.get("configuredLevel");
return (level == null ? null : LogLevel.valueOf(level.toUpperCase()));
} }
} }
...@@ -66,7 +66,7 @@ public class TraceWebFilterAutoConfigurationTests { ...@@ -66,7 +66,7 @@ public class TraceWebFilterAutoConfigurationTests {
public void skipsFilterIfPropertyDisabled() throws Exception { public void skipsFilterIfPropertyDisabled() throws Exception {
load("endpoints.trace.filter.enabled:false"); load("endpoints.trace.filter.enabled:false");
assertThat(this.context.getBeansOfType(WebRequestTraceFilter.class).size()) assertThat(this.context.getBeansOfType(WebRequestTraceFilter.class).size())
.isEqualTo(0); .isEqualTo(0);
} }
private void load(String... environment) { private void load(String... environment) {
...@@ -74,16 +74,16 @@ public class TraceWebFilterAutoConfigurationTests { ...@@ -74,16 +74,16 @@ public class TraceWebFilterAutoConfigurationTests {
} }
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); EnvironmentTestUtils.addEnvironment(context, environment);
if (config != null) { if (config != null) {
ctx.register(config); context.register(config);
} }
ctx.register(PropertyPlaceholderAutoConfiguration.class, context.register(PropertyPlaceholderAutoConfiguration.class,
TraceRepositoryAutoConfiguration.class, TraceRepositoryAutoConfiguration.class,
TraceWebFilterAutoConfiguration.class); TraceWebFilterAutoConfiguration.class);
ctx.refresh(); context.refresh();
this.context = ctx; this.context = context;
} }
@Configuration @Configuration
......
...@@ -66,8 +66,8 @@ public class ValidationAutoConfiguration { ...@@ -66,8 +66,8 @@ public class ValidationAutoConfiguration {
} }
private static boolean determineProxyTargetClass(Environment environment) { private static boolean determineProxyTargetClass(Environment environment) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
environment, "spring.aop."); "spring.aop.");
Boolean value = resolver.getProperty("proxyTargetClass", Boolean.class); Boolean value = resolver.getProperty("proxyTargetClass", Boolean.class);
return (value != null ? value : true); return (value != null ? value : true);
} }
......
...@@ -78,12 +78,12 @@ public class ValidationAutoConfigurationTests { ...@@ -78,12 +78,12 @@ public class ValidationAutoConfigurationTests {
@Test @Test
public void validationCanBeConfiguredToUseJdkProxy() { public void validationCanBeConfiguredToUseJdkProxy() {
load(AnotherSampleServiceConfiguration.class, "spring.aop.proxy-target-class=false"); load(AnotherSampleServiceConfiguration.class,
"spring.aop.proxy-target-class=false");
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1); assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
assertThat(this.context.getBeansOfType(DefaultAnotherSampleService.class)) assertThat(this.context.getBeansOfType(DefaultAnotherSampleService.class))
.isEmpty(); .isEmpty();
AnotherSampleService service = this.context AnotherSampleService service = this.context.getBean(AnotherSampleService.class);
.getBean(AnotherSampleService.class);
service.doSomething(42); service.doSomething(42);
this.thrown.expect(ConstraintViolationException.class); this.thrown.expect(ConstraintViolationException.class);
service.doSomething(2); service.doSomething(2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment