Resources { public static Properties getResourceAsProperties(String resource) throws IOException { Properties props = new Properties(); InputStream in = getResourceAsStream(resource); props.load(in); in.close(); return props; } Resources(); static ClassLoader getDefaultClassLoader(); static void setDefaultClassLoader(ClassLoader defaultClassLoader); static URL getResourceURL(String resource); static URL getResourceURL(ClassLoader loader, String resource); static InputStream getResourceAsStream(String resource); static InputStream getResourceAsStream(ClassLoader loader, String resource); static Properties getResourceAsProperties(String resource); static Properties getResourceAsProperties(ClassLoader loader, String resource); static Reader getResourceAsReader(String resource); static Reader getResourceAsReader(ClassLoader loader, String resource); static File getResourceAsFile(String resource); static File getResourceAsFile(ClassLoader loader, String resource); static InputStream getUrlAsStream(String urlString); static Reader getUrlAsReader(String urlString); static Properties getUrlAsProperties(String urlString); static Class<?> classForName(String className); static Charset getCharset(); static void setCharset(Charset charset);  }
@Test public void shouldGetResourceAsProperties() throws Exception { Properties props = Resources.getResourceAsProperties(CLASS_LOADER, JPETSTORE_PROPERTIES); assertNotNull(props.getProperty("driver")); }
@Test public void shouldGetResourceAsPropertiesWithOutClassloader() throws Exception { Properties file = Resources.getResourceAsProperties(JPETSTORE_PROPERTIES); assertNotNull(file); }
@Test public void shouldGetResourceAsPropertiesWithClassloader() throws Exception { Properties file = Resources.getResourceAsProperties(CLASS_LOADER, JPETSTORE_PROPERTIES); assertNotNull(file); }