io.vertx.config.ConfigRetriever Java Examples

The following examples show how to use io.vertx.config.ConfigRetriever. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VaultConfigStoreTestBase.java    From vertx-config with Apache License 2.0 7 votes vote down vote up
/**
 * Tests the access to secret data encoded as properties with KV-v1 engine.
 */
@Test
public void testAccessToNestedContentAsPropertiesFromSecretV1(TestContext tc) {
  JsonObject additionalConfig = getRetrieverConfiguration();
  JsonObject config = additionalConfig.copy().put("path", "secret/app/foo").put("key", "props");

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
    .addStore(new ConfigStoreOptions().setType("vault")
      .setFormat("properties")
      .setConfig(config)));

  Async async = tc.async();

  retriever.getConfig(json -> {
    tc.assertTrue(json.succeeded());
    JsonObject content = json.result();
    tc.assertEquals(content.getString("key"), "val");
    tc.assertEquals(content.getInteger("key2"), 5);
    async.complete();
  });
}
 
Example #2
Source File: VaultConfigStoreTestBase.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the access to a secret with KV-v1 engine.
 */
@Test
public void testAccessToSecretV1(TestContext tc) {
  JsonObject additionalConfig = getRetrieverConfiguration();
  JsonObject config = additionalConfig.copy().put("path", "secret/app/foo");

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
    .addStore(new ConfigStoreOptions().setType("vault").setConfig(config)));

  Async async = tc.async();

  retriever.getConfig(json -> {
    tc.assertTrue(json.succeeded());
    JsonObject content = json.result();
    tc.assertEquals("hello", content.getString("message"));
    tc.assertEquals(10, content.getInteger("counter"));

    async.complete();
  });
}
 
Example #3
Source File: RawProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithBrokenJson(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions()
          .addStore(
              new ConfigStoreOptions()
                  .setType("file")
                  .setFormat("raw")
                  .setConfig(
                      new JsonObject()
                          .put("path", "src/test/resources/raw/username")
                          .put("raw.type", "json-object")
                          .put("raw.key", "some-json")))
  );

  retriever.getConfig(ar -> {
    assertThat(ar.failed());
    assertThat(ar.cause())
      .isInstanceOf(DecodeException.class)
      .hasRootCauseInstanceOf(JsonParseException.class);
    async.complete();
  });
}
 
Example #4
Source File: HoconProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimplePropertiesConfiguration(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("hocon")
              .setConfig(new JsonObject().put("path", "src/test/resources/regular.properties"))));

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    JsonObject json = ar.result();
    assertThat(json.getString("key")).isEqualTo("value");

    assertThat(json.getBoolean("true")).isTrue();
    assertThat(json.getBoolean("false")).isFalse();

    assertThat(json.getString("missing")).isNull();

    assertThat(json.getInteger("int")).isEqualTo(5);
    assertThat(json.getDouble("float")).isEqualTo(25.3);

    async.complete();
  });
}
 
Example #5
Source File: VaultConfigStoreTestBase.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
/**
 * Tests accessing a specific key from a missing secret.
 */
@Test
public void testRetrievingAKeyFromAMissingSecret(TestContext tc) {
  JsonObject additionalConfig = getRetrieverConfiguration();
  JsonObject config = additionalConfig.copy()
    .put("path", "secret/app/missing").put("key", "missing");

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
    .addStore(new ConfigStoreOptions().setType("vault")
      .setConfig(config)));

  Async async = tc.async();

  retriever.getConfig(json -> {
    tc.assertTrue(json.succeeded());
    tc.assertTrue(json.result().isEmpty());
    async.complete();
  });
}
 
Example #6
Source File: HoconProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithTextFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("hocon")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-text.txt"))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(ConfigException.class);
    async.complete();
  });
}
 
Example #7
Source File: HoconProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyHocon(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("hocon")
              .setConfig(new JsonObject().put("path", "src/test/resources/empty.conf"))));

  retriever.getConfig(ar -> {
    assertThat(ar.result()).isNotNull();
    assertThat(ar.result()).isEmpty();
    async.complete();
  });
}
 
Example #8
Source File: VaultConfigStoreTestBase.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the access to a specific key of a secret in KV-v2 engine.
 */
@Test
public void testAccessToNestedContentFromSecretV2(TestContext tc) {
  JsonObject additionalConfig = getRetrieverConfiguration();
  JsonObject config = additionalConfig.copy()
    .put("path", "secret-v2/data/app/foo").put("key", "nested");

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
    .addStore(new ConfigStoreOptions().setType("vault")
      .setConfig(config)));

  Async async = tc.async();

  retriever.getConfig(json -> {
    if (json.failed()) {
      json.cause().printStackTrace();
    }
    tc.assertTrue(json.succeeded());
    JsonObject content = json.result();
    tc.assertEquals(content.getString("foo"), "bar");
    async.complete();
  });
}
 
Example #9
Source File: EnvVariablesConfigStoreWithMockEnvTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadingFromEnvWithoutRawData() {
  retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions()
      .addStore(new ConfigStoreOptions().setType("env"))
  );

  AtomicBoolean done = new AtomicBoolean();

  env.set("name", "12345678901234567891");

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    // Converted value, totally wrong ;-)
    assertThat(ar.result().getInteger("name")).isEqualTo(2147483647);
    done.set(true);
  });
  await().untilAtomic(done, is(true));
}
 
Example #10
Source File: ConfigExamples.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
public void propsWitHierarchicalStructure() {
  ConfigStoreOptions propertyWitHierarchical = new ConfigStoreOptions()
    .setFormat("properties")
    .setType("file")
    .setConfig(new JsonObject().put("path", "hierarchical.properties").put("hierarchical", true)
    );
  ConfigRetrieverOptions options = new ConfigRetrieverOptions()
    .addStore(propertyWitHierarchical);

  ConfigRetriever configRetriever = ConfigRetriever.create(Vertx.vertx(), options);

  configRetriever.configStream().handler(config -> {
    String host = config.getJsonObject("server").getString("host");
    Integer port = config.getJsonObject("server").getInteger("port");
    JsonArray multiple = config.getJsonObject("multiple").getJsonArray("values");
    for (int i = 0; i < multiple.size(); i++) {
      Integer value = multiple.getInteger(i);
    }
  });
}
 
Example #11
Source File: ConfigExamples.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
public void period(ConfigStoreOptions store1, ConfigStoreOptions store2) {
  ConfigRetrieverOptions options = new ConfigRetrieverOptions()
    .setScanPeriod(2000)
    .addStore(store1)
    .addStore(store2);

  ConfigRetriever retriever = ConfigRetriever.create(Vertx.vertx(), options);
  retriever.getConfig(json -> {
    // Initial retrieval of the configuration
  });

  retriever.listen(change -> {
    // Previous configuration
    JsonObject previous = change.getPreviousConfiguration();
    // New configuration
    JsonObject conf = change.getNewConfiguration();
  });
}
 
Example #12
Source File: ConfigExamples.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
public void stream(ConfigStoreOptions store1, ConfigStoreOptions store2) {
  ConfigRetrieverOptions options = new ConfigRetrieverOptions()
    .setScanPeriod(2000)
    .addStore(store1)
    .addStore(store2);

  ConfigRetriever retriever = ConfigRetriever.create(Vertx.vertx(), options);
  retriever.configStream()
    .endHandler(v -> {
      // retriever closed
    })
    .exceptionHandler(t -> {
      // an error has been caught while retrieving the configuration
    })
    .handler(conf -> {
      // the configuration
    });

}
 
Example #13
Source File: VaultConfigStoreTestBase.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
/**
 * Tests accessing a missing key from an existing secret.
 */
@Test
public void testRetrievingAMissingKey(TestContext tc) {
  JsonObject additionalConfig = getRetrieverConfiguration();
  JsonObject config = additionalConfig.copy()
    .put("path", "secret/app/foo").put("key", "missing");

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
    .addStore(new ConfigStoreOptions().setType("vault")
      .setConfig(config)));

  Async async = tc.async();

  retriever.getConfig(json -> {
    tc.assertTrue(json.succeeded());
    tc.assertTrue(json.result().isEmpty());
    async.complete();
  });
}
 
Example #14
Source File: DirectoryConfigStoreTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithAFileSetMatching2FilesWithoutConflict(TestContext context) {
  Async async = context.async();
  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
      .addStore(new ConfigStoreOptions()
          .setType("directory")
          .setConfig(new JsonObject().put("path", "src/test/resources")
              .put("filesets", new JsonArray()
                  .add(new JsonObject().put("pattern", "dir/a?.json"))
              ))));
  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("b.name")).isNull();
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    assertThat(ar.result().getString("c.name")).isEqualTo("C");
    assertThat(ar.result().getString("conflict")).isEqualTo("A");
    async.complete();
  });
}
 
Example #15
Source File: DirectoryConfigStoreTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithAFileSetMatching2FilesWithConflict(TestContext context) {
  Async async = context.async();
  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions()
      .addStore(new ConfigStoreOptions()
          .setType("directory")
          .setConfig(new JsonObject().put("path", "src/test/resources")
              .put("filesets", new JsonArray()
                  .add(new JsonObject().put("pattern", "dir/?.json"))
              ))));
  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("b.name")).isEqualTo("B");
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    // Alphabetical order, so B is last.
    assertThat(ar.result().getString("conflict")).isEqualTo("B");
    async.complete();
  });
}
 
Example #16
Source File: RawProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithBinary(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions()
          .addStore(
              new ConfigStoreOptions()
                  .setType("file")
                  .setFormat("raw")
                  .setConfig(
                      new JsonObject()
                          .put("path", "src/test/resources/raw/logo-white-big.png")
                          .put("raw.type", "binary")
                          .put("raw.key", "logo")))
  );

  retriever.getConfig(ar -> {
    assertThat(ar.result()).isNotNull().isNotEmpty();
    assertThat(ar.result().getBinary("logo")).isNotEmpty();
    async.complete();
  });
}
 
Example #17
Source File: RawProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithMissingKey(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions()
          .addStore(
              new ConfigStoreOptions()
                  .setType("file")
                  .setFormat("raw")
                  .setConfig(
                      new JsonObject()
                          .put("path", "src/test/resources/raw/logo-white-big.png")
                          .put("raw.type", "binary")))
  );

  retriever.getConfig(ar -> {
    assertThat(ar.failed());
    assertThat(ar.cause().getMessage()).contains("raw.key");
    async.complete();
  });
}
 
Example #18
Source File: YamlProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasicYamlFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/basic.yaml"))));

  retriever.getConfig(ar -> {
    expectSuccess(ar);
    JsonObject json = ar.result();
    assertThat(json.getInteger("invoice")).isEqualTo(34843);
    assertThat(json.getString("date")).isEqualTo("2001-01-23");
    JsonObject bill = json.getJsonObject("bill-to");
    assertThat(bill).contains(entry("given", "Chris"), entry("family", "Dumars"));
    assertThat(bill.getJsonObject("address")).isNotNull().isNotEmpty();
    JsonArray products = json.getJsonArray("product");
    assertThat(products).hasSize(2);
    assertThat(products.getJsonObject(0).getFloat("price")).isEqualTo(450.0f);
    assertThat(products.getJsonObject(1).getDouble("price")).isEqualTo(2392.0);
    assertThat(json.getString("comments")).contains("Late afternoon is best. Backup contact is Nancy Billsmer @");
    async.complete();
  });
}
 
Example #19
Source File: YamlProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithMissingFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-missing-file.yaml"))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(FileSystemException.class);
    async.complete();
  });
}
 
Example #20
Source File: YamlProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithTextFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-text.txt"))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(DecodeException.class);
    async.complete();
  });
}
 
Example #21
Source File: YamlProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyYaml(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/empty.yaml"))));

  retriever.getConfig(ar -> {
    expectSuccess(ar);
    assertThat(ar.result()).isNotNull();
    assertThat(ar.result()).isEmpty();
    async.complete();
  });
}
 
Example #22
Source File: ConfigVaultExamples.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
public void exampleWithUserPass(Vertx vertx, String username, String password) {
  JsonObject vault_config = new JsonObject();

  // ...

  vault_config
    .put("auth-backend", "userpass") // Set the auth-backend to userpass
    .put("user-credentials", new JsonObject()
      .put("username", username).put("password", password)
    );

  // Path to the secret to read.
  vault_config.put("path", "secret/my-secret");

  ConfigStoreOptions store = new ConfigStoreOptions()
    .setType("vault")
    .setConfig(vault_config);

  ConfigRetriever retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions().addStore(store));
}
 
Example #23
Source File: ConfigVaultExamples.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
public void exampleWithAppRole(Vertx vertx, String appRoleId, String secretId) {
  JsonObject vault_config = new JsonObject();

  // ...

  vault_config
    .put("auth-backend", "approle") // Set the auth-backend to approle
    .put("approle", new JsonObject()  // Configure the role id and secret it
      .put("role-id", appRoleId).put("secret-id", secretId)
    );

  // Path to the secret to read.
  vault_config.put("path", "secret/my-secret");

  ConfigStoreOptions store = new ConfigStoreOptions()
    .setType("vault")
    .setConfig(vault_config);

  ConfigRetriever retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions().addStore(store));
}
 
Example #24
Source File: GitConfigStoreTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDeepConfigMerge(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/b.json"), "dir");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
    ConfigStoreOptions().setType("git").setConfig(new JsonObject()
    .put("url", bareRoot.getAbsolutePath())
    .put("path", "target/junk/work")
    .put("filesets", new JsonArray()
      .add(new JsonObject().put("pattern", "dir/b.json"))
      .add(new JsonObject().put("pattern", "dir/a.*son"))
    ))));

  retriever.getConfig(ar -> {
    // Both level-3 objects must exist.
    assertThat(ar.result().getJsonObject("parent").getJsonObject("level_2").getString("key1")).isEqualTo("A");
    assertThat(ar.result().getJsonObject("parent").getJsonObject("level_2").getString("key2")).isEqualTo("B");
    async.complete();
  });

}
 
Example #25
Source File: GitConfigStoreTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWith2FileSetsAndWithIntersection(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/b.json"), "dir");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray()
          .add(new JsonObject().put("pattern", "dir/b.json"))
          .add(new JsonObject().put("pattern", "dir/a.*son"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    assertThat(ar.result().getString("b.name")).isEqualTo("B");
    assertThat(ar.result().getString("conflict")).isEqualTo("A");
    async.complete();
  });

}
 
Example #26
Source File: GitConfigStoreTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWith2FileSetsAndNoIntersection(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/regular.json"), "file");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray()
          .add(new JsonObject().put("pattern", "file/reg*.json"))
          .add(new JsonObject().put("pattern", "dir/a.*son"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("key")).isEqualTo("value");
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    async.complete();
  });

}
 
Example #27
Source File: EnvVariablesConfigStoreWithMockEnvTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadingFromEnvUsingRawData() {
  retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions()
      .addStore(new ConfigStoreOptions().setType("env").setConfig(new JsonObject().put("raw-data", true)))
  );

  AtomicBoolean done = new AtomicBoolean();

  env.set("name", "12345678901234567890");

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result().getString("PATH")).isNotNull();
    assertThat(ar.result().getString("name")).isEqualTo("12345678901234567890");
    done.set(true);
  });
  await().untilAtomic(done, is(true));
}
 
Example #28
Source File: GitConfigStoreTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithACustomBranch(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/a.json"), null);
  branch = "dev";
  add(git, root, new File("src/test/resources/files/regular.json"), null);
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("branch", branch)
      .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "*.json"))))));

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result()).isNotEmpty();
    JsonObject json = ar.result();
    assertThat(json).isNotNull();
    assertThat(json.getString("key")).isEqualTo("value");
    async.complete();
  });

}
 
Example #29
Source File: RawProcessorTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithJsonArray(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions()
          .addStore(
              new ConfigStoreOptions()
                  .setType("file")
                  .setFormat("raw")
                  .setConfig(
                      new JsonObject()
                          .put("path", "src/test/resources/raw/some-json-array.json")
                          .put("raw.type", "json-array")
                          .put("raw.key", "some-json")))
  );

  retriever.getConfig(ar -> {
    assertThat(ar.result()).isNotNull().isNotEmpty();
    assertThat(ar.result().getJsonArray("some-json").encode()).contains("1", "2", "3");
    async.complete();
  });
}
 
Example #30
Source File: GitConfigStoreTest.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyRepository(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/some-text.txt"), null);
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "**/*.json"))))));

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result()).isEmpty();
    async.complete();
  });

}