@Test public void shouldGetIntProperty() throws Exception { PowerMockito.mockStatic(IdentityUtil.class); PowerMockito.when(IdentityUtil.class.getResourceAsStream( "/identity.properties")).thenReturn(streamMock); PowerMockito.when(IdentityUtil.getIntProperty("key")).thenReturn(1); Assert.assertEquals(1, IdentityUtil.getIntProperty("key")); }
public static int getIntProperty(String key) throws Exception { String property = getProperty(key); if (property == null) { LOG.warn("Could not load integer property " + key); return -1; } try { return Integer.parseInt(property); } catch (NumberFormatException nfe) { LOG.warn("Invalid format for a number in properties file: " + property, nfe); return -1; } }
IdentityUtil { public static int getIntProperty(String key) throws Exception { String property = getProperty(key); if (property == null) { LOG.warn("Could not load integer property " + key); return -1; } try { return Integer.parseInt(property); } catch (NumberFormatException nfe) { LOG.warn("Invalid format for a number in properties file: " + property, nfe); return -1; } } }
IdentityUtil { public static int getIntProperty(String key) throws Exception { String property = getProperty(key); if (property == null) { LOG.warn("Could not load integer property " + key); return -1; } try { return Integer.parseInt(property); } catch (NumberFormatException nfe) { LOG.warn("Invalid format for a number in properties file: " + property, nfe); return -1; } }  }
IdentityUtil { public static int getIntProperty(String key) throws Exception { String property = getProperty(key); if (property == null) { LOG.warn("Could not load integer property " + key); return -1; } try { return Integer.parseInt(property); } catch (NumberFormatException nfe) { LOG.warn("Invalid format for a number in properties file: " + property, nfe); return -1; } }  static String getProperty(String key); static String getProperty(String key, String defaultValue); static int getIntProperty(String key); }
IdentityUtil { public static int getIntProperty(String key) throws Exception { String property = getProperty(key); if (property == null) { LOG.warn("Could not load integer property " + key); return -1; } try { return Integer.parseInt(property); } catch (NumberFormatException nfe) { LOG.warn("Invalid format for a number in properties file: " + property, nfe); return -1; } }  static String getProperty(String key); static String getProperty(String key, String defaultValue); static int getIntProperty(String key);  }