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