public default void putSection(String section, final Map<String, String> kvp) { checkNotNull(section); checkNotNull(kvp); kvp.forEach((k, v) -> { checkNotNull(k); checkNotNull(v); put(String.format("%s.%s", section, k), v); }); }
@Override public void configure() throws RepositoryConnectionException { RepositoryConnectionException.StorageType.OBJECT.configure(config, "mongodb", "0.1"); String uri = config.get("mongodb.uri").or(config.getGlobal("mongodb.uri")) .or("mongodb://localhost:27017/"); String database = config.get("mongodb.database").or(config.getGlobal("mongodb.database")) .or("geogig"); config.put("mongodb.uri", uri); config.put("mongodb.database", database); }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. injector.configDatabase().put("user.name", "groldan"); injector.configDatabase().put("user.email", "groldan@boundlessgeo.com"); }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. injector.configDatabase().put("user.name", "groldan"); injector.configDatabase().put("user.email", "groldan@boundlessgeo.com"); }
@Test public void testNullValue() { config.put("section.null", null); Optional<String> str = config.get("section.null"); assertFalse(str.isPresent()); }
@Test public void testNumberFormatException() { config.put("section.string", "notanumber"); exception.expect(IllegalArgumentException.class); config.get("section.string", Integer.class); }
@Test public void testNumberFormatException() { config.put("section.string", "notanumber"); exception.expect(IllegalArgumentException.class); config.get("section.string", Integer.class); }
@Test public void testNoRepository() { tempFolder.delete(); exception.expect(ConfigException.class); config.put("section.int", 1); }
@Test public void testConfiguredName() throws Exception { final String configRepoName = "myConfiguredRepoName"; getRepository().configDatabase().put("repo.name", configRepoName); String repoName = geogig.command(ResolveRepositoryName.class).call(); assertEquals(configRepoName, repoName); }
@Test public void testGlobalOnly() { ConfigDatabase globalOnly = IniFileConfigDatabase.globalOnly(platform); testGlobalOnly(() -> globalOnly.get("section.key")); testGlobalOnly(() -> globalOnly.getAll()); testGlobalOnly(() -> globalOnly.get("section.key", String.class)); testGlobalOnly(() -> globalOnly.getAllSection("section")); testGlobalOnly(() -> globalOnly.getAllSubsections("section.sub")); testGlobalOnly(() -> globalOnly.put("section.key", "val")); testGlobalOnly(() -> globalOnly.remove("section.key")); testGlobalOnly(() -> globalOnly.removeSection("section")); }