Skip to content

Commit dd69d58

Browse files
committed
Add org.apache.commons.lang3.SystemPropertiesTest.testGetPropertyStringSupplier()
1 parent 3ea871d commit dd69d58

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/java/org/apache/commons/lang3/SystemPropertiesTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@
2424
import static org.junit.jupiter.api.Assertions.assertNull;
2525
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2626

27+
import java.util.function.Supplier;
28+
2729
import org.junit.jupiter.api.Test;
2830
import org.junit.jupiter.api.function.ThrowingSupplier;
31+
import org.junitpioneer.jupiter.SetSystemProperty;
32+
import org.junitpioneer.jupiter.SetSystemProperty.SetSystemProperties;
2933

3034
class SystemPropertiesTest {
3135

36+
private static final String STRING_SPACE_1 = " ";
37+
private static final String STRING_TAB_1 = "\t";
38+
3239
private void basicKeyCheck(final String key) {
3340
assertNotNull(key);
3441
assertFalse(key.isEmpty());
@@ -695,6 +702,19 @@ void testGetPathSeparator() {
695702
assertNotNull(SystemProperties.getPathSeparator());
696703
}
697704

705+
@Test
706+
@SetSystemProperties({ @SetSystemProperty(key = STRING_SPACE_1, value = "value1"), @SetSystemProperty(key = STRING_TAB_1, value = "value2") })
707+
void testGetPropertyStringSupplier() {
708+
assertNull(SystemProperties.getProperty(null, (Supplier<String>) null));
709+
assertNull(SystemProperties.getProperty(StringUtils.EMPTY, (Supplier<String>) null));
710+
assertEquals("value1", SystemProperties.getProperty(STRING_SPACE_1, (Supplier<String>) null));
711+
assertEquals("value2", SystemProperties.getProperty("\t", (Supplier<String>) null));
712+
assertEquals("x", SystemProperties.getProperty(null, () -> "x"));
713+
assertEquals("x", SystemProperties.getProperty(StringUtils.EMPTY, () -> "x"));
714+
assertEquals("value1", SystemProperties.getProperty(STRING_SPACE_1, () -> "v"));
715+
assertEquals("value2", SystemProperties.getProperty("\t", () -> "v"));
716+
}
717+
698718
@Test
699719
void testGetUserCountry() {
700720
assertDoesNotThrow(SystemProperties::getUserCountry);

0 commit comments

Comments
 (0)