DataSourceFactory { static long retrieveConfigSetting(String propName, long defaultValue) { String propValue = System.getProperty(propName); if (propValue == null) { return defaultValue; } long value = defaultValue; try { value = Long.parseLong(propValue); } catch (NumberFormatException ex) { if (LOG.isWarnEnabled()) { LOG.warn("Ignoring Invalid number({}) set in system property({}). Using default ({})", propValue, propName, defaultValue); } } return value; }  static PoolableDataSource create(String url, Properties mysqlConnectionProperties); static GenericObjectPoolConfig setupPoolConfig();  }
@Test public void testRetrieveConfigSettingLong() { System.setProperty(ATHENZ_DBPOOL_PROP1, "100"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20L), 100L); System.setProperty(ATHENZ_DBPOOL_PROP1, "0"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20L), 0); System.setProperty(ATHENZ_DBPOOL_PROP1, "-100"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20L), -100L); System.clearProperty(ATHENZ_DBPOOL_PROP1); }
@Test public void testRetrieveConfigSettingLongNull() { System.clearProperty(ATHENZ_DBPOOL_PROP1); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 25L), 25L); }
@Test public void testRetrieveConfigSettingLongInvalid() { System.setProperty(ATHENZ_DBPOOL_PROP1, "abc"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20L), 20L); System.clearProperty(ATHENZ_DBPOOL_PROP1); }
@Test public void testRetrieveConfigSettingInt() { System.setProperty(ATHENZ_DBPOOL_PROP1, "100"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20), 100); System.setProperty(ATHENZ_DBPOOL_PROP1, "0"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20), 0); System.setProperty(ATHENZ_DBPOOL_PROP1, "-100"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20), -100); System.clearProperty(ATHENZ_DBPOOL_PROP1); }
@Test public void testRetrieveConfigSettingIntNull() { System.clearProperty(ATHENZ_DBPOOL_PROP1); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 25), 25); }
@Test public void testRetrieveConfigSettingIntInvalid() { System.setProperty(ATHENZ_DBPOOL_PROP1, "abc"); assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20), 20); System.clearProperty(ATHENZ_DBPOOL_PROP1); }