mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Test Micrometer config to property exposure
See gh-33743
This commit is contained in:
parent
637e190e76
commit
19e70055a5
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to test that all Micrometer config values are exposed via properties and
|
||||||
|
* settable using the corresponding {@link PropertiesConfigAdapter} implementation.
|
||||||
|
*
|
||||||
|
* @author Mirko Sobeck
|
||||||
|
*/
|
||||||
|
public final class TestConfigsToPropertiesExposure {
|
||||||
|
|
||||||
|
private TestConfigsToPropertiesExposure() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final List<Class<?>> classesForPropertiesList = Arrays.asList(Boolean.class, Byte.class,
|
||||||
|
Character.class, Short.class, Integer.class, Long.class, Double.class, Float.class, String.class,
|
||||||
|
Duration.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assertion to test if default methods of a given config are overridden by the
|
||||||
|
* adapter which implements it. This can be an indicator for micrometer config fields,
|
||||||
|
* that have been forgotten to expose via spring properties. Not overridden default
|
||||||
|
* methods in adapters are the most common cause of forgotten field exposure, because
|
||||||
|
* they do not for force an override.
|
||||||
|
* @param config micrometer config
|
||||||
|
* @param adapter adapter for properties {@link PropertiesConfigAdapter}
|
||||||
|
* @param excludedConfigMethods config methods that should be excluded for the
|
||||||
|
* assertion
|
||||||
|
*/
|
||||||
|
public static void assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(Class<?> config,
|
||||||
|
Class<? extends PropertiesConfigAdapter<?>> adapter, String... excludedConfigMethods) {
|
||||||
|
List<String> configDefaultMethodNames = Arrays.stream(config.getDeclaredMethods())
|
||||||
|
.filter((method) -> method.isDefault() && isSettableUsingProperties(method.getReturnType()))
|
||||||
|
.map(Method::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
configDefaultMethodNames.removeAll(Arrays.stream(excludedConfigMethods).collect(Collectors.toList()));
|
||||||
|
List<String> notOverriddenDefaultMethods = new ArrayList<>(configDefaultMethodNames);
|
||||||
|
|
||||||
|
Class<?> currentClass = adapter;
|
||||||
|
// loop through adapter class and superclasses
|
||||||
|
// to find not overridden config methods
|
||||||
|
while (!Object.class.equals(currentClass)) {
|
||||||
|
List<String> overriddenClassDefaultMethods = Arrays.stream(currentClass.getDeclaredMethods())
|
||||||
|
.map(Method::getName).filter(configDefaultMethodNames::contains).collect(Collectors.toList());
|
||||||
|
|
||||||
|
notOverriddenDefaultMethods.removeAll(overriddenClassDefaultMethods);
|
||||||
|
currentClass = currentClass.getSuperclass();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notOverriddenDefaultMethods.size() >= 1) {
|
||||||
|
Assert.fail(
|
||||||
|
"Found config default methods that are not overridden by the related PropertiesConfigAdapter: \n"
|
||||||
|
+ notOverriddenDefaultMethods + "\n"
|
||||||
|
+ "This could be an indicator for not exposed properties fields.\n"
|
||||||
|
+ "Please check if the fields are meant to be exposed and if not, "
|
||||||
|
+ "exclude them from this test by providing them to the method.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guess if a class can be set using properties. This will only catch the basic use
|
||||||
|
* cases regarding the micrometer configs to filter out methods that are not likely to
|
||||||
|
* be designed to be set via properties. <pre>
|
||||||
|
* isSettableUsingProperties(String.class) = true
|
||||||
|
* isSettableUsingProperties(boolean.class) = true
|
||||||
|
* isSettableUsingProperties(Object.class) = false
|
||||||
|
* </pre>
|
||||||
|
* @param clazz Class
|
||||||
|
* @return is likely to be settable using properties
|
||||||
|
*/
|
||||||
|
private static boolean isSettableUsingProperties(Class<?> clazz) {
|
||||||
|
if (Void.TYPE.equals(clazz)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clazz.isPrimitive()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return classesForPropertiesList.contains(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2023 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.
|
||||||
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.appoptics;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.appoptics;
|
||||||
|
|
||||||
|
import io.micrometer.appoptics.AppOpticsConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -68,4 +70,10 @@ class AppOpticsPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).floorTimes()).isTrue();
|
assertThat(createConfigAdapter(properties).floorTimes()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allDefaultConfigMethodsAreOverriddenByAtlasPropertiesConfigAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(AppOpticsConfig.class,
|
||||||
|
AppOpticsPropertiesConfigAdapter.class, "connectTimeout");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.atlas;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import com.netflix.spectator.atlas.AtlasConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,4 +133,11 @@ class AtlasPropertiesConfigAdapterTests {
|
|||||||
assertThat(new AtlasPropertiesConfigAdapter(properties).lwcIgnorePublishStep()).isFalse();
|
assertThat(new AtlasPropertiesConfigAdapter(properties).lwcIgnorePublishStep()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(AtlasConfig.class,
|
||||||
|
AtlasPropertiesConfigAdapter.class, "lwcIgnorePublishStep", "initialPollingDelay", "autoStart",
|
||||||
|
"lwcStep", "validTagCharacters");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog;
|
||||||
|
|
||||||
|
import io.micrometer.datadog.DatadogConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -76,4 +78,10 @@ class DatadogPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://app.example.com/api/v1/series");
|
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://app.example.com/api/v1/series");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(DatadogConfig.class,
|
||||||
|
DatadogPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.dynatrace;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import io.micrometer.dynatrace.DynatraceApiVersion;
|
import io.micrometer.dynatrace.DynatraceApiVersion;
|
||||||
|
import io.micrometer.dynatrace.DynatraceConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,4 +164,10 @@ class DynatracePropertiesConfigAdapterTests {
|
|||||||
assertThat(properties.getGroup()).isNull();
|
assertThat(properties.getGroup()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(DynatraceConfig.class,
|
||||||
|
DynatracePropertiesConfigAdapter.class, "documentType");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2023 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.
|
||||||
@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.elastic;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.elastic;
|
||||||
|
|
||||||
|
import io.micrometer.elastic.ElasticConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,4 +100,10 @@ class ElasticPropertiesConfigAdapterTests {
|
|||||||
assertThat(new ElasticPropertiesConfigAdapter(properties).apiKeyCredentials()).isEqualTo("secret");
|
assertThat(new ElasticPropertiesConfigAdapter(properties).apiKeyCredentials()).isEqualTo("secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(ElasticConfig.class,
|
||||||
|
ElasticPropertiesConfigAdapter.class, "documentType");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,11 @@ import java.time.Duration;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode;
|
import info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode;
|
||||||
|
import io.micrometer.ganglia.GangliaConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,4 +84,10 @@ class GangliaPropertiesConfigAdapterTests {
|
|||||||
assertThat(new GangliaPropertiesConfigAdapter(properties).port()).isEqualTo(4242);
|
assertThat(new GangliaPropertiesConfigAdapter(properties).port()).isEqualTo(4242);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(GangliaConfig.class,
|
||||||
|
GangliaPropertiesConfigAdapter.class, "protocolVersion");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,12 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.graphite;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import io.micrometer.graphite.GraphiteConfig;
|
||||||
import io.micrometer.graphite.GraphiteProtocol;
|
import io.micrometer.graphite.GraphiteProtocol;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,4 +97,10 @@ class GraphitePropertiesConfigAdapterTests {
|
|||||||
assertThat(new GraphitePropertiesConfigAdapter(properties).tagsAsPrefix()).isEqualTo(new String[] { "worker" });
|
assertThat(new GraphitePropertiesConfigAdapter(properties).tagsAsPrefix()).isEqualTo(new String[] { "worker" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(GraphiteConfig.class,
|
||||||
|
GraphitePropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.humio;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import io.micrometer.humio.HumioConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,4 +54,10 @@ class HumioPropertiesConfigAdapterTests {
|
|||||||
assertThat(new HumioPropertiesConfigAdapter(properties).uri()).isEqualTo("https://humio.example.com");
|
assertThat(new HumioPropertiesConfigAdapter(properties).uri()).isEqualTo("https://humio.example.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(HumioConfig.class,
|
||||||
|
HumioPropertiesConfigAdapter.class, "connectTimeout");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,11 @@
|
|||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
||||||
|
|
||||||
import io.micrometer.influx.InfluxApiVersion;
|
import io.micrometer.influx.InfluxApiVersion;
|
||||||
|
import io.micrometer.influx.InfluxConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,4 +61,10 @@ class InfluxPropertiesConfigAdapterTests {
|
|||||||
assertThat(adapter.token()).isEqualTo("token");
|
assertThat(adapter.token()).isEqualTo("token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(InfluxConfig.class,
|
||||||
|
InfluxPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.jmx;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import io.micrometer.jmx.JmxConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,4 +46,10 @@ class JmxPropertiesConfigAdapterTests {
|
|||||||
assertThat(new JmxPropertiesConfigAdapter(properties).domain()).isEqualTo("abc");
|
assertThat(new JmxPropertiesConfigAdapter(properties).domain()).isEqualTo("abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(JmxConfig.class,
|
||||||
|
JmxPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.kairos;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.kairos;
|
||||||
|
|
||||||
|
import io.micrometer.kairos.KairosConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -62,4 +64,10 @@ class KairosPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).password()).isEqualTo("secret");
|
assertThat(createConfigAdapter(properties).password()).isEqualTo("secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(KairosConfig.class,
|
||||||
|
KairosPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic;
|
||||||
|
|
||||||
import io.micrometer.newrelic.ClientProviderType;
|
import io.micrometer.newrelic.ClientProviderType;
|
||||||
|
import io.micrometer.newrelic.NewRelicConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -83,4 +85,10 @@ class NewRelicPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://example.newrelic.com");
|
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://example.newrelic.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(NewRelicConfig.class,
|
||||||
|
NewRelicPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.prometheus.HistogramFlavor;
|
import io.micrometer.prometheus.HistogramFlavor;
|
||||||
|
import io.micrometer.prometheus.PrometheusConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,4 +55,10 @@ class PrometheusPropertiesConfigAdapterTests {
|
|||||||
assertThat(new PrometheusPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofSeconds(30));
|
assertThat(new PrometheusPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofSeconds(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(PrometheusConfig.class,
|
||||||
|
PrometheusPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx;
|
||||||
|
|
||||||
|
import io.micrometer.signalfx.SignalFxConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxProperties.HistogramType;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxProperties.HistogramType;
|
||||||
|
|
||||||
@ -68,6 +70,11 @@ class SignalFxPropertiesConfigAdapterTests
|
|||||||
SignalFxProperties properties = createProperties();
|
SignalFxProperties properties = createProperties();
|
||||||
properties.setPublishedHistogramType(HistogramType.CUMULATIVE);
|
properties.setPublishedHistogramType(HistogramType.CUMULATIVE);
|
||||||
assertThat(createConfigAdapter(properties).publishCumulativeHistogram()).isTrue();
|
assertThat(createConfigAdapter(properties).publishCumulativeHistogram()).isTrue();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(SignalFxConfig.class,
|
||||||
|
SignalFxPropertiesConfigAdapter.class, "publishDeltaHistogram", "publishCumulativeHistogram");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.simple;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.core.instrument.simple.CountingMode;
|
import io.micrometer.core.instrument.simple.CountingMode;
|
||||||
|
import io.micrometer.core.instrument.simple.SimpleConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,4 +47,10 @@ class SimplePropertiesConfigAdapterTests {
|
|||||||
assertThat(new SimplePropertiesConfigAdapter(properties).mode()).isEqualTo(CountingMode.STEP);
|
assertThat(new SimplePropertiesConfigAdapter(properties).mode()).isEqualTo(CountingMode.STEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(SimpleConfig.class,
|
||||||
|
SimplePropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.stackdrive
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.micrometer.stackdriver.StackdriverConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,4 +65,10 @@ class StackdriverPropertiesConfigAdapterTests {
|
|||||||
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue();
|
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(StackdriverConfig.class,
|
||||||
|
StackdriverPropertiesConfigAdapter.class, "metricTypePrefix");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,13 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.statsd;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import io.micrometer.statsd.StatsdConfig;
|
||||||
import io.micrometer.statsd.StatsdFlavor;
|
import io.micrometer.statsd.StatsdFlavor;
|
||||||
import io.micrometer.statsd.StatsdProtocol;
|
import io.micrometer.statsd.StatsdProtocol;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,4 +107,10 @@ class StatsdPropertiesConfigAdapterTests {
|
|||||||
assertThat(new StatsdPropertiesConfigAdapter(properties).buffered()).isEqualTo(properties.isBuffered());
|
assertThat(new StatsdPropertiesConfigAdapter(properties).buffered()).isEqualTo(properties.isBuffered());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(StatsdConfig.class,
|
||||||
|
StatsdPropertiesConfigAdapter.class, "queueSize");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,10 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import io.micrometer.wavefront.WavefrontConfig;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PushRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PushRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -91,4 +93,11 @@ class WavefrontPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).reportDayDistribution()).isTrue();
|
assertThat(createConfigAdapter(properties).reportDayDistribution()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
||||||
|
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(WavefrontConfig.class,
|
||||||
|
WavefrontPropertiesConfigAdapter.class, "distributionPort", "reportMinuteDistribution",
|
||||||
|
"reportHourDistribution", "reportDayDistribution");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user