Skip to content

Commit 407d411

Browse files
committed
Add more tests to OpenTelemetryResourceAttributesTests
Signed-off-by: Dmytro Nosan <[email protected]>
1 parent faef7d5 commit 407d411

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryResourceAttributesTests.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,21 @@ void otelResourceAttributeValuesShouldBePercentDecoded() {
117117
.containsEntry("key", value);
118118
}
119119

120+
@Test
121+
void otelResourceAttributeValuesShouldBePercentDecodedWhenStringContainsNonAscii() {
122+
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES",
123+
"key=T%C5%8Dky%C5%8D,key1=%20\u015bp\u0159\u00ec\u0144\u0121%20");
124+
assertThat(getAttributes()).hasSize(3)
125+
.containsEntry("service.name", "unknown_service")
126+
.containsEntry("key", "Tōkyō")
127+
.containsEntry("key1", " śpřìńġ ");
128+
}
129+
120130
@Test
121131
void illegalArgumentExceptionShouldBeThrownWhenDecodingIllegalHexCharPercentEncodedValue() {
122132
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=abc%ß");
123133
assertThatIllegalArgumentException().isThrownBy(this::getAttributes)
124-
.withMessage("Failed to decode percent-encoded characters at index 3 in the value: 'abc%ß'");
134+
.withMessage("Invalid encoded sequence \"\"");
125135
}
126136

127137
@Test
@@ -134,7 +144,7 @@ void replacementCharShouldBeUsedWhenDecodingNonUtf8Character() {
134144
void illegalArgumentExceptionShouldBeThrownWhenDecodingInvalidPercentEncodedValue() {
135145
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=%");
136146
assertThatIllegalArgumentException().isThrownBy(this::getAttributes)
137-
.withMessage("Failed to decode percent-encoded characters at index 0 in the value: '%'");
147+
.withMessage("Invalid encoded sequence \"%\"");
138148
}
139149

140150
@Test

0 commit comments

Comments
 (0)