PropertiesHelper { public static long getLong(String propertyName, long defaultValue, long minValue, long maxValue) { String property = System.getProperty(propertyName); long result = defaultValue; if (property != null) { try { long value = Long.decode(property); if (value < minValue || value > maxValue) { logger.warn("Property {} is outside the range [{},{}], setting to default {}", propertyName, minValue, maxValue, defaultValue); } else { result = value; } } catch (Exception ex) { logger.warn("Can't convert property {} value {} to a long, using default {}", propertyName, property, defaultValue, ex); } } logger.debug("System property {}'s value is {}", propertyName, result); return result; }  static long getLong(String propertyName, long defaultValue, long minValue, long maxValue);  }
@Test public void getSystemPropertyAsLongTest() throws Exception { String property = "org.apache.apex.com.util.systemHelper"; System.setProperty(property, "1001"); Assert.assertEquals(1001, PropertiesHelper.getLong(property, 100, 100, 2000)); Assert.assertEquals(2000, PropertiesHelper.getLong(property, 2000, 2000, 20000)); System.setProperty(property, "INVALID"); Assert.assertEquals(2000, PropertiesHelper.getLong(property, 2000, 2000, 20000)); }