|
24 | 24 | import static org.junit.jupiter.api.Assertions.assertNull; |
25 | 25 | import static org.junit.jupiter.api.Assumptions.assumeTrue; |
26 | 26 |
|
| 27 | +import java.util.function.Supplier; |
| 28 | + |
27 | 29 | import org.junit.jupiter.api.Test; |
28 | 30 | import org.junit.jupiter.api.function.ThrowingSupplier; |
| 31 | +import org.junitpioneer.jupiter.SetSystemProperty; |
| 32 | +import org.junitpioneer.jupiter.SetSystemProperty.SetSystemProperties; |
29 | 33 |
|
30 | 34 | class SystemPropertiesTest { |
31 | 35 |
|
| 36 | + private static final String STRING_SPACE_1 = " "; |
| 37 | + private static final String STRING_TAB_1 = "\t"; |
| 38 | + |
32 | 39 | private void basicKeyCheck(final String key) { |
33 | 40 | assertNotNull(key); |
34 | 41 | assertFalse(key.isEmpty()); |
@@ -695,6 +702,19 @@ void testGetPathSeparator() { |
695 | 702 | assertNotNull(SystemProperties.getPathSeparator()); |
696 | 703 | } |
697 | 704 |
|
| 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 | + |
698 | 718 | @Test |
699 | 719 | void testGetUserCountry() { |
700 | 720 | assertDoesNotThrow(SystemProperties::getUserCountry); |
|
0 commit comments