Search in sources :

Example 36 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class AbstractComplexConfigTest method testStringListDefault.

@Test
public void testStringListDefault() {
    Config node = getMissingConfig();
    List<String> defaultValue = Arrays.asList("def-1", "def-2", "def-3");
    String[] expected = defaultValue.toArray(new String[0]);
    assertThat(node.asList(String.class).orElse(defaultValue), contains(expected));
    assertThat(node.asList(aConfig -> aConfig.asString().get()).orElse(defaultValue), contains(expected));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 37 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class DemoTest method testUseAppConfigMapper.

@Test
public void testUseAppConfigMapper() {
    Config config = Config.builder().sources(ConfigSources.classpath("application.conf")).addParser(HoconConfigParser.create()).disableValueResolving().build();
    AppConfig appConfig = config.get("app").as(// MAP using provided Mapper
    new AppConfigMapper()).get();
    assertThat(appConfig.getGreeting(), is("Hello"));
    assertThat(appConfig.getName(), is("Demo"));
    assertThat(appConfig.getPageSize(), is(20));
    assertThat(appConfig.getBasicRange(), contains(-20, 20));
    assertThat(appConfig.isStorageEnabled(), is(false));
    assertThat(appConfig.getStoragePassphrase(), is("${AES=thisIsEncriptedPassphrase}"));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 38 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class DemoTest method testRegisterAppConfigMapper.

@Test
public void testRegisterAppConfigMapper() {
    Config config = Config.builder().sources(ConfigSources.classpath("application.conf")).addParser(HoconConfigParser.create()).addMapper(AppConfig.class, new AppConfigMapper()).disableValueResolving().build();
    AppConfig appConfig = config.get("app").as(// get AS type
    AppConfig.class).get();
    assertThat(appConfig.getGreeting(), is("Hello"));
    assertThat(appConfig.getName(), is("Demo"));
    assertThat(appConfig.getPageSize(), is(20));
    assertThat(appConfig.getBasicRange(), contains(-20, 20));
    assertThat(appConfig.isStorageEnabled(), is(false));
    assertThat(appConfig.getStoragePassphrase(), is("${AES=thisIsEncriptedPassphrase}"));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 39 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class DemoTest method testCreateConfig.

@Test
public void testCreateConfig() {
    // looks for: application .yaml | .conf | .json | .properties on classpath
    Config config = Config.create();
    assertThat(config.get("app.greeting").asString().get(), is("Hello"));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 40 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class DemoTest method testSecurityFilter.

@Test
public void testSecurityFilter() {
    Config config = Config.builder().sources(ConfigSources.classpath("application.conf")).addParser(HoconConfigParser.create()).addFilter(// custom config filter
    new SecurityConfigFilter()).disableValueResolving().build();
    assertThat(config.get("app.storagePassphrase").asString(), is(simpleValue("Password1.")));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Aggregations

Config (io.helidon.config.Config)329 Test (org.junit.jupiter.api.Test)169 LogConfig (io.helidon.common.LogConfig)56 WebServer (io.helidon.webserver.WebServer)54 Routing (io.helidon.webserver.Routing)51 BeforeAll (org.junit.jupiter.api.BeforeAll)24 Security (io.helidon.security.Security)20 HealthSupport (io.helidon.health.HealthSupport)18 Single (io.helidon.common.reactive.Single)17 MetricsSupport (io.helidon.metrics.MetricsSupport)16 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)16 ConfigSources (io.helidon.config.ConfigSources)15 JsonpSupport (io.helidon.media.jsonp.JsonpSupport)15 SecurityContext (io.helidon.security.SecurityContext)15 Optional (java.util.Optional)15 TimeUnit (java.util.concurrent.TimeUnit)15 WebSecurity (io.helidon.security.integration.webserver.WebSecurity)13 HealthChecks (io.helidon.health.checks.HealthChecks)12 WebClient (io.helidon.webclient.WebClient)12 GrpcRouting (io.helidon.grpc.server.GrpcRouting)11