SystemPropertiesUtil { public static String getString(String name) { return System.getProperty(name); }  static Boolean getBoolean(String name); static Boolean getBoolean(String name, Boolean defaultValue); static String getString(String name); static String getString(String name, String defaultValue); static Integer getInteger(String name); static Integer getInteger(String name, Integer defaultValue); static Long getLong(String name); static Long getLong(String name, Long defaultValue); static Double getDouble(String propertyName); static Double getDouble(String propertyName, Double defaultValue); static String getString(String propertyName, String envName, String defaultValue); static Integer getInteger(String propertyName, String envName, Integer defaultValue); static Long getLong(String propertyName, String envName, Long defaultValue); static Double getDouble(String propertyName, String envName, Double defaultValue); static Boolean getBoolean(String propertyName, String envName, Boolean defaultValue); static synchronized void registerSystemPropertiesListener(PropertiesListener listener);  }
@Test public void stringSystemProperty() { String name = "ss.test" + RandomUtil.nextInt(); String envName = "ss_test" + RandomUtil.nextInt(); String result = SystemPropertiesUtil.getString(name, envName, "123"); assertThat(result).isEqualTo("123"); String result2 = SystemPropertiesUtil.getString(name, "PATH", "123"); assertThat(result2).isNotEqualTo("123"); System.setProperty(name, "456"); String result3 = SystemPropertiesUtil.getString(name, envName, "123"); assertThat(result3).isEqualTo("456"); try { String result4 = SystemPropertiesUtil.getString(name, name, "123"); fail("should fail before"); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalArgumentException.class); } System.clearProperty(name); }