View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.lang3;
19  
20  import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
21  import static org.junit.jupiter.api.Assertions.assertEquals;
22  import static org.junit.jupiter.api.Assertions.assertFalse;
23  import static org.junit.jupiter.api.Assertions.assertNotNull;
24  import static org.junit.jupiter.api.Assertions.assertNull;
25  import static org.junit.jupiter.api.Assertions.assertTrue;
26  import static org.junit.jupiter.api.Assumptions.assumeTrue;
27  
28  import java.nio.file.Paths;
29  import java.util.function.Supplier;
30  
31  import org.junit.jupiter.api.Test;
32  import org.junit.jupiter.api.function.ThrowingSupplier;
33  import org.junit.jupiter.params.ParameterizedTest;
34  import org.junit.jupiter.params.provider.ValueSource;
35  import org.junitpioneer.jupiter.SetSystemProperty;
36  import org.junitpioneer.jupiter.SetSystemProperty.SetSystemProperties;
37  
38  @SetSystemProperties({
39      @SetSystemProperty(key = SystemPropertiesTest.KEY_SPACE_1, value = "value1"),
40      @SetSystemProperty(key = SystemPropertiesTest.KEY_TAB_1, value = "value2") })
41  class SystemPropertiesTest {
42  
43      private static final String SIMPLE_NAME = SystemPropertiesTest.class.getSimpleName();
44      static final String KEY_SPACE_1 = " ";
45      static final String KEY_TAB_1 = "\t";
46  
47      private void basicKeyCheck(final String key) {
48          assertNotNull(key);
49          assertFalse(key.isEmpty());
50          assertDoesNotThrow(() -> System.getProperties().get(key));
51          assertDoesNotThrow(() -> System.getProperty(key));
52          assertDoesNotThrow(() -> System.getProperty(key, ""));
53  // Debug/Info
54  //        if (!System.getProperties().containsKey(key)) {
55  //            System.out.printf("No key '%s'%n", key);
56  //        } else if (System.getProperty(key) == null) {
57  //            System.out.printf("Null value at key '%s'%n", key);
58  //        }
59      }
60  
61      private boolean isJava11OrGreater() {
62          return SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_11);
63      }
64  
65      @Test
66      void testActualKeys() {
67          basicKeyCheck(SystemProperties.APPLE_AWT_ENABLE_TEMPLATE_IMAGES);
68          basicKeyCheck(SystemProperties.AWT_TOOLKIT);
69          basicKeyCheck(SystemProperties.COM_SUN_JNDI_LDAP_OBJECT_TRUST_SERIAL_DATA);
70          basicKeyCheck(SystemProperties.COM_SUN_NET_HTTP_SERVER_HTTP_SERVER_PROVIDER);
71          basicKeyCheck(SystemProperties.FILE_ENCODING);
72          basicKeyCheck(SystemProperties.FILE_SEPARATOR);
73          basicKeyCheck(SystemProperties.FTP_NON_PROXY_HOST);
74          basicKeyCheck(SystemProperties.FTP_PROXY_HOST);
75          basicKeyCheck(SystemProperties.FTP_PROXY_PORT);
76          basicKeyCheck(SystemProperties.HTTP_AGENT);
77          basicKeyCheck(SystemProperties.HTTP_AUTH_DIGEST_CNONCE_REPEAT);
78          basicKeyCheck(SystemProperties.HTTP_AUTH_DIGEST_RE_ENABLED_ALGORITHMS);
79          basicKeyCheck(SystemProperties.HTTP_AUTH_DIGEST_VALIDATE_PROXY);
80          basicKeyCheck(SystemProperties.HTTP_AUTH_DIGEST_VALIDATE_SERVER);
81          basicKeyCheck(SystemProperties.HTTP_AUTH_NTLM_DOMAIN);
82          basicKeyCheck(SystemProperties.HTTP_KEEP_ALIVE);
83          basicKeyCheck(SystemProperties.HTTP_KEEP_ALIVE_TIME_PROXY);
84          basicKeyCheck(SystemProperties.HTTP_KEEP_ALIVE_TIME_SERVER);
85          basicKeyCheck(SystemProperties.HTTP_MAX_CONNECTIONS);
86          basicKeyCheck(SystemProperties.HTTP_MAX_REDIRECTS);
87          basicKeyCheck(SystemProperties.HTTP_NON_PROXY_HOSTS);
88          basicKeyCheck(SystemProperties.HTTP_PROXY_HOST);
89          basicKeyCheck(SystemProperties.HTTP_PROXY_PORT);
90          basicKeyCheck(SystemProperties.HTTPS_PROXY_HOST);
91          basicKeyCheck(SystemProperties.HTTPS_PROXY_PORT);
92          basicKeyCheck(SystemProperties.JAVA_AWT_FONTS);
93          basicKeyCheck(SystemProperties.JAVA_AWT_GRAPHICSENV);
94          basicKeyCheck(SystemProperties.JAVA_AWT_HEADLESS);
95          basicKeyCheck(SystemProperties.JAVA_AWT_PRINTERJOB);
96          basicKeyCheck(SystemProperties.JAVA_CLASS_PATH);
97          basicKeyCheck(SystemProperties.JAVA_CLASS_VERSION);
98          basicKeyCheck(SystemProperties.JAVA_COMPILER);
99          basicKeyCheck(SystemProperties.JAVA_CONTENT_HANDLER_PKGS);
100         basicKeyCheck(SystemProperties.JAVA_ENDORSED_DIRS);
101         basicKeyCheck(SystemProperties.JAVA_EXT_DIRS);
102         basicKeyCheck(SystemProperties.JAVA_HOME);
103         basicKeyCheck(SystemProperties.JAVA_IO_TMPDIR);
104         basicKeyCheck(SystemProperties.JAVA_LIBRARY_PATH);
105         basicKeyCheck(SystemProperties.JAVA_LOCALE_PROVIDERS);
106         basicKeyCheck(SystemProperties.JAVA_LOCALE_USE_OLD_ISO_CODES);
107         basicKeyCheck(SystemProperties.JAVA_NET_PREFER_IPV4_STACK);
108         basicKeyCheck(SystemProperties.JAVA_NET_PREFER_IPV6_ADDRESSES);
109         basicKeyCheck(SystemProperties.JAVA_NET_SOCKS_PASSWORD);
110         basicKeyCheck(SystemProperties.JAVA_NET_SOCKS_USER_NAME);
111         basicKeyCheck(SystemProperties.JAVA_NET_USE_SYSTEM_PROXIES);
112         basicKeyCheck(SystemProperties.JAVA_NIO_CHANNELS_DEFAULT_THREAD_POOL_INITIAL_SIZE);
113         basicKeyCheck(SystemProperties.JAVA_NIO_CHANNELS_DEFAULT_THREAD_POOL_THREAD_FACTORY);
114         basicKeyCheck(SystemProperties.JAVA_NIO_CHANNELS_SPI_ASYNCHRONOUS_CHANNEL_PROVIDER);
115         basicKeyCheck(SystemProperties.JAVA_NIO_CHANNELS_SPI_SELECTOR_PROVIDER);
116         basicKeyCheck(SystemProperties.JAVA_NIO_FILE_SPI_DEFAULT_FILE_SYSTEM_PROVIDER);
117         basicKeyCheck(SystemProperties.JAVA_PROPERTIES_DATE);
118         basicKeyCheck(SystemProperties.JAVA_PROTOCOL_HANDLER_PKGS);
119         basicKeyCheck(SystemProperties.JAVA_RMI_SERVER_CODEBASE);
120         basicKeyCheck(SystemProperties.JAVA_RMI_SERVER_HOST_NAME);
121         basicKeyCheck(SystemProperties.JAVA_RMI_SERVER_RANDOM_IDS);
122         basicKeyCheck(SystemProperties.JAVA_RMI_SERVER_RMI_CLASS_LOADER_SPI);
123         basicKeyCheck(SystemProperties.JAVA_RUNTIME_NAME);
124         basicKeyCheck(SystemProperties.JAVA_RUNTIME_VERSION);
125         basicKeyCheck(SystemProperties.JAVA_SECURITY_AUTH_LOGIN_CONFIG);
126         basicKeyCheck(SystemProperties.JAVA_SECURITY_KERBEROS_CONF);
127         basicKeyCheck(SystemProperties.JAVA_SECURITY_KERBEROS_KDC);
128         basicKeyCheck(SystemProperties.JAVA_SECURITY_KERBEROS_REALM);
129         basicKeyCheck(SystemProperties.JAVA_SECURITY_DEBUG);
130         basicKeyCheck(SystemProperties.JAVA_SECURITY_MANAGER);
131         basicKeyCheck(SystemProperties.JAVA_SPECIFICATION_MAINTENANCE_VERSION);
132         basicKeyCheck(SystemProperties.JAVA_SPECIFICATION_NAME);
133         basicKeyCheck(SystemProperties.JAVA_SPECIFICATION_VENDOR);
134         basicKeyCheck(SystemProperties.JAVA_SPECIFICATION_VERSION);
135         basicKeyCheck(SystemProperties.JAVA_SYSTEM_CLASS_LOADER);
136         basicKeyCheck(SystemProperties.JAVA_TIME_ZONE_DEFAULT_ZONE_RULES_PROVIDER);
137         basicKeyCheck(SystemProperties.JAVA_UTIL_CONCURRENT_FORK_JOIN_POOL_COMMON_EXCEPTION_HANDLER);
138         basicKeyCheck(SystemProperties.JAVA_UTIL_CONCURRENT_FORK_JOIN_POOL_COMMON_MAXIMUM_SPARES);
139         basicKeyCheck(SystemProperties.JAVA_UTIL_CONCURRENT_FORK_JOIN_POOL_COMMON_PARALLELISM);
140         basicKeyCheck(SystemProperties.JAVA_UTIL_CONCURRENT_FORK_JOIN_POOL_COMMON_THREAD_FACTORY);
141         basicKeyCheck(SystemProperties.JAVA_UTIL_CURRENCY_DATA);
142         basicKeyCheck(SystemProperties.JAVA_UTIL_LOGGING_CONFIG_CLASS);
143         basicKeyCheck(SystemProperties.JAVA_UTIL_LOGGING_CONFIG_FILE);
144         basicKeyCheck(SystemProperties.JAVA_UTIL_LOGGING_SIMPLE_FORMATTER_FORMAT);
145         basicKeyCheck(SystemProperties.JAVA_UTIL_PREFS_PREFERENCES_FACTORY);
146         basicKeyCheck(SystemProperties.JAVA_UTIL_PROPERTY_RESOURCE_BUNDLE_ENCODING);
147         basicKeyCheck(SystemProperties.JAVA_VENDOR);
148         basicKeyCheck(SystemProperties.JAVA_VENDOR_URL);
149         basicKeyCheck(SystemProperties.JAVA_VENDOR_VERSION);
150         basicKeyCheck(SystemProperties.JAVA_VERSION);
151         basicKeyCheck(SystemProperties.JAVA_VERSION_DATE);
152         basicKeyCheck(SystemProperties.JAVA_VM_INFO);
153         basicKeyCheck(SystemProperties.JAVA_VM_NAME);
154         basicKeyCheck(SystemProperties.JAVA_VM_SPECIFICATION_NAME);
155         basicKeyCheck(SystemProperties.JAVA_VM_SPECIFICATION_VENDOR);
156         basicKeyCheck(SystemProperties.JAVA_VM_SPECIFICATION_VERSION);
157         basicKeyCheck(SystemProperties.JAVA_VM_VENDOR);
158         basicKeyCheck(SystemProperties.JAVA_VM_VERSION);
159         basicKeyCheck(SystemProperties.JAVA_XML_CONFIG_FILE);
160         basicKeyCheck(SystemProperties.JAVAX_ACCESSIBILITY_ASSISTIVE_TECHNOLOGIES);
161         basicKeyCheck(SystemProperties.JAVAX_NET_SSL_SESSION_CACHE_SIZE);
162         basicKeyCheck(SystemProperties.JAVAX_RMI_SSL_CLIENT_ENABLED_CIPHER_SUITES);
163         basicKeyCheck(SystemProperties.JAVAX_RMI_SSL_CLIENT_ENABLED_PROTOCOLS);
164         basicKeyCheck(SystemProperties.JAVAX_SECURITY_AUTH_USE_SUBJECT_CREDS_ONLY);
165         basicKeyCheck(SystemProperties.JAVAX_SMART_CARD_IO_TERMINAL_FACTORY_DEFAULT_TYPE);
166         basicKeyCheck(SystemProperties.JDBC_DRIVERS);
167         basicKeyCheck(SystemProperties.JDK_HTTP_AUTH_PROXYING_DISABLED_SCHEMES);
168         basicKeyCheck(SystemProperties.JDK_HTTP_AUTH_TUNNELING_DISABLED_SCHEMES);
169         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_ALLOW_RESTRICTED_HEADERS);
170         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_AUTH_RETRY_LIMIT);
171         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_BUF_SIZE);
172         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_CONNECTION_POOL_SIZE);
173         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_CONNECTION_WINDOW_SIZE);
174         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_DISABLE_RETRY_CONNECT);
175         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_ENABLE_ALL_METHOD_RETRY);
176         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_ENABLE_PUSH);
177         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_HPACK_MAX_HEADER_TABLE_SIZE);
178         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_HTTP_CLIENT_LOG);
179         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_KEEP_ALIVE_TIMEOUT);
180         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_KEEP_ALIVE_TIMEOUT_H2);
181         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_MAX_FRAME_SIZE);
182         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_MAX_STREAMS);
183         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_RECEIVE_BUFFER_SIZE);
184         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_REDIRECTS_RETRY_LIMIT);
185         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_SEND_BUFFER_SIZE);
186         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_WEB_SOCKET_WRITE_BUFFER_SIZE);
187         basicKeyCheck(SystemProperties.JDK_HTTP_CLIENT_WINDOW_SIZE);
188         basicKeyCheck(SystemProperties.JDK_HTTPS_NEGOTIATE_CBT);
189         basicKeyCheck(SystemProperties.JDK_HTTP_SERVER_MAX_CONNECTIONS);
190         basicKeyCheck(SystemProperties.JDK_INCLUDE_IN_EXCEPTIONS);
191         basicKeyCheck(SystemProperties.JDK_INTERNAL_HTTP_CLIENT_DISABLE_HOST_NAME_VERIFICATION);
192         basicKeyCheck(SystemProperties.JDK_IO_PERMISSIONS_USE_CANONICAL_PATH);
193         basicKeyCheck(SystemProperties.JDK_JNDI_LDAP_OBJECT_FACTORIES_FILTER);
194         basicKeyCheck(SystemProperties.JDK_JNDI_OBJECT_FACTORIES_FILTER);
195         basicKeyCheck(SystemProperties.JDK_JNDI_RMI_OBJECT_FACTORIES_FILTER);
196         basicKeyCheck(SystemProperties.JDK_MODULE_MAIN);
197         basicKeyCheck(SystemProperties.JDK_MODULE_MAIN_CLASS);
198         basicKeyCheck(SystemProperties.JDK_MODULE_PATH);
199         basicKeyCheck(SystemProperties.JDK_MODULE_UPGRADE_PATH);
200         basicKeyCheck(SystemProperties.JDK_NET_UNIX_DOMAIN_TMPDIR);
201         basicKeyCheck(SystemProperties.JDK_NET_URL_CLASS_PATH_SHOW_IGNORED_CLASS_PATH_ENTRIES);
202         basicKeyCheck(SystemProperties.JDK_SERIAL_FILTER);
203         basicKeyCheck(SystemProperties.JDK_SERIAL_FILTER_FACTORY);
204         basicKeyCheck(SystemProperties.JDK_TLS_CLIENT_SIGNATURE_SCHEMES);
205         basicKeyCheck(SystemProperties.JDK_TLS_NAMED_GROUPS);
206         basicKeyCheck(SystemProperties.JDK_TLS_SERVER_SIGNATURE_SCHEMES);
207         basicKeyCheck(SystemProperties.JDK_VIRTUAL_THREAD_SCHEDULER_MAXPOOLSIZE);
208         basicKeyCheck(SystemProperties.JDK_VIRTUAL_THREAD_SCHEDULER_PARALLELISM);
209         basicKeyCheck(SystemProperties.JDK_XML_CDATA_CHUNK_SIZE);
210         basicKeyCheck(SystemProperties.JDK_XML_DTD_SUPPORT);
211         basicKeyCheck(SystemProperties.JDK_XML_ELEMENT_ATTRIBUTE_LIMIT);
212         basicKeyCheck(SystemProperties.JDK_XML_ENABLE_EXTENSION_FUNCTIONS);
213         basicKeyCheck(SystemProperties.JDK_XML_ENTITY_EXPANSION_LIMIT);
214         basicKeyCheck(SystemProperties.JDK_XML_ENTITY_REPLACEMENT_LIMIT);
215         basicKeyCheck(SystemProperties.JDK_XML_IS_STANDALONE);
216         basicKeyCheck(SystemProperties.JDK_XML_JDK_CATALOG_RESOLVE);
217         basicKeyCheck(SystemProperties.JDK_XML_MAX_ELEMENT_DEPTH);
218         basicKeyCheck(SystemProperties.JDK_XML_MAX_GENERAL_ENTITY_SIZE_LIMIT);
219         basicKeyCheck(SystemProperties.JDK_XML_MAX_OCCUR_LIMIT);
220         basicKeyCheck(SystemProperties.JDK_XML_MAX_PARAMETER_ENTITY_SIZE_LIMIT);
221         basicKeyCheck(SystemProperties.JDK_XML_MAX_XML_NAME_LIMIT);
222         basicKeyCheck(SystemProperties.JDK_XML_OVERRIDE_DEFAULT_PARSER);
223         basicKeyCheck(SystemProperties.JDK_XML_RESET_SYMBOL_TABLE);
224         basicKeyCheck(SystemProperties.JDK_XML_TOTAL_ENTITY_SIZE_LIMIT);
225         basicKeyCheck(SystemProperties.JDK_XML_XSLTC_IS_STANDALONE);
226         basicKeyCheck(SystemProperties.LINE_SEPARATOR);
227         basicKeyCheck(SystemProperties.NATIVE_ENCODING);
228         basicKeyCheck(SystemProperties.NETWORK_ADDRESS_CACHE_NEGATIVE_TTL);
229         basicKeyCheck(SystemProperties.NETWORK_ADDRESS_CACHE_STALE_TTL);
230         basicKeyCheck(SystemProperties.NETWORK_ADDRESS_CACHE_TTL);
231         basicKeyCheck(SystemProperties.ORG_JCP_XML_DSIG_SECURE_VALIDATION);
232         basicKeyCheck(SystemProperties.ORG_OPENJDK_JAVA_UTIL_STREAM_TRIPWIRE);
233         basicKeyCheck(SystemProperties.OS_ARCH);
234         basicKeyCheck(SystemProperties.OS_NAME);
235         basicKeyCheck(SystemProperties.OS_VERSION);
236         basicKeyCheck(SystemProperties.PATH_SEPARATOR);
237         basicKeyCheck(SystemProperties.SOCKS_PROXY_HOST);
238         basicKeyCheck(SystemProperties.SOCKS_PROXY_PORT);
239         basicKeyCheck(SystemProperties.SOCKS_PROXY_VERSION);
240         basicKeyCheck(SystemProperties.STDERR_ENCODING);
241         basicKeyCheck(SystemProperties.STDOUT_ENCODING);
242         basicKeyCheck(SystemProperties.SUN_NET_HTTP_SERVER_DRAIN_AMOUNT);
243         basicKeyCheck(SystemProperties.SUN_NET_HTTP_SERVER_IDLE_INTERVAL);
244         basicKeyCheck(SystemProperties.SUN_NET_HTTP_SERVER_MAX_IDLE_CONNECTIONS);
245         basicKeyCheck(SystemProperties.SUN_NET_HTTP_SERVER_MAX_REQ_HEADERS);
246         basicKeyCheck(SystemProperties.SUN_NET_HTTP_SERVER_MAX_REQ_TIME);
247         basicKeyCheck(SystemProperties.SUN_NET_HTTP_SERVER_MAX_RSP_TIME);
248         basicKeyCheck(SystemProperties.SUN_NET_HTTP_SERVER_NO_DELAY);
249         basicKeyCheck(SystemProperties.SUN_SECURITY_KRB5_PRINCIPAL);
250         basicKeyCheck(SystemProperties.USER_COUNTRY);
251         basicKeyCheck(SystemProperties.USER_DIR);
252         basicKeyCheck(SystemProperties.USER_EXTENSIONS);
253         basicKeyCheck(SystemProperties.USER_HOME);
254         basicKeyCheck(SystemProperties.USER_LANGUAGE);
255         basicKeyCheck(SystemProperties.USER_NAME);
256         basicKeyCheck(SystemProperties.USER_REGION);
257         basicKeyCheck(SystemProperties.USER_SCRIPT);
258         basicKeyCheck(SystemProperties.USER_TIMEZONE);
259         basicKeyCheck(SystemProperties.USER_VARIANT);
260     }
261 
262     @Test
263     void testGetAwtToolkit() {
264         assertDoesNotThrow(SystemProperties::getAwtToolkit);
265     }
266 
267     @Test
268     void testGetBoolean() {
269         final String key = RandomStringUtils.insecure().next(10);
270         final String absentKey = RandomStringUtils.insecure().next(10);
271         assertNull(System.getProperty(absentKey));
272         try {
273             System.setProperty(key, Boolean.toString(Boolean.TRUE));
274             assertEquals(Boolean.TRUE, SystemProperties.getBoolean(key, () -> false));
275             assertEquals(Boolean.TRUE, SystemProperties.getBoolean(absentKey, () -> Boolean.TRUE));
276             assertFalse(SystemProperties.getBoolean(absentKey, () -> false));
277             assertFalse(SystemProperties.getBoolean(absentKey, null));
278         } finally {
279             System.clearProperty(key);
280         }
281     }
282 
283     @Test
284     void testGetBooleanClass() {
285         final String key = RandomStringUtils.insecure().next(10);
286         final String absentKey = RandomStringUtils.insecure().next(10);
287         final String keyFull = SIMPLE_NAME + "." + key;
288         final String absentKeyFull = SIMPLE_NAME + "." + absentKey;
289         assertNull(System.getProperty(absentKeyFull));
290         try {
291             System.setProperty(keyFull, Boolean.TRUE.toString());
292             assertTrue(SystemProperties.getBoolean(SystemPropertiesTest.class, key, () -> false));
293             assertTrue(SystemProperties.getBoolean(SystemPropertiesTest.class, absentKey, () -> true));
294             assertFalse(SystemProperties.getBoolean(SystemPropertiesTest.class, absentKey, () -> false));
295             assertTrue(SystemProperties.getBoolean(SystemPropertiesTest.class, absentKey, () -> true));
296         } finally {
297             System.clearProperty(keyFull);
298         }
299     }
300 
301     @Test
302     void testGetDoesNotThrow() {
303         assertDoesNotThrow(SystemProperties::getAppleAwtEnableTemplateImages);
304         assertDoesNotThrow(SystemProperties::getAwtToolkit);
305         assertDoesNotThrow(SystemProperties::getComSunJndiLdapObjectTrustSerialData);
306         assertDoesNotThrow(SystemProperties::getComSunNetHttpServerHttpServerProvider);
307         assertDoesNotThrow(SystemProperties::getFileEncoding);
308         assertDoesNotThrow(SystemProperties::getFileSeparator);
309         assertDoesNotThrow(SystemProperties::getFtpNonProxyHost);
310         assertDoesNotThrow(SystemProperties::getFtpProxyHost);
311         assertDoesNotThrow(SystemProperties::getFtpProxyPort);
312         assertDoesNotThrow(SystemProperties::getHttpAgent);
313         assertDoesNotThrow(SystemProperties::getHttpAuthDigestCnonceRepeat);
314         assertDoesNotThrow(SystemProperties::getHttpAuthDigestReenabledAlgorithms);
315         assertDoesNotThrow(SystemProperties::getHttpAuthDigestValidateProxy);
316         assertDoesNotThrow(SystemProperties::getHttpAuthDigestValidateServer);
317         assertDoesNotThrow(SystemProperties::getHttpAuthNtlmDomain);
318         assertDoesNotThrow(SystemProperties::getHttpKeepAlive);
319         assertDoesNotThrow(SystemProperties::getHttpKeepAliveTimeProxy);
320         assertDoesNotThrow(SystemProperties::getHttpKeepAliveTimeServer);
321         assertDoesNotThrow(SystemProperties::getHttpMaxConnections);
322         assertDoesNotThrow(SystemProperties::getHttpMaxRedirects);
323         assertDoesNotThrow(SystemProperties::getHttpNonProxyHosts);
324         assertDoesNotThrow(SystemProperties::getHttpProxyHost);
325         assertDoesNotThrow(SystemProperties::getHttpProxyPort);
326         assertDoesNotThrow(SystemProperties::getHttpsProxyHost);
327         assertDoesNotThrow(SystemProperties::getHttpsProxyPort);
328         assertDoesNotThrow(SystemProperties::getJavaAwtFonts);
329         assertDoesNotThrow(SystemProperties::getJavaAwtGraphicsenv);
330         assertDoesNotThrow(SystemProperties::getJavaAwtHeadless);
331         assertDoesNotThrow(SystemProperties::getJavaAwtPrinterjob);
332         assertDoesNotThrow(SystemProperties::getJavaClassPath);
333         assertDoesNotThrow(SystemProperties::getJavaClassVersion);
334         assertDoesNotThrow(SystemProperties::getJavaCompiler);
335         assertDoesNotThrow(SystemProperties::getJavaContentHandlerPkgs);
336         assertDoesNotThrow(SystemProperties::getJavaEndorsedDirs);
337         assertDoesNotThrow(SystemProperties::getJavaExtDirs);
338         assertDoesNotThrow(SystemProperties::getJavaHome);
339         assertDoesNotThrow(SystemProperties::getJavaIoTmpdir);
340         assertDoesNotThrow(SystemProperties::getJavaLibraryPath);
341         assertDoesNotThrow(SystemProperties::getJavaLocaleProviders);
342         assertDoesNotThrow(SystemProperties::getJavaLocaleUseOldIsoCodes);
343         assertDoesNotThrow(SystemProperties::getJavaNetPreferIpv4Stack);
344         assertDoesNotThrow(SystemProperties::getJavaNetPreferIpv6Addresses);
345         assertDoesNotThrow(SystemProperties::getJavaNetSocksPassword);
346         assertDoesNotThrow(SystemProperties::getJavaNetSocksUserName);
347         assertDoesNotThrow(SystemProperties::getJavaNetUseSystemProxies);
348         assertDoesNotThrow(SystemProperties::getJavaNioChannelsDefaultThreadPoolInitialSize);
349         assertDoesNotThrow(SystemProperties::getJavaNioChannelsDefaultThreadPoolThreadFactory);
350         assertDoesNotThrow(SystemProperties::getJavaNioChannelsSpiAsynchronousChannelProvider);
351         assertDoesNotThrow(SystemProperties::getJavaNioChannelsSpiSelectorProvider);
352         assertDoesNotThrow(SystemProperties::getJavaNioFileSpiDefaultFileSystemProvider);
353         assertDoesNotThrow(SystemProperties::getJavaPropertiesDate);
354         assertDoesNotThrow(SystemProperties::getJavaProtocolHandlerPkgs);
355         assertDoesNotThrow(SystemProperties::getJavaRmiServerCodebase);
356         assertDoesNotThrow(SystemProperties::getJavaRmiServerHostName);
357         assertDoesNotThrow(SystemProperties::getJavaRmiServerRandomIds);
358         assertDoesNotThrow(SystemProperties::getJavaRmiServerRmiClassLoaderSpi);
359         assertDoesNotThrow(SystemProperties::getJavaRuntimeName);
360         assertDoesNotThrow(SystemProperties::getJavaRuntimeVersion);
361         assertDoesNotThrow(SystemProperties::getJavaSecurityAuthLoginConfig);
362         assertDoesNotThrow(SystemProperties::getJavaSecurityManager);
363         assertDoesNotThrow(SystemProperties::getJavaSpecificationMaintenanceVersion);
364         assertDoesNotThrow(SystemProperties::getJavaSpecificationName);
365         assertDoesNotThrow(SystemProperties::getJavaSpecificationVendor);
366         assertDoesNotThrow((ThrowingSupplier<String>) SystemProperties::getJavaSpecificationVersion);
367         assertDoesNotThrow(SystemProperties::getJavaSystemClassLoader);
368         assertDoesNotThrow(SystemProperties::getJavaTimeZoneDefaultZoneRulesProvider);
369         assertDoesNotThrow(SystemProperties::getJavaUtilConcurrentForkJoinPoolCommonExceptionHandler);
370         assertDoesNotThrow(SystemProperties::getJavaUtilConcurrentForkJoinPoolCommonMaximumSpares);
371         assertDoesNotThrow(SystemProperties::getJavaUtilConcurrentForkJoinPoolCommonParallelism);
372         assertDoesNotThrow(SystemProperties::getJavaUtilConcurrentForkJoinPoolCommonThreadFactory);
373         assertDoesNotThrow(SystemProperties::getJavaUtilCurrencyData);
374         assertDoesNotThrow(SystemProperties::getJavaUtilLoggingConfigClass);
375         assertDoesNotThrow(SystemProperties::getJavaUtilLoggingConfigFile);
376         assertDoesNotThrow(SystemProperties::getJavaUtilLoggingSimpleFormatterFormat);
377         assertDoesNotThrow(SystemProperties::getJavaUtilPrefsPreferencesFactory);
378         assertDoesNotThrow(SystemProperties::getJavaUtilPropertyResourceBundleEncoding);
379         assertDoesNotThrow(SystemProperties::getJavaVendor);
380         assertDoesNotThrow(SystemProperties::getJavaVendorUrl);
381         assertDoesNotThrow(SystemProperties::getJavaVendorVersion);
382         assertDoesNotThrow(SystemProperties::getJavaVersion);
383         assertDoesNotThrow(SystemProperties::getJavaVersionDate);
384         assertDoesNotThrow(SystemProperties::getJavaVmInfo);
385         assertDoesNotThrow(SystemProperties::getJavaVmName);
386         assertDoesNotThrow(SystemProperties::getJavaVmSpecificationName);
387         assertDoesNotThrow(SystemProperties::getJavaVmSpecificationVendor);
388         assertDoesNotThrow(SystemProperties::getJavaVmSpecificationVersion);
389         assertDoesNotThrow(SystemProperties::getJavaVmVendor);
390         assertDoesNotThrow(SystemProperties::getJavaVmVersion);
391         assertDoesNotThrow(SystemProperties::getJavaxAccessibilityAssistiveTechnologies);
392         assertDoesNotThrow(SystemProperties::getJavaXmlConfigFile);
393         assertDoesNotThrow(SystemProperties::getJavaxNetSslSessionCacheSize);
394         assertDoesNotThrow(SystemProperties::getJavaxRmiSslClientEnabledCipherSuites);
395         assertDoesNotThrow(SystemProperties::getJavaxRmiSslClientEnabledProtocols);
396         assertDoesNotThrow(SystemProperties::getJavaxSecurityAuthUseSubjectCredsOnly);
397         assertDoesNotThrow(SystemProperties::getJavaxSmartCardIoTerminalFactoryDefaultType);
398         assertDoesNotThrow(SystemProperties::getJdbcDrivers);
399         assertDoesNotThrow(SystemProperties::getJdkHttpAuthProxyingDisabledSchemes);
400         assertDoesNotThrow(SystemProperties::getJdkHttpAuthTunnelingDisabledSchemes);
401         assertDoesNotThrow(SystemProperties::getJdkHttpClientAllowRestrictedHeaders);
402         assertDoesNotThrow(SystemProperties::getJdkHttpClientAuthRetryLimit);
403         assertDoesNotThrow(SystemProperties::getJdkHttpClientBufSize);
404         assertDoesNotThrow(SystemProperties::getJdkHttpClientConnectionPoolSize);
405         assertDoesNotThrow(SystemProperties::getJdkHttpClientConnectionWindowSize);
406         assertDoesNotThrow(SystemProperties::getJdkHttpClientDisableRetryConnect);
407         assertDoesNotThrow(SystemProperties::getJdkHttpClientEnableAllMethodRetry);
408         assertDoesNotThrow(SystemProperties::getJdkHttpClientEnablePush);
409         assertDoesNotThrow(SystemProperties::getJdkHttpClientHpackMaxHeaderTableSize);
410         assertDoesNotThrow(SystemProperties::getJdkHttpClientHttpClientLog);
411         assertDoesNotThrow(SystemProperties::getJdkHttpClientKeepAliveTimeout);
412         assertDoesNotThrow(SystemProperties::getJdkHttpClientKeepAliveTimeoutH2);
413         assertDoesNotThrow(SystemProperties::getJdkHttpClientMaxFrameSize);
414         assertDoesNotThrow(SystemProperties::getJdkHttpClientMaxStreams);
415         assertDoesNotThrow(SystemProperties::getJdkHttpClientReceiveBufferSize);
416         assertDoesNotThrow(SystemProperties::getJdkHttpClientRedirectsRetryLimit);
417         assertDoesNotThrow(SystemProperties::getJdkHttpClientSendBufferSize);
418         assertDoesNotThrow(SystemProperties::getJdkHttpClientWebSocketWriteBufferSize);
419         assertDoesNotThrow(SystemProperties::getJdkHttpClientWindowSize);
420         assertDoesNotThrow(SystemProperties::getJdkHttpServerMaxConnections);
421         assertDoesNotThrow(SystemProperties::getJdkHttpsNegotiateCbt);
422         assertDoesNotThrow(SystemProperties::getJdkIncludeInExceptions);
423         assertDoesNotThrow(SystemProperties::getJdkInternalHttpClientDisableHostNameVerification);
424         assertDoesNotThrow(SystemProperties::getJdkIoPermissionsUseCanonicalPath);
425         assertDoesNotThrow(SystemProperties::getJdkJndiLdapObjectFactoriesFilter);
426         assertDoesNotThrow(SystemProperties::getJdkJndiObjectFactoriesFilter);
427         assertDoesNotThrow(SystemProperties::getJdkJndiRmiObjectFactoriesFilter);
428         assertDoesNotThrow(SystemProperties::getJdkModuleMain);
429         assertDoesNotThrow(SystemProperties::getJdkModuleMainClass);
430         assertDoesNotThrow(SystemProperties::getJdkModulePath);
431         assertDoesNotThrow(SystemProperties::getJdkModuleUpgradePath);
432         assertDoesNotThrow(SystemProperties::getJdkNetUnixDomainTmpDir);
433         assertDoesNotThrow(SystemProperties::getJdkNetUrlClassPathShowIgnoredClassPathEntries);
434         assertDoesNotThrow(SystemProperties::getJdkSerialFilter);
435         assertDoesNotThrow(SystemProperties::getJdkSerialFilterFactory);
436         assertDoesNotThrow(SystemProperties::getJdkTlsClientSignatureSchemes);
437         assertDoesNotThrow(SystemProperties::getJdkTlsNamedGroups);
438         assertDoesNotThrow(SystemProperties::getJdkTlsServerSignatureSchemes);
439         assertDoesNotThrow(SystemProperties::getJdkVirtualThreadSchedulerMaxPoolSize);
440         assertDoesNotThrow(SystemProperties::getJdkVirtualThreadSchedulerParallelism);
441         assertDoesNotThrow(SystemProperties::getJdkXmlCdataChunkSize);
442         assertDoesNotThrow(SystemProperties::getJdkXmlDtdSupport);
443         assertDoesNotThrow(SystemProperties::getJdkXmlElementAttributeLimit);
444         assertDoesNotThrow(SystemProperties::getJdkXmlEnableExtensionFunctions);
445         assertDoesNotThrow(SystemProperties::getJdkXmlEntityExpansionLimit);
446         assertDoesNotThrow(SystemProperties::getJdkXmlEntityReplacementLimit);
447         assertDoesNotThrow(SystemProperties::getJdkXmlIsStandalone);
448         assertDoesNotThrow(SystemProperties::getJdkXmlJdkCatalogResolve);
449         assertDoesNotThrow(SystemProperties::getJdkXmlMaxElementDepth);
450         assertDoesNotThrow(SystemProperties::getJdkXmlMaxGeneralEntitySizeLimit);
451         assertDoesNotThrow(SystemProperties::getJdkXmlMaxOccurLimit);
452         assertDoesNotThrow(SystemProperties::getJdkXmlMaxParameterEntitySizeLimit);
453         assertDoesNotThrow(SystemProperties::getJdkXmlMaxXmlNameLimit);
454         assertDoesNotThrow(SystemProperties::getJdkXmlOverrideDefaultParser);
455         assertDoesNotThrow(SystemProperties::getJdkXmlResetSymbolTable);
456         assertDoesNotThrow(SystemProperties::getJdkXmlTotalEntitySizeLimit);
457         assertDoesNotThrow(SystemProperties::getJdkXmlXsltcIsStandalone);
458         assertDoesNotThrow((ThrowingSupplier<String>) SystemProperties::getLineSeparator);
459         assertDoesNotThrow(SystemProperties::getNativeEncoding);
460         assertDoesNotThrow(SystemProperties::getNetworkAddressCacheNegativeTtl);
461         assertDoesNotThrow(SystemProperties::getNetworkAddressCacheStaleTtl);
462         assertDoesNotThrow(SystemProperties::getNetworkAddressCacheTtl);
463         assertDoesNotThrow(SystemProperties::getOrgJcpXmlDsigSecureValidation);
464         assertDoesNotThrow(SystemProperties::getOrgOpenJdkJavaUtilStreamTripwire);
465         assertDoesNotThrow(SystemProperties::getOsArch);
466         assertDoesNotThrow(SystemProperties::getOsName);
467         assertDoesNotThrow(SystemProperties::getOsVersion);
468         assertDoesNotThrow(SystemProperties::getPathSeparator);
469         assertDoesNotThrow(SystemProperties::getSocksProxyHost);
470         assertDoesNotThrow(SystemProperties::getSocksProxyPort);
471         assertDoesNotThrow(SystemProperties::getSocksProxyVersion);
472         assertDoesNotThrow(SystemProperties::getStdErrEncoding);
473         assertDoesNotThrow(SystemProperties::getStdOutEncoding);
474         assertDoesNotThrow(SystemProperties::getSunNetHttpServerDrainAmount);
475         assertDoesNotThrow(SystemProperties::getSunNetHttpServerIdleInterval);
476         assertDoesNotThrow(SystemProperties::getSunNetHttpServerMaxIdleConnections);
477         assertDoesNotThrow(SystemProperties::getSunNetHttpServerMaxReqHeaders);
478         assertDoesNotThrow(SystemProperties::getSunNetHttpServerMaxReqTime);
479         assertDoesNotThrow(SystemProperties::getSunNetHttpServerMaxRspTime);
480         assertDoesNotThrow(SystemProperties::getSunNetHttpServerNoDelay);
481         assertDoesNotThrow(SystemProperties::getSunSecurityKrb5Principal);
482         assertDoesNotThrow(SystemProperties::getUserCountry);
483         assertDoesNotThrow(SystemProperties::getUserDir);
484         assertDoesNotThrow(SystemProperties::getUserExtensions);
485         assertDoesNotThrow(SystemProperties::getUserHome);
486         assertDoesNotThrow(SystemProperties::getUserLanguage);
487         assertDoesNotThrow((ThrowingSupplier<String>) SystemProperties::getUserName);
488         assertDoesNotThrow(SystemProperties::getUserRegion);
489         assertDoesNotThrow(SystemProperties::getUserScript);
490         assertDoesNotThrow(SystemProperties::getUserTimezone);
491         assertDoesNotThrow(SystemProperties::getUserVariant);
492     }
493 
494     @Test
495     void testGetFileEncoding() {
496         basicKeyCheck(SystemProperties.getFileEncoding());
497     }
498 
499     @Test
500     void testGetFileSeparator() {
501         assertNotNull(SystemProperties.getFileSeparator());
502     }
503 
504     @Test
505     void testGetInt() {
506         final String key = RandomStringUtils.insecure().next(10);
507         final String absentKey = RandomStringUtils.insecure().next(10);
508         assertNull(System.getProperty(absentKey));
509         try {
510             System.setProperty(key, Integer.toString(Integer.MAX_VALUE));
511             assertEquals(Integer.MAX_VALUE, SystemProperties.getInt(key, () -> 0));
512             assertEquals(Integer.MAX_VALUE, SystemProperties.getInt(absentKey, () -> Integer.MAX_VALUE));
513             assertEquals(0, SystemProperties.getInt(absentKey, () -> 0));
514             assertEquals(0, SystemProperties.getInt(absentKey, null));
515         } finally {
516             System.clearProperty(key);
517         }
518     }
519 
520     @Test
521     void testGetIntClass() {
522         final String key = RandomStringUtils.insecure().next(10);
523         final String absentKey = RandomStringUtils.insecure().next(10);
524         final String keyFull = SIMPLE_NAME + "." + key;
525         final String absentKeyFull = SIMPLE_NAME + "." + absentKey;
526         assertNull(System.getProperty(absentKeyFull));
527         try {
528             System.setProperty(keyFull, Long.toString(Integer.MAX_VALUE));
529             assertEquals(Integer.MAX_VALUE, SystemProperties.getInt(SystemPropertiesTest.class, key, () -> 0));
530             assertEquals(Integer.MAX_VALUE, SystemProperties.getInt(SystemPropertiesTest.class, absentKey, () -> Integer.MAX_VALUE));
531             assertEquals(0, SystemProperties.getInt(SystemPropertiesTest.class, absentKey, () -> 0));
532             assertEquals(1, SystemProperties.getInt(SystemPropertiesTest.class, absentKey, () -> 1));
533         } finally {
534             System.clearProperty(keyFull);
535         }
536     }
537 
538     @Test
539     void testGetJavaAwtFonts() {
540         assertNull(SystemProperties.getJavaAwtFonts());
541     }
542 
543     @Test
544     void testGetJavaAwtGraphicsenv() {
545         assertDoesNotThrow(SystemProperties::getJavaAwtGraphicsenv);
546     }
547 
548     @Test
549     void testGetJavaAwtHeadless() {
550         assertNull(SystemProperties.getJavaAwtHeadless());
551     }
552 
553     @Test
554     void testGetJavaAwtPrinterjob() {
555         assertDoesNotThrow(SystemProperties::getJavaAwtPrinterjob);
556     }
557 
558     @Test
559     void testGetJavaClassPath() {
560         assertNotNull(SystemProperties.getJavaClassPath());
561     }
562 
563     @Test
564     void testGetJavaClassVersion() {
565         assertNotNull(SystemProperties.getJavaClassVersion());
566     }
567 
568     @Test
569     void testGetJavaCompiler() {
570         if (SystemUtils.IS_JAVA_14) {
571             // Not in Java 11
572             assertNotNull(SystemProperties.getJavaCompiler());
573         }
574     }
575 
576     @Test
577     void testGetJavaEndorsedDirs() {
578         if (isJava11OrGreater()) {
579             // Not in Java 11
580             assertNull(SystemProperties.getJavaEndorsedDirs());
581         } else {
582             assertNotNull(SystemProperties.getJavaExtDirs());
583         }
584     }
585 
586     @Test
587     void testGetJavaExtDirs() {
588         if (isJava11OrGreater()) {
589             // Not in Java 11
590             assertNull(SystemProperties.getJavaExtDirs());
591         } else {
592             assertNotNull(SystemProperties.getJavaExtDirs());
593         }
594     }
595 
596     @Test
597     void testGetJavaHome() {
598         assertNotNull(SystemProperties.getJavaHome());
599     }
600 
601     @Test
602     void testGetJavaIoTmpdir() {
603         assertNotNull(SystemProperties.getJavaIoTmpdir());
604     }
605 
606     @Test
607     void testGetJavaLibraryPath() {
608         assertNotNull(SystemProperties.getJavaLibraryPath());
609     }
610 
611     @Test
612     void testGetJavaLocaleProviders() {
613         assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9));
614         // default is null
615         assertNull(SystemProperties.getJavaLocaleProviders(), SystemProperties.getJavaVersion());
616     }
617 
618     @Test
619     void testGetJavaRuntimeName() {
620         assertNotNull(SystemProperties.getJavaRuntimeName());
621     }
622 
623     @Test
624     void testGetJavaRuntimeVersion() {
625         assertNotNull(SystemProperties.getJavaRuntimeVersion());
626     }
627 
628     @Test
629     void testGetJavaSpecificationName() {
630         assertNotNull(SystemProperties.getJavaSpecificationName());
631     }
632 
633     @Test
634     void testGetJavaSpecificationVendor() {
635         assertNotNull(SystemProperties.getJavaSpecificationVendor());
636     }
637 
638     @Test
639     void testGetJavaSpecificationVersion() {
640         assertNotNull(SystemProperties.getJavaSpecificationVersion());
641     }
642 
643     @Test
644     void testGetJavaSpecificationVersionSupplier() {
645         assertNotNull(SystemProperties.getJavaSpecificationVersion("99.0"));
646     }
647 
648     @Test
649     void testGetJavaUtilPrefsPreferencesFactory() {
650         assertNull(SystemProperties.getJavaUtilPrefsPreferencesFactory());
651     }
652 
653     @Test
654     void testGetJavaVendor() {
655         assertNotNull(SystemProperties.getJavaVendor());
656     }
657 
658     @Test
659     void testGetJavaVendorUrl() {
660         assertNotNull(SystemProperties.getJavaVendorUrl());
661     }
662 
663     @Test
664     void testGetJavaVersion() {
665         assertNotNull(SystemProperties.getJavaVersion());
666     }
667 
668     @Test
669     void testGetJavaVmInfo() {
670         assertNotNull(SystemProperties.getJavaVmInfo());
671     }
672 
673     @Test
674     void testGetJavaVmName() {
675         assertNotNull(SystemProperties.getJavaVmName());
676     }
677 
678     @Test
679     void testGetJavaVmSpecificationName() {
680         assertNotNull(SystemProperties.getJavaVmSpecificationName());
681     }
682 
683     @Test
684     void testGetJavaVmSpecificationVendor() {
685         assertNotNull(SystemProperties.getJavaVmSpecificationVendor());
686     }
687 
688     @Test
689     void testGetJavaVmSpecificationVersion() {
690         assertNotNull(SystemProperties.getJavaVmSpecificationVersion());
691     }
692 
693     @Test
694     void testGetJavaVmVendor() {
695         assertNotNull(SystemProperties.getJavaVmVendor());
696     }
697 
698     @Test
699     void testGetJavaVmVersion() {
700         assertNotNull(SystemProperties.getJavaVmVersion());
701     }
702 
703     @Test
704     void testGetLineSeparator() {
705         assertNotNull(SystemProperties.getLineSeparator());
706         assertNotNull(SystemProperties.getLineSeparator(null));
707         assertNotNull(SystemProperties.getLineSeparator(() -> ""));
708         assertNotNull(SystemProperties.getLineSeparator(() -> "\n"));
709         assertNotNull(SystemProperties.getLineSeparator(() -> null));
710         assertNotNull(SystemProperties.getLineSeparator(null));
711     }
712 
713     @Test
714     void testGetLong() {
715         final String key = RandomStringUtils.insecure().next(10);
716         final String absentKey = RandomStringUtils.insecure().next(10);
717         assertNull(System.getProperty(absentKey));
718         try {
719             System.setProperty(key, Long.toString(Long.MAX_VALUE));
720             assertEquals(Long.MAX_VALUE, SystemProperties.getLong(key, () -> 0));
721             assertEquals(Long.MAX_VALUE, SystemProperties.getLong(absentKey, () -> Long.MAX_VALUE));
722             assertEquals(0, SystemProperties.getLong(absentKey, () -> 0));
723             assertEquals(0, SystemProperties.getLong(absentKey, null));
724         } finally {
725             System.clearProperty(key);
726         }
727     }
728 
729     @Test
730     void testGetLongClass() {
731         final String key = RandomStringUtils.insecure().next(10);
732         final String absentKey = RandomStringUtils.insecure().next(10);
733         final String keyFull = SIMPLE_NAME + "." + key;
734         final String absentKeyFull = SIMPLE_NAME + "." + absentKey;
735         assertNull(System.getProperty(absentKeyFull));
736         try {
737             System.setProperty(keyFull, Long.toString(Long.MAX_VALUE));
738             assertEquals(Long.MAX_VALUE, SystemProperties.getLong(SystemPropertiesTest.class, key, () -> 0));
739             assertEquals(Long.MAX_VALUE, SystemProperties.getLong(SystemPropertiesTest.class, absentKey, () -> Long.MAX_VALUE));
740             assertEquals(0, SystemProperties.getLong(SystemPropertiesTest.class, absentKey, () -> 0));
741             assertEquals(1, SystemProperties.getLong(SystemPropertiesTest.class, absentKey, () -> 1));
742         } finally {
743             System.clearProperty(keyFull);
744         }
745     }
746 
747     @Test
748     void testGetOsArch() {
749         assertNotNull(SystemProperties.getOsArch());
750     }
751 
752     @Test
753     void testGetOsName() {
754         assertNotNull(SystemProperties.getOsName());
755     }
756 
757     @Test
758     void testGetOsVersion() {
759         assertNotNull(SystemProperties.getOsVersion());
760     }
761 
762     @Test
763     void testGetPath() {
764         assertNull(SystemProperties.getPath(null, null));
765         assertNull(SystemProperties.getPath(null, () -> null));
766         assertNull(SystemProperties.getPath(StringUtils.EMPTY, null));
767         assertEquals(Paths.get("value1"), SystemProperties.getPath(KEY_SPACE_1, null));
768         assertEquals(Paths.get("value2"), SystemProperties.getPath(KEY_TAB_1, null));
769         assertEquals(Paths.get("value1"), SystemProperties.getPath(null, () -> Paths.get("value1")));
770     }
771 
772     @Test
773     void testGetPathSeparator() {
774         assertNotNull(SystemProperties.getPathSeparator());
775     }
776 
777     @Test
778     void testGetProperty() {
779         assertNull(SystemProperties.getProperty(null));
780         assertNull(SystemProperties.getProperty(StringUtils.EMPTY));
781         assertEquals("value1", SystemProperties.getProperty(KEY_SPACE_1));
782         assertEquals("value2", SystemProperties.getProperty(KEY_TAB_1));
783     }
784 
785     @Test
786     void testGetPropertyStringString() {
787         assertNull(SystemProperties.getProperty(null, StringUtils.NULL));
788         assertNull(SystemProperties.getProperty(StringUtils.EMPTY, StringUtils.NULL));
789         assertEquals("value1", SystemProperties.getProperty(KEY_SPACE_1, StringUtils.NULL));
790         assertEquals("value2", SystemProperties.getProperty("\t", StringUtils.NULL));
791         assertEquals("x", SystemProperties.getProperty(null, "x"));
792         assertEquals("x", SystemProperties.getProperty(StringUtils.EMPTY, "x"));
793         assertEquals("value1", SystemProperties.getProperty(KEY_SPACE_1, "v"));
794         assertEquals("value2", SystemProperties.getProperty("\t", "v"));
795     }
796 
797     @Test
798     void testGetPropertyStringSupplier() {
799         assertNull(SystemProperties.getProperty(null, (Supplier<String>) null));
800         assertNull(SystemProperties.getProperty(StringUtils.EMPTY, (Supplier<String>) null));
801         assertEquals("value1", SystemProperties.getProperty(KEY_SPACE_1, (Supplier<String>) null));
802         assertEquals("value2", SystemProperties.getProperty("\t", (Supplier<String>) null));
803         assertEquals("x", SystemProperties.getProperty(null, () -> "x"));
804         assertEquals("x", SystemProperties.getProperty(StringUtils.EMPTY, () -> "x"));
805         assertEquals("value1", SystemProperties.getProperty(KEY_SPACE_1, () -> "v"));
806         assertEquals("value2", SystemProperties.getProperty("\t", () -> "v"));
807     }
808 
809     @Test
810     void testGetUserCountry() {
811         assertDoesNotThrow(SystemProperties::getUserCountry);
812     }
813 
814     @Test
815     void testGetUserDir() {
816         assertNotNull(SystemProperties.getUserDir());
817     }
818 
819     @Test
820     void testGetUserHome() {
821         assertNotNull(SystemProperties.getUserHome());
822     }
823 
824     @Test
825     void testGetUserLanguage() {
826         assertNotNull(SystemProperties.getUserLanguage());
827     }
828 
829     @Test
830     void testGetUserName() {
831         assertNotNull(SystemProperties.getUserName());
832         assertNotNull(SystemProperties.getUserName(""));
833         assertNotNull(SystemProperties.getUserName("User"));
834         assertNotNull(SystemProperties.getUserName(null));
835     }
836 
837     @Test
838     void testGetUserTimezone() {
839         assertDoesNotThrow(SystemProperties::getUserTimezone);
840     }
841 
842     @ParameterizedTest
843     @ValueSource(strings = { KEY_SPACE_1, KEY_TAB_1 })
844     void testIsPropertySet(final String property) {
845         assertTrue(SystemProperties.isPropertySet(property));
846     }
847 
848     @Test
849     void testIsPropertySetEdges() {
850         assertFalse(SystemProperties.isPropertySet(StringUtils.NULL));
851         assertFalse(SystemProperties.isPropertySet(StringUtils.EMPTY));
852     }
853 
854 }