@Test public void test() throws Exception { try { provider.open(null); Assert.fail(); } catch (Exception e) { Assert.assertTrue(e.getMessage() .contains( "Null or blank configuration file reference not allowed")); } try { provider.open("fu.bar"); Assert.fail(); } catch (Exception e) { Assert.assertTrue(e.getMessage() .contains("fu.bar")); } String config = IOUtils.toString(provider.open("src/main/resources/moneta-config.yaml")); Assert.assertTrue(config.contains("console")); config = IOUtils.toString(provider.open("/moneta-config.yaml")); Assert.assertTrue(config.contains("console")); }
public InputStream open(String path) throws IOException { Validate.notBlank(path, "Null or blank configuration file reference not allowed"); InputStream configStream = MonetaConfigurationSourceProvider.class.getResourceAsStream(path); if (configStream == null) { final File file = new File(path); if (!file.exists()) { throw new MonetaException( "configuration not found in the classpath or as file").addContextValue( "configuration yaml", path); } configStream = new FileInputStream(file); } return configStream; }
MonetaConfigurationSourceProvider implements
ConfigurationSourceProvider { public InputStream open(String path) throws IOException { Validate.notBlank(path, "Null or blank configuration file reference not allowed"); InputStream configStream = MonetaConfigurationSourceProvider.class.getResourceAsStream(path); if (configStream == null) { final File file = new File(path); if (!file.exists()) { throw new MonetaException( "configuration not found in the classpath or as file").addContextValue( "configuration yaml", path); } configStream = new FileInputStream(file); } return configStream; } }
MonetaConfigurationSourceProvider implements
ConfigurationSourceProvider { public InputStream open(String path) throws IOException { Validate.notBlank(path, "Null or blank configuration file reference not allowed"); InputStream configStream = MonetaConfigurationSourceProvider.class.getResourceAsStream(path); if (configStream == null) { final File file = new File(path); if (!file.exists()) { throw new MonetaException( "configuration not found in the classpath or as file").addContextValue( "configuration yaml", path); } configStream = new FileInputStream(file); } return configStream; }  }
MonetaConfigurationSourceProvider implements
ConfigurationSourceProvider { public InputStream open(String path) throws IOException { Validate.notBlank(path, "Null or blank configuration file reference not allowed"); InputStream configStream = MonetaConfigurationSourceProvider.class.getResourceAsStream(path); if (configStream == null) { final File file = new File(path); if (!file.exists()) { throw new MonetaException( "configuration not found in the classpath or as file").addContextValue( "configuration yaml", path); } configStream = new FileInputStream(file); } return configStream; }  InputStream open(String path); }
MonetaConfigurationSourceProvider implements
ConfigurationSourceProvider { public InputStream open(String path) throws IOException { Validate.notBlank(path, "Null or blank configuration file reference not allowed"); InputStream configStream = MonetaConfigurationSourceProvider.class.getResourceAsStream(path); if (configStream == null) { final File file = new File(path); if (!file.exists()) { throw new MonetaException( "configuration not found in the classpath or as file").addContextValue( "configuration yaml", path); } configStream = new FileInputStream(file); } return configStream; }  InputStream open(String path);  }