ConfigUtils { @SuppressWarnings("deprecation") public static int getServerShutdownTimeout() { int timeout = Constants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT; String value = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY); if (value != null && value.length() > 0) { try { timeout = Integer.parseInt(value); } catch (Exception e) { } } else { value = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY); if (value != null && value.length() > 0) { try { timeout = Integer.parseInt(value) * 1000; } catch (Exception e) { } } } return timeout; } private  ConfigUtils(); static boolean isNotEmpty(String value); static boolean isEmpty(String value); static boolean isDefault(String value); static List<String> mergeValues(Class<?> type, String cfg, List<String> def); static String replaceProperty(String expression, Map<String, String> params); static Properties getProperties(); static void setProperties(Properties properties); static void addProperties(Properties properties); static String getProperty(String key); @SuppressWarnings({"unchecked", "rawtypes"}) static String getProperty(String key, String defaultValue); static String getSystemProperty(String key); static Properties loadProperties(String fileName); static Properties loadProperties(String fileName, boolean allowMultiFile); static Properties loadProperties(String fileName, boolean allowMultiFile, boolean optional); static int getPid(); @SuppressWarnings("deprecation") static int getServerShutdownTimeout();  }
@Test public void testGetServerShutdownTimeoutFromShutdownWait() throws Exception { System.setProperty(Constants.SHUTDOWN_WAIT_KEY, "1234"); try { assertThat(ConfigUtils.getServerShutdownTimeout(), equalTo(1234)); } finally { System.clearProperty(Constants.SHUTDOWN_WAIT_KEY); } }
@Test public void testGetServerShutdownTimeoutFromShutdownWaitSeconds() throws Exception { System.setProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY, "1234"); try { assertThat(ConfigUtils.getServerShutdownTimeout(), equalTo(1234 * 1000)); } finally { System.clearProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY); } }
@Test public void testGetServerShutdownTimeoutFromDefault() throws Exception { System.clearProperty(Constants.SHUTDOWN_WAIT_KEY); System.clearProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY); assertThat(ConfigUtils.getServerShutdownTimeout(), equalTo(Constants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT)); }