Search in sources :

Example 11 with SmallRyeConfig

use of io.smallrye.config.SmallRyeConfig in project jqa-core-framework by buschmais.

the class ConfigurationLoaderImpl method load.

@Override
public Configuration load(File configurationDirectory, ConfigSource... configSources) {
    List<ConfigSource> yamlConfigSources = getYamlConfigSources(configurationDirectory);
    SmallRyeConfig config = new SmallRyeConfigBuilder().withMapping(Configuration.class).addDefaultSources().withSources(yamlConfigSources).withSources(configSources).withValidateUnknown(false).build();
    return config.getConfigMapping(Configuration.class);
}
Also used : ConfigSource(org.eclipse.microprofile.config.spi.ConfigSource) YamlConfigSource(io.smallrye.config.source.yaml.YamlConfigSource) SmallRyeConfigBuilder(io.smallrye.config.SmallRyeConfigBuilder) Configuration(com.buschmais.jqassistant.core.configuration.api.Configuration) SmallRyeConfig(io.smallrye.config.SmallRyeConfig)

Example 12 with SmallRyeConfig

use of io.smallrye.config.SmallRyeConfig in project keycloak by keycloak.

the class ConfigurationTest method testDatabaseUrlProperties.

@Test
public void testDatabaseUrlProperties() {
    System.setProperty(CLI_ARGS, "--db=mariadb" + ARG_SEPARATOR + "--db-url=jdbc:mariadb:aurora://foo/bar?a=1&b=2");
    SmallRyeConfig config = createConfig();
    assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals("jdbc:mariadb:aurora://foo/bar?a=1&b=2", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
}
Also used : MariaDBDialect(org.hibernate.dialect.MariaDBDialect) SmallRyeConfig(io.smallrye.config.SmallRyeConfig) Test(org.junit.Test)

Example 13 with SmallRyeConfig

use of io.smallrye.config.SmallRyeConfig in project keycloak by keycloak.

the class ConfigurationTest method testNestedDatabaseProperties.

// KEYCLOAK-15632
@Test
public void testNestedDatabaseProperties() {
    System.setProperty("kc.home.dir", "/tmp/kc/bin/../");
    SmallRyeConfig config = createConfig();
    assertEquals("jdbc:h2:file:/tmp/kc/bin/..//data/keycloakdb", config.getConfigValue("quarkus.datasource.foo").getValue());
    Assert.assertEquals("foo-def-suffix", config.getConfigValue("quarkus.datasource.bar").getValue());
    System.setProperty("kc.prop5", "val5");
    config = createConfig();
    Assert.assertEquals("foo-val5-suffix", config.getConfigValue("quarkus.datasource.bar").getValue());
    System.setProperty("kc.prop4", "val4");
    config = createConfig();
    Assert.assertEquals("foo-val4", config.getConfigValue("quarkus.datasource.bar").getValue());
    System.setProperty("kc.prop3", "val3");
    config = createConfig();
    Assert.assertEquals("foo-val3", config.getConfigValue("quarkus.datasource.bar").getValue());
}
Also used : SmallRyeConfig(io.smallrye.config.SmallRyeConfig) Test(org.junit.Test)

Example 14 with SmallRyeConfig

use of io.smallrye.config.SmallRyeConfig in project keycloak by keycloak.

the class ConfigurationTest method testResolveMetricsOption.

@Test
public void testResolveMetricsOption() {
    System.setProperty(CLI_ARGS, "--metrics-enabled=true");
    SmallRyeConfig config = createConfig();
    assertEquals("true", config.getConfigValue("quarkus.datasource.metrics.enabled").getValue());
}
Also used : SmallRyeConfig(io.smallrye.config.SmallRyeConfig) Test(org.junit.Test)

Example 15 with SmallRyeConfig

use of io.smallrye.config.SmallRyeConfig in project keycloak by keycloak.

the class ConfigurationTest method testDefaultDbPropertiesGetApplied.

@Test
public void testDefaultDbPropertiesGetApplied() {
    System.setProperty(CLI_ARGS, "--db=postgres" + ARG_SEPARATOR + "--db-url-host=myhost" + ARG_SEPARATOR + "--db-url-database=kcdb" + ARG_SEPARATOR + "--db-url-properties=?foo=bar");
    SmallRyeConfig config = createConfig();
    assertEquals("io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect", config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals("jdbc:postgresql://myhost/kcdb?foo=bar", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
    assertEquals("postgresql", config.getConfigValue("quarkus.datasource.db-kind").getValue());
}
Also used : SmallRyeConfig(io.smallrye.config.SmallRyeConfig) Test(org.junit.Test)

Aggregations

SmallRyeConfig (io.smallrye.config.SmallRyeConfig)19 Test (org.junit.Test)12 SmallRyeConfigBuilder (io.smallrye.config.SmallRyeConfigBuilder)4 MariaDBDialect (org.hibernate.dialect.MariaDBDialect)3 QuarkusH2Dialect (io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect)2 ConfigSource (org.eclipse.microprofile.config.spi.ConfigSource)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)1 BodyEvent (ch.qos.logback.core.joran.event.BodyEvent)1 SaxEvent (ch.qos.logback.core.joran.event.SaxEvent)1 StartEvent (ch.qos.logback.core.joran.event.StartEvent)1 Configuration (com.buschmais.jqassistant.core.configuration.api.Configuration)1 BodySub (io.quarkiverse.logback.runtime.events.BodySub)1 EventSubstitution (io.quarkiverse.logback.runtime.events.EventSubstitution)1 QuarkusPostgreSQL10Dialect (io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect)1 PropertiesConfigSource (io.smallrye.config.PropertiesConfigSource)1 YamlConfigSource (io.smallrye.config.source.yaml.YamlConfigSource)1 OpenApiConfigImpl (io.smallrye.openapi.api.OpenApiConfigImpl)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1