Search in sources :

Example 1 with SmallRyeConfig

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

the class ConfigurationTest method testResolveHealthOption.

public void testResolveHealthOption() {
    System.setProperty(CLI_ARGS, "--health-enabled=true");
    SmallRyeConfig config = createConfig();
    assertEquals("true", config.getConfigValue("quarkus.datasource.health.enabled").getValue());
}
Also used : SmallRyeConfig(io.smallrye.config.SmallRyeConfig)

Example 2 with SmallRyeConfig

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

the class ConfigurationTest method testDatabaseProperties.

@Test
public void testDatabaseProperties() {
    System.setProperty("kc.db-url-properties", ";;test=test;test1=test1");
    System.setProperty("kc.db-url-path", "test-dir");
    System.setProperty(CLI_ARGS, "--db=dev-file");
    SmallRyeConfig config = createConfig();
    assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals("jdbc:h2:file:test-dir" + File.separator + "data" + File.separator + "h2" + File.separator + "keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
    assertEquals("xa", config.getConfigValue("quarkus.datasource.jdbc.transactions").getValue());
    System.setProperty(CLI_ARGS, "");
    config = createConfig();
    assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals("jdbc:h2:file:test-dir" + File.separator + "data" + File.separator + "h2" + File.separator + "keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
    System.setProperty("kc.db-url-properties", "?test=test&test1=test1");
    System.setProperty(CLI_ARGS, "--db=mariadb");
    config = createConfig();
    assertEquals("jdbc:mariadb://localhost/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
    assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals(MySQLDataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
    System.setProperty(CLI_ARGS, "--db=postgres");
    config = createConfig();
    assertEquals("jdbc:postgresql://localhost/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
    assertEquals(QuarkusPostgreSQL10Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals(PGXADataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
    System.setProperty(CLI_ARGS, "--db-schema=test-schema");
    config = createConfig();
    assertEquals("test-schema", config.getConfigValue("kc.db-schema").getValue());
    assertEquals("test-schema", config.getConfigValue("quarkus.hibernate-orm.database.default-schema").getValue());
}
Also used : MariaDBDialect(org.hibernate.dialect.MariaDBDialect) QuarkusH2Dialect(io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect) SmallRyeConfig(io.smallrye.config.SmallRyeConfig) MySQLDataSource(org.mariadb.jdbc.MySQLDataSource) QuarkusPostgreSQL10Dialect(io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect) PGXADataSource(org.postgresql.xa.PGXADataSource) Test(org.junit.Test)

Example 3 with SmallRyeConfig

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

the class ConfigurationTest method testDatabaseKindProperties.

@Test
public void testDatabaseKindProperties() {
    System.setProperty(CLI_ARGS, "--db=postgres" + ARG_SEPARATOR + "--db-url=jdbc:postgresql://localhost/keycloak");
    SmallRyeConfig config = createConfig();
    assertEquals("io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect", config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals("jdbc:postgresql://localhost/keycloak", 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)

Example 4 with SmallRyeConfig

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

the class ConfigurationTest method testTransactionTypeChangesDriver.

@Test
public void testTransactionTypeChangesDriver() {
    System.setProperty(CLI_ARGS, "--db=mssql" + ARG_SEPARATOR + "--transaction-xa-enabled=false");
    assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
    SmallRyeConfig config = createConfig();
    assertEquals("com.microsoft.sqlserver.jdbc.SQLServerDriver", config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
    assertEquals("enabled", config.getConfigValue("quarkus.datasource.jdbc.transactions").getValue());
    System.setProperty(CLI_ARGS, "--db=mssql" + ARG_SEPARATOR + "--transaction-xa-enabled=true");
    assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
    SmallRyeConfig config2 = createConfig();
    assertEquals("com.microsoft.sqlserver.jdbc.SQLServerXADataSource", config2.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
    assertEquals("xa", config2.getConfigValue("quarkus.datasource.jdbc.transactions").getValue());
}
Also used : SmallRyeConfig(io.smallrye.config.SmallRyeConfig) Test(org.junit.Test)

Example 5 with SmallRyeConfig

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

the class ConfigurationTest method testPropertyMapping.

@Test
public void testPropertyMapping() {
    System.setProperty(CLI_ARGS, "--db=mariadb" + ARG_SEPARATOR + "--db-url=jdbc:mariadb://localhost/keycloak");
    SmallRyeConfig config = createConfig();
    assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
    assertEquals("jdbc:mariadb://localhost/keycloak", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
}
Also used : MariaDBDialect(org.hibernate.dialect.MariaDBDialect) 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