Configuration { protected static void setTimeoutValue(Map<String, String> properties, String propertyName) { if (properties == null) { return; } String value = properties.get(propertyName); if (value == null) { return; } try { properties.put(propertyName, Integer.toString(timeStringToMillis(value))); } catch (InvalidTimeException e) { log.warn( "Invalid value {0} for configuration property ''{1}'', timeout has been disabled.", value, propertyName ); properties.put(propertyName, "0"); } catch (ConfigurationException e) { log.warn("Invalid value ''{0}'' for configuration property ''{1}''.", value, propertyName); } }  void setConfigurationProperties(Map<String, String> configurationProperties);  }
@Test public void testSetTimeoutValue() { Map<String, String> props = new HashMap<String, String>(); props.put("test", "1m"); Configuration.setTimeoutValue(props, "test"); Assert.assertTrue(props.get("test").equals("60000")); }
@Test public void testSetTimeoutValueSeconds() { Map<String, String> props = new HashMap<String, String>(); props.put("test", "3 s"); Configuration.setTimeoutValue(props, "test"); Assert.assertTrue(props.get("test").equals("3000")); }
@Test public void testSetTimeoutValueMillis() { Map<String, String> props = new HashMap<String, String>(); props.put("test", "1ms"); Configuration.setTimeoutValue(props, "test"); Assert.assertTrue(props.get("test").equals("1")); }
@Test public void testSetTimeoutValueNoSuffix() { Map<String, String> props = new HashMap<String, String>(); props.put("test", "7"); Configuration.setTimeoutValue(props, "test"); Assert.assertTrue(props.get("test").equals("7000")); }
@Test public void testSetTimeoutValueNegative() { Map<String, String> props = new HashMap<String, String>(); props.put("test", "-3 ms"); Configuration.setTimeoutValue(props, "test"); Assert.assertTrue(props.get("test").equals("0")); }
@Test public void testSetTimeoutValueInvalid() { Map<String, String> props = new HashMap<String, String>(); props.put("test", "foo"); Configuration.setTimeoutValue(props, "test"); Assert.assertTrue(props.get("test").equals("foo")); }
@Test public void testSetTimeoutValueNullProps() { Configuration.setTimeoutValue(null, "test"); }
@Test public void testSetTimeoutValueNullName() { Map<String, String> props = new HashMap<String, String>(); props.put("test", "7"); Configuration.setTimeoutValue(props, null); Assert.assertTrue(props.get("test").equals("7")); }