Search in sources :

Example 21 with Config

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

the class GenericConfigMapperTest method testWithDefault.

@Test
public void testWithDefault() {
    Config config = Config.builder().sources(ConfigSources.create(prepareConfigApp(// uid
    false, // greeting
    true, // PAGESIZE
    false, // basicRange
    true, // logging
    true, // security
    true, // names
    true).build())).disableEnvironmentVariablesSource().disableSystemPropertiesSource().build();
    print(config);
    AppConfig appConfig = config.get("app").as(AppConfig.class).get();
    assertThat(appConfig.getPageSize(), is(10));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 22 with Config

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

the class GenericConfigMapperTest method testWrongDefaultsNotUsed.

@Test
public void testWrongDefaultsNotUsed() {
    Config config = Config.builder(ConfigSources.create(Map.of("numberWithDefault", "23", "numberWithDefaultSupplier", "42"))).disableEnvironmentVariablesSource().disableSystemPropertiesSource().build();
    WrongDefaultBean wrongDefaultBean = config.as(WrongDefaultBean.class).get();
    assertThat(wrongDefaultBean.numberWithDefault, is(23));
    assertThat(wrongDefaultBean.numberWithDefaultSupplier, is(42));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 23 with Config

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

the class GenericConfigMapperTest method testTransient.

@Test
public void testTransient() {
    Config config = Config.builder().sources(ConfigSources.create(prepareConfigApp(// UID
    true, // greeting
    true, // pageSize
    true, // basicRange
    true, // logging
    true, // security
    true, // names
    true).build())).disableEnvironmentVariablesSource().disableSystemPropertiesSource().build();
    print(config);
    assertThat(config.get("app.uid").type(), is(Type.VALUE));
    assertThat(config.get("app.security.providers.0.uid").type(), is(Type.VALUE));
    assertThat(config.get("app.security.providers.1.uid").type(), is(Type.VALUE));
    AppConfig appConfig = config.get("app").as(AppConfig.class).get();
    assertThat(appConfig.getUid(), is(nullValue()));
    assertThat(appConfig.getSecurity().getProviders().get(0).getUid(), is(nullValue()));
    assertThat(appConfig.getSecurity().getProviders().get(1).getUid(), is(nullValue()));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 24 with Config

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

the class CustomParserPrecedenceTest method testCustomParserOverride.

@Test
public void testCustomParserOverride() {
    Config config = configBuilder().build();
    assertThat(config.get(Parsers1Priority100ConfigParser.KEY_PREFIX + KEY).asString(), is(ConfigValues.simpleValue(VALUE)));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 25 with Config

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

the class ConfigCreateDefaultFromEnvVarsTest method testCreate.

@Test
@ExtendWith(RestoreSystemPropertiesExt.class)
public void testCreate() {
    Config config = Config.create();
    assertThat(config.get(KEY).asString(), is(simpleValue(ENV_VALUE)));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith)

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