Skip to content

Commit e617d36

Browse files
committed
Merge branch '3.0.x'
Closes gh-34208
2 parents f387dce + efbeab7 commit e617d36

File tree

11 files changed

+674
-8
lines changed

11 files changed

+674
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.metrics.export.atlas;
18+
19+
import java.time.Duration;
20+
21+
import org.junit.jupiter.api.Test;
22+
23+
import static org.assertj.core.api.Assertions.assertThat;
24+
25+
/**
26+
* Tests for {@link AtlasPropertiesConfigAdapter}.
27+
*
28+
* @author Mirko Sobeck
29+
*/
30+
class AtlasPropertiesConfigAdapterTests {
31+
32+
@Test
33+
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
34+
AtlasProperties properties = new AtlasProperties();
35+
properties.setStep(Duration.ofMinutes(15));
36+
assertThat(new AtlasPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15));
37+
}
38+
39+
@Test
40+
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
41+
AtlasProperties properties = new AtlasProperties();
42+
properties.setEnabled(false);
43+
assertThat(new AtlasPropertiesConfigAdapter(properties).enabled()).isFalse();
44+
}
45+
46+
@Test
47+
void whenPropertiesConnectTimeoutIsSetAdapterConnectTimeoutReturnsIt() {
48+
AtlasProperties properties = new AtlasProperties();
49+
properties.setConnectTimeout(Duration.ofSeconds(12));
50+
assertThat(new AtlasPropertiesConfigAdapter(properties).connectTimeout()).isEqualTo(Duration.ofSeconds(12));
51+
}
52+
53+
@Test
54+
void whenPropertiesReadTimeoutIsSetAdapterReadTimeoutReturnsIt() {
55+
AtlasProperties properties = new AtlasProperties();
56+
properties.setReadTimeout(Duration.ofSeconds(42));
57+
assertThat(new AtlasPropertiesConfigAdapter(properties).readTimeout()).isEqualTo(Duration.ofSeconds(42));
58+
}
59+
60+
@Test
61+
void whenPropertiesNumThreadsIsSetAdapterNumThreadsReturnsIt() {
62+
AtlasProperties properties = new AtlasProperties();
63+
properties.setNumThreads(8);
64+
assertThat(new AtlasPropertiesConfigAdapter(properties).numThreads()).isEqualTo(8);
65+
}
66+
67+
@Test
68+
void whenPropertiesBatchSizeIsSetAdapterBatchSizeReturnsIt() {
69+
AtlasProperties properties = new AtlasProperties();
70+
properties.setBatchSize(10042);
71+
assertThat(new AtlasPropertiesConfigAdapter(properties).batchSize()).isEqualTo(10042);
72+
}
73+
74+
@Test
75+
void whenPropertiesUriIsSetAdapterUriReturnsIt() {
76+
AtlasProperties properties = new AtlasProperties();
77+
properties.setUri("https://atlas.example.com");
78+
assertThat(new AtlasPropertiesConfigAdapter(properties).uri()).isEqualTo("https://atlas.example.com");
79+
}
80+
81+
@Test
82+
void whenPropertiesLwcEnabledIsSetAdapterLwcEnabledReturnsIt() {
83+
AtlasProperties properties = new AtlasProperties();
84+
properties.setLwcEnabled(true);
85+
assertThat(new AtlasPropertiesConfigAdapter(properties).lwcEnabled()).isTrue();
86+
}
87+
88+
@Test
89+
void whenPropertiesConfigRefreshFrequencyIsSetAdapterConfigRefreshFrequencyReturnsIt() {
90+
AtlasProperties properties = new AtlasProperties();
91+
properties.setConfigRefreshFrequency(Duration.ofMinutes(5));
92+
assertThat(new AtlasPropertiesConfigAdapter(properties).configRefreshFrequency())
93+
.isEqualTo(Duration.ofMinutes(5));
94+
}
95+
96+
@Test
97+
void whenPropertiesConfigTimeToLiveIsSetAdapterConfigTTLReturnsIt() {
98+
AtlasProperties properties = new AtlasProperties();
99+
properties.setConfigTimeToLive(Duration.ofMinutes(6));
100+
assertThat(new AtlasPropertiesConfigAdapter(properties).configTTL()).isEqualTo(Duration.ofMinutes(6));
101+
}
102+
103+
@Test
104+
void whenPropertiesConfigUriIsSetAdapterConfigUriReturnsIt() {
105+
AtlasProperties properties = new AtlasProperties();
106+
properties.setConfigUri("https://atlas.example.com/config");
107+
assertThat(new AtlasPropertiesConfigAdapter(properties).configUri())
108+
.isEqualTo("https://atlas.example.com/config");
109+
}
110+
111+
@Test
112+
void whenPropertiesEvalUriIsSetAdapterEvalUriReturnsIt() {
113+
AtlasProperties properties = new AtlasProperties();
114+
properties.setEvalUri("https://atlas.example.com/evaluate");
115+
assertThat(new AtlasPropertiesConfigAdapter(properties).evalUri())
116+
.isEqualTo("https://atlas.example.com/evaluate");
117+
}
118+
119+
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogPropertiesConfigAdapterTests.java

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,22 +18,62 @@
1818

1919
import org.junit.jupiter.api.Test;
2020

21+
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
22+
2123
import static org.assertj.core.api.Assertions.assertThat;
2224

2325
/**
2426
* Tests for {@link DatadogPropertiesConfigAdapter}.
2527
*
2628
* @author Stephane Nicoll
29+
* @author Mirko Sobeck
2730
*/
28-
class DatadogPropertiesConfigAdapterTests {
31+
class DatadogPropertiesConfigAdapterTests
32+
extends StepRegistryPropertiesConfigAdapterTests<DatadogProperties, DatadogPropertiesConfigAdapter> {
33+
34+
@Override
35+
protected DatadogProperties createProperties() {
36+
return new DatadogProperties();
37+
}
38+
39+
@Override
40+
protected DatadogPropertiesConfigAdapter createConfigAdapter(DatadogProperties properties) {
41+
return new DatadogPropertiesConfigAdapter(properties);
42+
}
43+
44+
@Test
45+
void whenPropertiesApiKeyIsSetAdapterApiKeyReturnsIt() {
46+
DatadogProperties properties = createProperties();
47+
properties.setApiKey("my-api-key");
48+
assertThat(createConfigAdapter(properties).apiKey()).isEqualTo("my-api-key");
49+
}
50+
51+
@Test
52+
void whenPropertiesApplicationKeyIsSetAdapterApplicationKeyReturnsIt() {
53+
DatadogProperties properties = createProperties();
54+
properties.setApplicationKey("my-application-key");
55+
assertThat(createConfigAdapter(properties).applicationKey()).isEqualTo("my-application-key");
56+
}
57+
58+
@Test
59+
void whenPropertiesDescriptionsIsSetAdapterDescriptionsReturnsIt() {
60+
DatadogProperties properties = createProperties();
61+
properties.setDescriptions(false);
62+
assertThat(createConfigAdapter(properties).descriptions()).isEqualTo(false);
63+
}
64+
65+
@Test
66+
void whenPropertiesHostTagIsSetAdapterHostTagReturnsIt() {
67+
DatadogProperties properties = createProperties();
68+
properties.setHostTag("waldo");
69+
assertThat(createConfigAdapter(properties).hostTag()).isEqualTo("waldo");
70+
}
2971

3072
@Test
31-
void uriCanBeSet() {
32-
DatadogProperties properties = new DatadogProperties();
73+
void whenPropertiesUriIsSetAdapterUriReturnsIt() {
74+
DatadogProperties properties = createProperties();
3375
properties.setUri("https://app.example.com/api/v1/series");
34-
properties.setApiKey("my-key");
35-
assertThat(new DatadogPropertiesConfigAdapter(properties).uri())
36-
.isEqualTo("https://app.example.com/api/v1/series");
76+
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://app.example.com/api/v1/series");
3777
}
3878

3979
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,8 @@ void defaultValuesAreConsistent() {
3636
DynatraceConfig config = (key) -> null;
3737
assertStepRegistryDefaultValues(properties, config);
3838
assertThat(properties.getV1().getTechnologyType()).isEqualTo(config.technologyType());
39+
assertThat(properties.getV2().isUseDynatraceSummaryInstruments())
40+
.isEqualTo(config.useDynatraceSummaryInstruments());
3941
}
4042

4143
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.metrics.export.ganglia;
18+
19+
import java.time.Duration;
20+
import java.util.concurrent.TimeUnit;
21+
22+
import info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode;
23+
import org.junit.jupiter.api.Test;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Tests for {@link GangliaPropertiesConfigAdapter}.
29+
*
30+
* @author Mirko Sobeck
31+
*/
32+
class GangliaPropertiesConfigAdapterTests {
33+
34+
@Test
35+
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
36+
GangliaProperties properties = new GangliaProperties();
37+
properties.setEnabled(false);
38+
assertThat(new GangliaPropertiesConfigAdapter(properties).enabled()).isFalse();
39+
}
40+
41+
@Test
42+
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
43+
GangliaProperties properties = new GangliaProperties();
44+
properties.setStep(Duration.ofMinutes(15));
45+
assertThat(new GangliaPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15));
46+
}
47+
48+
@Test
49+
void whenPropertiesDurationUnitsIsSetAdapterDurationUnitsReturnsIt() {
50+
GangliaProperties properties = new GangliaProperties();
51+
properties.setDurationUnits(TimeUnit.MINUTES);
52+
assertThat(new GangliaPropertiesConfigAdapter(properties).durationUnits()).isEqualTo(TimeUnit.MINUTES);
53+
}
54+
55+
@Test
56+
void whenPropertiesAddressingModeIsSetAdapterAddressingModeReturnsIt() {
57+
GangliaProperties properties = new GangliaProperties();
58+
properties.setAddressingMode(UDPAddressingMode.UNICAST);
59+
assertThat(new GangliaPropertiesConfigAdapter(properties).addressingMode())
60+
.isEqualTo(UDPAddressingMode.UNICAST);
61+
}
62+
63+
@Test
64+
void whenPropertiesTimeToLiveIsSetAdapterTtlReturnsIt() {
65+
GangliaProperties properties = new GangliaProperties();
66+
properties.setTimeToLive(2);
67+
assertThat(new GangliaPropertiesConfigAdapter(properties).ttl()).isEqualTo(2);
68+
}
69+
70+
@Test
71+
void whenPropertiesHostIsSetAdapterHostReturnsIt() {
72+
GangliaProperties properties = new GangliaProperties();
73+
properties.setHost("node");
74+
assertThat(new GangliaPropertiesConfigAdapter(properties).host()).isEqualTo("node");
75+
}
76+
77+
@Test
78+
void whenPropertiesPortIsSetAdapterPortReturnsIt() {
79+
GangliaProperties properties = new GangliaProperties();
80+
properties.setPort(4242);
81+
assertThat(new GangliaPropertiesConfigAdapter(properties).port()).isEqualTo(4242);
82+
}
83+
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.metrics.export.graphite;
18+
19+
import java.time.Duration;
20+
import java.util.concurrent.TimeUnit;
21+
22+
import io.micrometer.graphite.GraphiteProtocol;
23+
import org.junit.jupiter.api.Test;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Tests for {@link GraphitePropertiesConfigAdapter}.
29+
*
30+
* @author Mirko Sobeck
31+
*/
32+
class GraphitePropertiesConfigAdapterTests {
33+
34+
@Test
35+
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
36+
GraphiteProperties properties = new GraphiteProperties();
37+
properties.setEnabled(false);
38+
assertThat(new GraphitePropertiesConfigAdapter(properties).enabled()).isFalse();
39+
}
40+
41+
@Test
42+
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
43+
GraphiteProperties properties = new GraphiteProperties();
44+
properties.setStep(Duration.ofMinutes(15));
45+
assertThat(new GraphitePropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15));
46+
}
47+
48+
@Test
49+
void whenPropertiesRateUnitsIsSetAdapterRateUnitsReturnsIt() {
50+
GraphiteProperties properties = new GraphiteProperties();
51+
properties.setRateUnits(TimeUnit.MINUTES);
52+
assertThat(new GraphitePropertiesConfigAdapter(properties).rateUnits()).isEqualTo(TimeUnit.MINUTES);
53+
}
54+
55+
@Test
56+
void whenPropertiesDurationUnitsIsSetAdapterDurationUnitsReturnsIt() {
57+
GraphiteProperties properties = new GraphiteProperties();
58+
properties.setRateUnits(TimeUnit.MINUTES);
59+
assertThat(new GraphitePropertiesConfigAdapter(properties).rateUnits()).isEqualTo(TimeUnit.MINUTES);
60+
}
61+
62+
@Test
63+
void whenPropertiesHostIsSetAdapterHostReturnsIt() {
64+
GraphiteProperties properties = new GraphiteProperties();
65+
properties.setHost("node");
66+
assertThat(new GraphitePropertiesConfigAdapter(properties).host()).isEqualTo("node");
67+
}
68+
69+
@Test
70+
void whenPropertiesPortIsSetAdapterPortReturnsIt() {
71+
GraphiteProperties properties = new GraphiteProperties();
72+
properties.setPort(4242);
73+
assertThat(new GraphitePropertiesConfigAdapter(properties).port()).isEqualTo(4242);
74+
}
75+
76+
@Test
77+
void whenPropertiesProtocolIsSetAdapterProtocolReturnsIt() {
78+
GraphiteProperties properties = new GraphiteProperties();
79+
properties.setProtocol(GraphiteProtocol.UDP);
80+
assertThat(new GraphitePropertiesConfigAdapter(properties).protocol()).isEqualTo(GraphiteProtocol.UDP);
81+
}
82+
83+
@Test
84+
void whenPropertiesGraphiteTagsEnabledIsSetAdapterGraphiteTagsEnabledReturnsIt() {
85+
GraphiteProperties properties = new GraphiteProperties();
86+
properties.setGraphiteTagsEnabled(true);
87+
assertThat(new GraphitePropertiesConfigAdapter(properties).graphiteTagsEnabled()).isTrue();
88+
}
89+
90+
@Test
91+
void whenPropertiesTagsAsPrefixIsSetAdapterTagsAsPrefixReturnsIt() {
92+
GraphiteProperties properties = new GraphiteProperties();
93+
properties.setTagsAsPrefix(new String[] { "worker" });
94+
assertThat(new GraphitePropertiesConfigAdapter(properties).tagsAsPrefix()).isEqualTo(new String[] { "worker" });
95+
}
96+
97+
}

0 commit comments

Comments
 (0)