Commit d117a6b2 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 71c2c69c
...@@ -76,14 +76,17 @@ public class BasicErrorController implements ErrorController { ...@@ -76,14 +76,17 @@ public class BasicErrorController implements ErrorController {
String trace = request.getParameter("trace"); String trace = request.getParameter("trace");
Map<String, Object> extracted = extract(attributes, Map<String, Object> extracted = extract(attributes,
trace != null && !"false".equals(trace.toLowerCase()), true); trace != null && !"false".equals(trace.toLowerCase()), true);
HttpStatus statusCode; HttpStatus statusCode = getStatus((Integer) extracted.get("status"));
return new ResponseEntity<Map<String, Object>>(extracted, statusCode);
}
private HttpStatus getStatus(Integer value) {
try { try {
statusCode = HttpStatus.valueOf((Integer) extracted.get("status")); return HttpStatus.valueOf(value);
} }
catch (Exception e) { catch (Exception ex) {
statusCode = HttpStatus.INTERNAL_SERVER_ERROR; return HttpStatus.INTERNAL_SERVER_ERROR;
} }
return new ResponseEntity<Map<String, Object>>(extracted, statusCode);
} }
@Override @Override
......
...@@ -32,7 +32,6 @@ import org.springframework.test.annotation.DirtiesContext; ...@@ -32,7 +32,6 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
...@@ -61,8 +60,8 @@ public class ManagementPortSampleActuatorApplicationTests { ...@@ -61,8 +60,8 @@ public class ManagementPortSampleActuatorApplicationTests {
@Test @Test
public void testHome() throws Exception { public void testHome() throws Exception {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = getRestTemplate("user", getPassword()).getForEntity( ResponseEntity<Map> entity = RestTemplates.get("user", getPassword())
"http://localhost:" + this.port, Map.class); .getForEntity("http://localhost:" + this.port, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody(); Map<String, Object> body = entity.getBody();
...@@ -73,14 +72,14 @@ public class ManagementPortSampleActuatorApplicationTests { ...@@ -73,14 +72,14 @@ public class ManagementPortSampleActuatorApplicationTests {
public void testMetrics() throws Exception { public void testMetrics() throws Exception {
testHome(); // makes sure some requests have been made testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = getRestTemplate().getForEntity( ResponseEntity<Map> entity = RestTemplates.get().getForEntity(
"http://localhost:" + this.managementPort + "/metrics", Map.class); "http://localhost:" + this.managementPort + "/metrics", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode()); assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
} }
@Test @Test
public void testHealth() throws Exception { public void testHealth() throws Exception {
ResponseEntity<String> entity = getRestTemplate().getForEntity( ResponseEntity<String> entity = RestTemplates.get().getForEntity(
"http://localhost:" + this.managementPort + "/health", String.class); "http://localhost:" + this.managementPort + "/health", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("ok", entity.getBody()); assertEquals("ok", entity.getBody());
...@@ -89,7 +88,7 @@ public class ManagementPortSampleActuatorApplicationTests { ...@@ -89,7 +88,7 @@ public class ManagementPortSampleActuatorApplicationTests {
@Test @Test
public void testErrorPage() throws Exception { public void testErrorPage() throws Exception {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = getRestTemplate().getForEntity( ResponseEntity<Map> entity = RestTemplates.get().getForEntity(
"http://localhost:" + this.managementPort + "/error", Map.class); "http://localhost:" + this.managementPort + "/error", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -101,12 +100,4 @@ public class ManagementPortSampleActuatorApplicationTests { ...@@ -101,12 +100,4 @@ public class ManagementPortSampleActuatorApplicationTests {
return this.security.getUser().getPassword(); return this.security.getUser().getPassword();
} }
private RestTemplate getRestTemplate() {
return RestTemplates.get();
}
private RestTemplate getRestTemplate(final String username, final String password) {
return RestTemplates.get(username, password);
}
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -63,4 +63,5 @@ abstract class Banner { ...@@ -63,4 +63,5 @@ abstract class Banner {
FAINT, version)); FAINT, version));
printStream.println(); printStream.println();
} }
} }
...@@ -301,10 +301,13 @@ class BeanDefinitionLoader { ...@@ -301,10 +301,13 @@ class BeanDefinitionLoader {
protected boolean matchClassName(String className) { protected boolean matchClassName(String className) {
return this.classNames.contains(className); return this.classNames.contains(className);
} }
} }
protected interface GroovyBeanDefinitionSource { protected interface GroovyBeanDefinitionSource {
Closure<?> getBeans(); Closure<?> getBeans();
} }
} }
...@@ -24,19 +24,31 @@ package org.springframework.boot.ansi; ...@@ -24,19 +24,31 @@ package org.springframework.boot.ansi;
public interface AnsiElement { public interface AnsiElement {
public static final AnsiElement NORMAL = new DefaultAnsiElement("0"); public static final AnsiElement NORMAL = new DefaultAnsiElement("0");
public static final AnsiElement BOLD = new DefaultAnsiElement("1"); public static final AnsiElement BOLD = new DefaultAnsiElement("1");
public static final AnsiElement FAINT = new DefaultAnsiElement("2"); public static final AnsiElement FAINT = new DefaultAnsiElement("2");
public static final AnsiElement ITALIC = new DefaultAnsiElement("3"); public static final AnsiElement ITALIC = new DefaultAnsiElement("3");
public static final AnsiElement UNDERLINE = new DefaultAnsiElement("4"); public static final AnsiElement UNDERLINE = new DefaultAnsiElement("4");
public static final AnsiElement BLACK = new DefaultAnsiElement("30"); public static final AnsiElement BLACK = new DefaultAnsiElement("30");
public static final AnsiElement RED = new DefaultAnsiElement("31"); public static final AnsiElement RED = new DefaultAnsiElement("31");
public static final AnsiElement GREEN = new DefaultAnsiElement("32"); public static final AnsiElement GREEN = new DefaultAnsiElement("32");
public static final AnsiElement YELLOW = new DefaultAnsiElement("33"); public static final AnsiElement YELLOW = new DefaultAnsiElement("33");
public static final AnsiElement BLUE = new DefaultAnsiElement("34"); public static final AnsiElement BLUE = new DefaultAnsiElement("34");
public static final AnsiElement MAGENTA = new DefaultAnsiElement("35"); public static final AnsiElement MAGENTA = new DefaultAnsiElement("35");
public static final AnsiElement CYAN = new DefaultAnsiElement("36"); public static final AnsiElement CYAN = new DefaultAnsiElement("36");
public static final AnsiElement WHITE = new DefaultAnsiElement("37"); public static final AnsiElement WHITE = new DefaultAnsiElement("37");
public static final AnsiElement DEFAULT = new DefaultAnsiElement("39"); public static final AnsiElement DEFAULT = new DefaultAnsiElement("39");
/** /**
...@@ -60,6 +72,7 @@ public interface AnsiElement { ...@@ -60,6 +72,7 @@ public interface AnsiElement {
public String toString() { public String toString() {
return this.code; return this.code;
} }
} }
} }
...@@ -90,6 +90,7 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -90,6 +90,7 @@ public final class RelaxedNames implements Iterable<String> {
}; };
public abstract String apply(String value); public abstract String apply(String value);
} }
static enum Manipulation { static enum Manipulation {
...@@ -157,5 +158,7 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -157,5 +158,7 @@ public final class RelaxedNames implements Iterable<String> {
}; };
public abstract String apply(String value); public abstract String apply(String value);
} }
} }
/* /*
* Copyright 2012-2013 the original author or authors. * Copyright 2012-2014 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.
...@@ -89,5 +89,6 @@ public class YamlJavaBeanPropertyConstructor extends Constructor { ...@@ -89,5 +89,6 @@ public class YamlJavaBeanPropertyConstructor extends Constructor {
Property property = (forType == null ? null : forType.get(name)); Property property = (forType == null ? null : forType.get(name));
return (property == null ? super.getProperty(type, name) : property); return (property == null ? super.getProperty(type, name) : property);
} }
} }
} }
...@@ -75,6 +75,7 @@ public class ParentContextApplicationContextInitializer implements ...@@ -75,6 +75,7 @@ public class ParentContextApplicationContextInitializer implements
(ConfigurableApplicationContext) context)); (ConfigurableApplicationContext) context));
} }
} }
} }
public static class ParentContextAvailableEvent extends ApplicationEvent { public static class ParentContextAvailableEvent extends ApplicationEvent {
......
...@@ -75,4 +75,5 @@ public class FileEncodingApplicationListener implements ...@@ -75,4 +75,5 @@ public class FileEncodingApplicationListener implements
} }
} }
} }
}; };
...@@ -48,6 +48,7 @@ public interface EmbeddedServletContainer { ...@@ -48,6 +48,7 @@ public interface EmbeddedServletContainer {
public int getPort() { public int getPort() {
return 0; return 0;
} }
}; };
/** /**
......
...@@ -75,4 +75,5 @@ public class EnumerableCompositePropertySource extends ...@@ -75,4 +75,5 @@ public class EnumerableCompositePropertySource extends
getSource().add(source); getSource().add(source);
this.names = null; this.names = null;
} }
} }
...@@ -48,4 +48,5 @@ public class PropertiesPropertySourceLoader implements PropertySourceLoader { ...@@ -48,4 +48,5 @@ public class PropertiesPropertySourceLoader implements PropertySourceLoader {
} }
return null; return null;
} }
} }
/* /*
* Copyright 2012-2013 the original author or authors. * Copyright 2012-2014 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.
...@@ -640,4 +640,5 @@ class InvalidBase64CharacterException extends IllegalArgumentException { ...@@ -640,4 +640,5 @@ class InvalidBase64CharacterException extends IllegalArgumentException {
InvalidBase64CharacterException(String message) { InvalidBase64CharacterException(String message) {
super(message); super(message);
} }
} }
...@@ -487,9 +487,11 @@ public class RelaxedDataBinderTests { ...@@ -487,9 +487,11 @@ public class RelaxedDataBinderTests {
public void setInfo(Map<String, Object> nested) { public void setInfo(Map<String, Object> nested) {
this.info = nested; this.info = nested;
} }
} }
public static class TargetWithNestedMap { public static class TargetWithNestedMap {
private Map<String, Object> nested; private Map<String, Object> nested;
public Map<String, Object> getNested() { public Map<String, Object> getNested() {
...@@ -499,9 +501,11 @@ public class RelaxedDataBinderTests { ...@@ -499,9 +501,11 @@ public class RelaxedDataBinderTests {
public void setNested(Map<String, Object> nested) { public void setNested(Map<String, Object> nested) {
this.nested = nested; this.nested = nested;
} }
} }
public static class TargetWithNestedMapOfString { public static class TargetWithNestedMapOfString {
private Map<String, String> nested; private Map<String, String> nested;
public Map<String, String> getNested() { public Map<String, String> getNested() {
...@@ -511,9 +515,11 @@ public class RelaxedDataBinderTests { ...@@ -511,9 +515,11 @@ public class RelaxedDataBinderTests {
public void setNested(Map<String, String> nested) { public void setNested(Map<String, String> nested) {
this.nested = nested; this.nested = nested;
} }
} }
public static class TargetWithNestedMapOfListOfString { public static class TargetWithNestedMapOfListOfString {
private Map<String, List<String>> nested; private Map<String, List<String>> nested;
public Map<String, List<String>> getNested() { public Map<String, List<String>> getNested() {
...@@ -523,9 +529,11 @@ public class RelaxedDataBinderTests { ...@@ -523,9 +529,11 @@ public class RelaxedDataBinderTests {
public void setNested(Map<String, List<String>> nested) { public void setNested(Map<String, List<String>> nested) {
this.nested = nested; this.nested = nested;
} }
} }
public static class TargetWithNestedMapOfListOfBean { public static class TargetWithNestedMapOfListOfBean {
private Map<String, List<VanillaTarget>> nested; private Map<String, List<VanillaTarget>> nested;
public Map<String, List<VanillaTarget>> getNested() { public Map<String, List<VanillaTarget>> getNested() {
...@@ -535,9 +543,11 @@ public class RelaxedDataBinderTests { ...@@ -535,9 +543,11 @@ public class RelaxedDataBinderTests {
public void setNested(Map<String, List<VanillaTarget>> nested) { public void setNested(Map<String, List<VanillaTarget>> nested) {
this.nested = nested; this.nested = nested;
} }
} }
public static class TargetWithNestedMapOfBean { public static class TargetWithNestedMapOfBean {
private Map<String, VanillaTarget> nested; private Map<String, VanillaTarget> nested;
public Map<String, VanillaTarget> getNested() { public Map<String, VanillaTarget> getNested() {
...@@ -547,9 +557,11 @@ public class RelaxedDataBinderTests { ...@@ -547,9 +557,11 @@ public class RelaxedDataBinderTests {
public void setNested(Map<String, VanillaTarget> nested) { public void setNested(Map<String, VanillaTarget> nested) {
this.nested = nested; this.nested = nested;
} }
} }
public static class TargetWithNestedList { public static class TargetWithNestedList {
private List<String> nested; private List<String> nested;
public List<String> getNested() { public List<String> getNested() {
...@@ -559,33 +571,41 @@ public class RelaxedDataBinderTests { ...@@ -559,33 +571,41 @@ public class RelaxedDataBinderTests {
public void setNested(List<String> nested) { public void setNested(List<String> nested) {
this.nested = nested; this.nested = nested;
} }
} }
public static class TargetWithReadOnlyNestedList { public static class TargetWithReadOnlyNestedList {
private final List<String> nested = new ArrayList<String>(); private final List<String> nested = new ArrayList<String>();
public List<String> getNested() { public List<String> getNested() {
return this.nested; return this.nested;
} }
} }
public static class TargetWithReadOnlyDoubleNestedList { public static class TargetWithReadOnlyDoubleNestedList {
TargetWithReadOnlyNestedList bean = new TargetWithReadOnlyNestedList(); TargetWithReadOnlyNestedList bean = new TargetWithReadOnlyNestedList();
public TargetWithReadOnlyNestedList getBean() { public TargetWithReadOnlyNestedList getBean() {
return this.bean; return this.bean;
} }
} }
public static class TargetWithReadOnlyNestedCollection { public static class TargetWithReadOnlyNestedCollection {
private final Collection<String> nested = new ArrayList<String>(); private final Collection<String> nested = new ArrayList<String>();
public Collection<String> getNested() { public Collection<String> getNested() {
return this.nested; return this.nested;
} }
} }
public static class TargetWithNestedSet { public static class TargetWithNestedSet {
private Set<String> nested = new LinkedHashSet<String>(); private Set<String> nested = new LinkedHashSet<String>();
public Set<String> getNested() { public Set<String> getNested() {
...@@ -595,6 +615,7 @@ public class RelaxedDataBinderTests { ...@@ -595,6 +615,7 @@ public class RelaxedDataBinderTests {
public void setNested(Set<String> nested) { public void setNested(Set<String> nested) {
this.nested = nested; this.nested = nested;
} }
} }
public static class TargetWithNestedObject { public static class TargetWithNestedObject {
...@@ -650,6 +671,7 @@ public class RelaxedDataBinderTests { ...@@ -650,6 +671,7 @@ public class RelaxedDataBinderTests {
public void setFooBaz(String fooBaz) { public void setFooBaz(String fooBaz) {
this.fooBaz = fooBaz; this.fooBaz = fooBaz;
} }
} }
public static class ValidatedTarget { public static class ValidatedTarget {
......
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