Skip to content
Open
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 @@ -22,6 +22,7 @@
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
Expand Down Expand Up @@ -231,7 +232,7 @@ private String getConfigurable(
@Nullable final String defaultValue,
Properties... propertiesSources
) {
String envVarName = propertyName.replaceAll("\\.", "_").toUpperCase();
String envVarName = propertyName.replaceAll("\\.", "_").toUpperCase(Locale.ROOT);
if (!envVarName.startsWith("TESTCONTAINERS_") && !envVarName.startsWith("DOCKER_")) {
envVarName = "TESTCONTAINERS_" + envVarName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
Expand Down Expand Up @@ -225,6 +226,24 @@ void shouldTrimImageNames() {
.isEqualTo("testcontainers/ryuk:0.3.2");
}

@Test
void shouldReadEnvVarRegardlessOfDefaultLocale() {
// Property names such as "image.substitutor" contain the letter 'i', which
// upper-cases to a dotted capital 'İ' (U+0130) under the Turkish locale. The
// derived environment variable name must not depend on the JVM default locale,
// otherwise the lookup silently fails and the environment variable is ignored.
Locale previousDefault = Locale.getDefault();
try {
Locale.setDefault(new Locale("tr", "TR"));
environment.put("TESTCONTAINERS_IMAGE_SUBSTITUTOR", "com.example.MySubstitutor");
assertThat(newConfig().getImageSubstitutorClassName())
.as("environment variables are resolved independently of the default locale")
.isEqualTo("com.example.MySubstitutor");
} finally {
Locale.setDefault(previousDefault);
}
}

private TestcontainersConfiguration newConfig() {
return new TestcontainersConfiguration(userProperties, classpathProperties, environment);
}
Expand Down