Format with Eclipse Oxygen SR2
This commit is contained in:
@@ -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.
|
||||
@@ -133,11 +133,9 @@ public class EnvironmentEndpoint {
|
||||
String propertyName) {
|
||||
Map<String, PropertyValueDescriptor> propertySources = new LinkedHashMap<>();
|
||||
PlaceholdersResolver resolver = getResolver();
|
||||
getPropertySourcesAsMap()
|
||||
.forEach((sourceName, source) -> propertySources.put(sourceName,
|
||||
source.containsProperty(propertyName)
|
||||
? describeValueOf(propertyName, source, resolver)
|
||||
: null));
|
||||
getPropertySourcesAsMap().forEach((sourceName, source) -> propertySources
|
||||
.put(sourceName, source.containsProperty(propertyName)
|
||||
? describeValueOf(propertyName, source, resolver) : null));
|
||||
return propertySources;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,10 +120,8 @@ public class MetricsEndpoint {
|
||||
}
|
||||
|
||||
private void mergeMeasurements(Map<Statistic, Double> samples, Meter meter) {
|
||||
meter.measure()
|
||||
.forEach((measurement) -> samples.merge(measurement.getStatistic(),
|
||||
measurement.getValue(),
|
||||
mergeFunction(measurement.getStatistic())));
|
||||
meter.measure().forEach((measurement) -> samples.merge(measurement.getStatistic(),
|
||||
measurement.getValue(), mergeFunction(measurement.getStatistic())));
|
||||
}
|
||||
|
||||
private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) {
|
||||
|
||||
@@ -107,13 +107,13 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
throws ServletException, IOException {
|
||||
filterAndRecordMetrics(request, response, filterChain);
|
||||
}
|
||||
|
||||
private void filterAndRecordMetrics(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws IOException, ServletException, NestedServletException {
|
||||
throws IOException, ServletException, NestedServletException {
|
||||
Object handler = null;
|
||||
try {
|
||||
handler = getHandler(request);
|
||||
@@ -150,7 +150,7 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
|
||||
|
||||
private void filterAndRecordMetrics(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain, Object handler)
|
||||
throws IOException, ServletException, NestedServletException {
|
||||
throws IOException, ServletException, NestedServletException {
|
||||
TimingContext timingContext = TimingContext.get(request);
|
||||
if (timingContext == null) {
|
||||
timingContext = startAndAttachTimingContext(request, handler);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class HttpTraceFilter extends OncePerRequestFilter implements Ordered {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
throws ServletException, IOException {
|
||||
TraceableHttpServletRequest traceableRequest = new TraceableHttpServletRequest(
|
||||
request);
|
||||
HttpTrace trace = this.tracer.receivedRequest(traceableRequest);
|
||||
|
||||
@@ -100,12 +100,13 @@ public class BeansEndpointTests {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(EndpointConfiguration.class).withParent(parent)
|
||||
.run((child) -> {
|
||||
ApplicationBeans result = child.getBean(BeansEndpoint.class).beans();
|
||||
assertThat(result.getContexts().get(parent.getId()).getBeans())
|
||||
.containsKey("bean");
|
||||
assertThat(result.getContexts().get(child.getId()).getBeans())
|
||||
.containsKey("endpoint");
|
||||
});
|
||||
ApplicationBeans result = child.getBean(BeansEndpoint.class)
|
||||
.beans();
|
||||
assertThat(result.getContexts().get(parent.getId()).getBeans())
|
||||
.containsKey("bean");
|
||||
assertThat(result.getContexts().get(child.getId()).getBeans())
|
||||
.containsKey("endpoint");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -43,18 +43,20 @@ public class ConfigurationPropertiesReportEndpointParentTests {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(ClassConfigurationProperties.class)
|
||||
.withParent(parent).run((child) -> {
|
||||
ConfigurationPropertiesReportEndpoint endpoint = child
|
||||
.getBean(ConfigurationPropertiesReportEndpoint.class);
|
||||
ApplicationConfigurationProperties applicationProperties = endpoint
|
||||
.configurationProperties();
|
||||
assertThat(applicationProperties.getContexts())
|
||||
.containsOnlyKeys(child.getId(), parent.getId());
|
||||
assertThat(applicationProperties.getContexts().get(child.getId())
|
||||
.getBeans().keySet()).containsExactly("someProperties");
|
||||
assertThat((applicationProperties.getContexts()
|
||||
.get(parent.getId()).getBeans().keySet()))
|
||||
.containsExactly("testProperties");
|
||||
});
|
||||
ConfigurationPropertiesReportEndpoint endpoint = child
|
||||
.getBean(
|
||||
ConfigurationPropertiesReportEndpoint.class);
|
||||
ApplicationConfigurationProperties applicationProperties = endpoint
|
||||
.configurationProperties();
|
||||
assertThat(applicationProperties.getContexts())
|
||||
.containsOnlyKeys(child.getId(), parent.getId());
|
||||
assertThat(applicationProperties.getContexts()
|
||||
.get(child.getId()).getBeans().keySet())
|
||||
.containsExactly("someProperties");
|
||||
assertThat((applicationProperties.getContexts()
|
||||
.get(parent.getId()).getBeans().keySet()))
|
||||
.containsExactly("testProperties");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,17 +68,19 @@ public class ConfigurationPropertiesReportEndpointParentTests {
|
||||
.withUserConfiguration(
|
||||
BeanMethodConfigurationProperties.class)
|
||||
.withParent(parent).run((child) -> {
|
||||
ConfigurationPropertiesReportEndpoint endpoint = child
|
||||
.getBean(ConfigurationPropertiesReportEndpoint.class);
|
||||
ApplicationConfigurationProperties applicationProperties = endpoint
|
||||
.configurationProperties();
|
||||
assertThat(applicationProperties.getContexts().get(child.getId())
|
||||
.getBeans().keySet())
|
||||
.containsExactlyInAnyOrder("otherProperties");
|
||||
assertThat((applicationProperties.getContexts()
|
||||
.get(parent.getId()).getBeans().keySet()))
|
||||
.containsExactly("testProperties");
|
||||
});
|
||||
ConfigurationPropertiesReportEndpoint endpoint = child
|
||||
.getBean(
|
||||
ConfigurationPropertiesReportEndpoint.class);
|
||||
ApplicationConfigurationProperties applicationProperties = endpoint
|
||||
.configurationProperties();
|
||||
assertThat(applicationProperties.getContexts()
|
||||
.get(child.getId()).getBeans().keySet())
|
||||
.containsExactlyInAnyOrder(
|
||||
"otherProperties");
|
||||
assertThat((applicationProperties.getContexts()
|
||||
.get(parent.getId()).getBeans().keySet()))
|
||||
.containsExactly("testProperties");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public class JerseyWebEndpointIntegrationTests extends
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
throws ServletException, IOException {
|
||||
filterChain.doFilter(new HttpServletRequestWrapper(request) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,15 +66,13 @@ public class WebFluxEndpointIntegrationTests
|
||||
|
||||
@Test
|
||||
public void responseToOptionsRequestIncludesCorsHeaders() {
|
||||
load(TestEndpointConfiguration.class,
|
||||
(client) -> client.options().uri("/test")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.header("Access-Control-Request-Method", "POST")
|
||||
.header("Origin", "http://example.com").exchange().expectStatus()
|
||||
.isOk().expectHeader()
|
||||
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
|
||||
.expectHeader()
|
||||
.valueEquals("Access-Control-Allow-Methods", "GET,POST"));
|
||||
load(TestEndpointConfiguration.class, (client) -> client.options().uri("/test")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.header("Access-Control-Request-Method", "POST")
|
||||
.header("Origin", "http://example.com").exchange().expectStatus().isOk()
|
||||
.expectHeader()
|
||||
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
|
||||
.expectHeader().valueEquals("Access-Control-Allow-Methods", "GET,POST"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -68,15 +68,13 @@ public class MvcWebEndpointIntegrationTests extends
|
||||
|
||||
@Test
|
||||
public void responseToOptionsRequestIncludesCorsHeaders() {
|
||||
load(TestEndpointConfiguration.class,
|
||||
(client) -> client.options().uri("/test")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.header("Access-Control-Request-Method", "POST")
|
||||
.header("Origin", "http://example.com").exchange().expectStatus()
|
||||
.isOk().expectHeader()
|
||||
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
|
||||
.expectHeader()
|
||||
.valueEquals("Access-Control-Allow-Methods", "GET,POST"));
|
||||
load(TestEndpointConfiguration.class, (client) -> client.options().uri("/test")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.header("Access-Control-Request-Method", "POST")
|
||||
.header("Origin", "http://example.com").exchange().expectStatus().isOk()
|
||||
.expectHeader()
|
||||
.valueEquals("Access-Control-Allow-Origin", "http://example.com")
|
||||
.expectHeader().valueEquals("Access-Control-Allow-Methods", "GET,POST"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,7 +145,7 @@ public class MvcWebEndpointIntegrationTests extends
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
throws ServletException, IOException {
|
||||
filterChain.doFilter(new HttpServletRequestWrapper(request) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,8 +70,8 @@ public class MetricsEndpointWebIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void selectByTag() {
|
||||
client.get()
|
||||
.uri("/actuator/metrics/jvm.memory.used?tag=id:Compressed%20Class%20Space")
|
||||
client.get().uri(
|
||||
"/actuator/metrics/jvm.memory.used?tag=id:Compressed%20Class%20Space")
|
||||
.exchange().expectStatus().isOk().expectBody().jsonPath("$.name")
|
||||
.isEqualTo("jvm.memory.used");
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public class MetricsRestTemplateCustomizerTests {
|
||||
.andRespond(MockRestResponseCreators.withSuccess("OK",
|
||||
MediaType.APPLICATION_JSON));
|
||||
String result = this.restTemplate.getForObject("/test/{id}", String.class, 123);
|
||||
assertThat(this.registry.find("http.client.requests")
|
||||
.meters()).anySatisfy((m) -> assertThat(
|
||||
assertThat(this.registry.find("http.client.requests").meters())
|
||||
.anySatisfy((m) -> assertThat(
|
||||
StreamSupport.stream(m.getId().getTags().spliterator(), false)
|
||||
.map(Tag::getKey)).doesNotContain("bucket"));
|
||||
assertThat(this.registry.get("http.client.requests")
|
||||
|
||||
@@ -497,7 +497,7 @@ public class WebMvcMetricsFilterTests {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
throws ServletException, IOException {
|
||||
String misbehave = request.getHeader(TEST_MISBEHAVE_HEADER);
|
||||
if (misbehave != null) {
|
||||
response.setStatus(Integer.parseInt(misbehave));
|
||||
|
||||
@@ -205,12 +205,11 @@ public class HttpExchangeTracerTests {
|
||||
@Test
|
||||
public void mixedCaseSetCookieHeaderIsNotIncludedByDefault() {
|
||||
HttpTrace trace = new HttpTrace(createRequest());
|
||||
new HttpExchangeTracer(EnumSet.of(Include.RESPONSE_HEADERS))
|
||||
.sendingResponse(trace,
|
||||
createResponse(Collections.singletonMap(
|
||||
mixedCase(HttpHeaders.SET_COOKIE),
|
||||
Arrays.asList("test=test"))),
|
||||
null, null);
|
||||
new HttpExchangeTracer(EnumSet.of(Include.RESPONSE_HEADERS)).sendingResponse(
|
||||
trace,
|
||||
createResponse(Collections.singletonMap(mixedCase(HttpHeaders.SET_COOKIE),
|
||||
Arrays.asList("test=test"))),
|
||||
null, null);
|
||||
assertThat(trace.getResponse().getHeaders()).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class HttpTraceFilterTests {
|
||||
@Override
|
||||
protected void service(HttpServletRequest req,
|
||||
HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
throws ServletException, IOException {
|
||||
req.getSession(true);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class HttpTraceFilterTests {
|
||||
@Override
|
||||
protected void service(HttpServletRequest req,
|
||||
HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
throws ServletException, IOException {
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user