### Question:
PropertiesUtils { public static Properties loadFromClasspath(String resourcePath) { if (StringUtils.isEmpty(resourcePath)) { throw new IllegalArgumentException("resourcePath must not be empty."); } LOG.debug("resourcePath to load : {}", resourcePath); Properties properties = new Properties(); try { InputStream resourceStream = PropertiesUtils.class.getClassLoader().getResourceAsStream(resourcePath); if (resourceStream == null) { throw new IllegalStateException("Failed to load properties from '" + resourcePath + "'. You might set illegal resource path. Leading slash(/) is not allowed."); } if (resourcePath.toLowerCase().endsWith(".xml")) { properties.loadFromXML(resourceStream); } else { properties.load(resourceStream); } } catch (IOException e) { throw new IllegalStateException("Failed to load properties from '" + resourcePath + "'."); } return properties; }  static Properties loadFromClasspath(String resourcePath);  }### Answer:
@Test public void loadFromClasspath_emptyConfigPath() throws Exception { expectedException.expect(IllegalArgumentException.class); PropertiesUtils.loadFromClasspath(""); }
@Test public void loadFromClasspath_normal_properties() throws Exception { Properties properties = PropertiesUtils.loadFromClasspath("kr/pe/kwonnam/hibernate4memcached/util/normal.properties"); assertThat(properties).hasSize(1); assertThat(properties.getProperty("normal.key")).isEqualTo("normal properties value"); }
@Test public void loadFromClasspath_xml_properteis() throws Exception { Properties properties = PropertiesUtils.loadFromClasspath("kr/pe/kwonnam/hibernate4memcached/util/xml_properties.xml"); assertThat(properties).hasSize(1); assertThat(properties.getProperty("xml.key")).isEqualTo("xml properties value"); }
@Test public void loadFromClasspath_illegal_resourcePath() throws Exception { expectedException.expect(IllegalStateException.class); expectedException.expectMessage(containsString("You might set illegal resource path. Leading slash(/) is not allowed.")); PropertiesUtils.loadFromClasspath("/kr/something/not/exists/class/path/some.properties"); }