Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.CollectorRegistry;
import org.junit.Test;
Expand Down Expand Up @@ -54,14 +53,7 @@ static class TestConfiguration {
public PrometheusScrapeEndpoint endpoint() {
CollectorRegistry collectorRegistry = new CollectorRegistry(true);
PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(
new PrometheusConfig() {

@Override
public String get(String key) {
return null;
}

}, collectorRegistry, Clock.SYSTEM);
(key) -> null, collectorRegistry, Clock.SYSTEM);
new JvmMemoryMetrics().bindTo(meterRegistry);
return new PrometheusScrapeEndpoint(collectorRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.metrics;

import io.micrometer.core.instrument.Clock;
import io.micrometer.newrelic.NewRelicConfig;
import io.micrometer.newrelic.NewRelicMeterRegistry;
import org.junit.Test;

Expand Down Expand Up @@ -64,14 +63,7 @@ static class MissingAccountIdConfiguration {

@Bean
public NewRelicMeterRegistry meterRegistry() {
return new NewRelicMeterRegistry(new NewRelicConfig() {

@Override
public String get(String key) {
return null;
}

}, Clock.SYSTEM);
return new NewRelicMeterRegistry((key) -> null, Clock.SYSTEM);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,7 @@ static class CustomConfigConfiguration {

@Bean
public AtlasConfig customConfig() {
return new AtlasConfig() {

@Override
public String get(String k) {
return null;
}

};
return (k) -> null;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,11 @@ static class CustomConfigConfiguration {

@Bean
public DatadogConfig customConfig() {
return new DatadogConfig() {

@Override
public String get(String k) {
if ("datadog.apiKey".equals(k)) {
return "12345";
}
return null;
return (k) -> {
if ("datadog.apiKey".equals(k)) {
return "12345";
}

return null;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,7 @@ static class CustomConfigConfiguration {

@Bean
public GangliaConfig customConfig() {
return new GangliaConfig() {

@Override
public String get(String k) {
return null;
}

};
return (k) -> null;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,11 @@ static class CustomConfigConfiguration {

@Bean
public GraphiteConfig customConfig() {
return new GraphiteConfig() {

@Override
public String get(String k) {
if ("Graphite.apiKey".equals(k)) {
return "12345";
}
return null;
return (k) -> {
if ("Graphite.apiKey".equals(k)) {
return "12345";
}

return null;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,7 @@ static class CustomConfigConfiguration {

@Bean
public HumioConfig customConfig() {
return new HumioConfig() {

@Override
public String get(String k) {
return null;
}

};
return (k) -> null;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,7 @@ static class CustomConfigConfiguration {

@Bean
public InfluxConfig customConfig() {
return new InfluxConfig() {

@Override
public String get(String k) {
return null;
}

};
return (k) -> null;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,14 @@ static class CustomConfigConfiguration {

@Bean
public NewRelicConfig customConfig() {
return new NewRelicConfig() {

@Override
public String get(String k) {
if ("newrelic.accountId".equals(k)) {
return "abcde";
}
if ("newrelic.apiKey".equals(k)) {
return "12345";
}
return null;
return (k) -> {
if ("newrelic.accountId".equals(k)) {
return "abcde";
}

if ("newrelic.apiKey".equals(k)) {
return "12345";
}
return null;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,7 @@ static class CustomConfigConfiguration {

@Bean
public PrometheusConfig customConfig() {
return new PrometheusConfig() {

@Override
public String get(String k) {
return null;
}

};
return (k) -> null;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,11 @@ static class CustomConfigConfiguration {

@Bean
public SignalFxConfig customConfig() {
return new SignalFxConfig() {

@Override
public String get(String k) {
if ("signalfx.accessToken".equals(k)) {
return "abcde";
}
return null;
return (k) -> {
if ("signalfx.accessToken".equals(k)) {
return "abcde";
}

return null;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,7 @@ static class CustomConfigConfiguration {

@Bean
public SimpleConfig customConfig() {
return new SimpleConfig() {

@Override
public String get(String k) {
return null;
}

};
return (k) -> null;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.Arrays;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;

import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
Expand All @@ -44,9 +44,7 @@
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -148,20 +146,11 @@ static class AuthenticatedConfiguration {

@Bean
public WebFilter webFilter() {
return new WebFilter() {

@Override
public Mono<Void> filter(ServerWebExchange exchange,
WebFilterChain chain) {
return chain.filter(exchange).subscriberContext(
ReactiveSecurityContextHolder.withAuthentication(
new UsernamePasswordAuthenticationToken("Alice",
"secret",
Arrays.asList(new SimpleGrantedAuthority(
"ROLE_ACTUATOR")))));
}

};
return (exchange, chain) -> chain.filter(exchange)
.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(
new UsernamePasswordAuthenticationToken("Alice", "secret",
Arrays.asList(new SimpleGrantedAuthority(
"ROLE_ACTUATOR")))));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
import org.springframework.boot.actuate.web.trace.reactive.HttpTraceWebFilter;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebExchangeDecorator;
import org.springframework.web.server.WebFilterChain;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
Expand All @@ -61,14 +59,7 @@ public void filterTracesExchange() throws ServletException, IOException {
this.filter.filter(
MockServerWebExchange
.from(MockServerHttpRequest.get("https://api.example.com")),
new WebFilterChain() {

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
return Mono.empty();
}

}).block();
(exchange) -> Mono.empty()).block();
assertThat(this.repository.findAll()).hasSize(1);
}

Expand All @@ -78,14 +69,9 @@ public void filterCapturesSessionIdWhenSessionIsUsed()
this.filter.filter(
MockServerWebExchange
.from(MockServerHttpRequest.get("https://api.example.com")),
new WebFilterChain() {

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
exchange.getSession().block().getAttributes().put("a", "alpha");
return Mono.empty();
}

(exchange) -> {
exchange.getSession().block().getAttributes().put("a", "alpha");
return Mono.empty();
}).block();
assertThat(this.repository.findAll()).hasSize(1);
Session session = this.repository.findAll().get(0).getSession();
Expand All @@ -99,14 +85,9 @@ public void filterDoesNotCaptureIdOfUnusedSession()
this.filter.filter(
MockServerWebExchange
.from(MockServerHttpRequest.get("https://api.example.com")),
new WebFilterChain() {

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
exchange.getSession().block();
return Mono.empty();
}

(exchange) -> {
exchange.getSession().block();
return Mono.empty();
}).block();
assertThat(this.repository.findAll()).hasSize(1);
Session session = this.repository.findAll().get(0).getSession();
Expand All @@ -125,14 +106,9 @@ public Mono<Principal> getPrincipal() {
return Mono.just(principal);
}

}, new WebFilterChain() {

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
exchange.getSession().block().getAttributes().put("a", "alpha");
return Mono.empty();
}

}, (exchange) -> {
exchange.getSession().block().getAttributes().put("a", "alpha");
return Mono.empty();
}).block();
assertThat(this.repository.findAll()).hasSize(1);
org.springframework.boot.actuate.trace.http.HttpTrace.Principal tracedPrincipal = this.repository
Expand All @@ -148,14 +124,7 @@ public void statusIsAssumedToBe500WhenChainFails()
this.filter.filter(
MockServerWebExchange
.from(MockServerHttpRequest.get("https://api.example.com")),
new WebFilterChain() {

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
return Mono.error(new RuntimeException());
}

}).block();
(exchange) -> Mono.error(new RuntimeException())).block();
fail();
}
catch (Exception ex) {
Expand Down
Loading