Configuration { public FileLocation getFileLocationOfShared(String relativePath) { String rootPath; rootPath = System.getProperty(PROP_SHARED_DIR); if (rootPath == null) { rootPath = props.get(PROP_SHARED_DIR); } if (rootPath == null) { rootPath = System.getenv(ENV_SHARED_DIR); } requireNonNull(rootPath, format("Property '%s' or environment variable '%s' is missing", PROP_SHARED_DIR, ENV_SHARED_DIR)); File rootDir = new File(rootPath); checkState(rootDir.isDirectory() && rootDir.exists(), "Please check the definition of it_sources (%s or %s) because the directory does not exist: %s", PROP_SHARED_DIR, ENV_SHARED_DIR, rootDir); return FileLocation.of(new File(rootDir, relativePath)); } private  Configuration(File homeDir, Map<String, String> props); FileSystem fileSystem(); Locators locators(); FileLocation getFileLocationOfShared(String relativePath); String getString(String key); String getString(String key, @Nullable String defaultValue); @CheckForNull String getStringByKeys(String... keys); @CheckForNull String getStringByKeys(Predicate<String> validator, String... keys); int getInt(String key, int defaultValue); Map<String, String> asMap(); static Configuration createEnv(); static Configuration create(Properties properties); static Configuration create(Map<String, String> properties); static Configuration create(); static Builder builder();  }
@Test public void getFileLocationOfShared() throws URISyntaxException { URL url = getClass().getResource("/com/sonar/orchestrator/config/ConfigurationTest/sample.properties"); Properties props = new Properties(); props.setProperty("orchestrator.configUrl", url.toString()); props.setProperty("orchestrator.it_sources", FilenameUtils.getFullPath(url.toURI().getPath())); Configuration config = Configuration.create(props); FileLocation location = config.getFileLocationOfShared("sample.properties"); assertThat(location.getFile()).isFile(); assertThat(location.getFile()).exists(); assertThat(location.getFile().getName()).isEqualTo("sample.properties"); }