Search in sources :

Example 66 with Config

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

the class ConfigurationTest method configValuesTest.

/**
 * Test if simple configuration values are applied. This test does not check all
 * values
 */
@Test
void configValuesTest() {
    Map<String, String> source = Map.of("cache.management-enabled", "true", "cache.statistics-enabled", "true", "cache.store-by-value", "true");
    Config config = Config.builder().addSource(ConfigSources.create(source).build()).build();
    CacheConfiguration<Long, String> cacheConfig = MicrostreamCacheConfigurationBuilder.builder(config.get("cache"), Long.class, String.class).build();
    assertAll(() -> assertThat("getKeyType", cacheConfig.getKeyType(), typeCompatibleWith(Long.class)), () -> assertThat("getValueType", cacheConfig.getValueType(), typeCompatibleWith(String.class)), () -> assertThat("isManagementEnabled", cacheConfig.isManagementEnabled(), is(true)), () -> assertThat("isStatisticsEnabled", cacheConfig.isStatisticsEnabled(), is(true)), () -> assertThat("isStoreByValue", cacheConfig.isStoreByValue(), is(true)));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 67 with Config

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

the class MetricsSupportTest method testBaseMetricsDisabled.

@Test
void testBaseMetricsDisabled() {
    Config config = Config.builder().sources(ConfigSources.create(Map.of("base.enabled", "false"))).build();
    RegistryFactory myRF = (RegistryFactory) io.helidon.metrics.api.RegistryFactory.create(config);
    Registry myBase = myRF.getARegistry(MetricRegistry.Type.BASE);
    assertFalse(myBase.getGauges().containsKey(METRIC_USED_HEAP), "Base registry incorrectly contains " + METRIC_USED_HEAP + " when base was configured as disabled");
}
Also used : Config(io.helidon.config.Config) MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) Test(org.junit.jupiter.api.Test)

Example 68 with Config

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

the class RegistryFactoryTest method createInstance.

@BeforeAll
static void createInstance() {
    unconfigured = RegistryFactory.create();
    Config config = Config.builder().sources(ConfigSources.create(Map.of("base." + METRIC_USED_HEAP.getName() + ".enabled", "false"))).build();
    configured = RegistryFactory.create(config);
    baseUn = unconfigured.getRegistry(MetricRegistry.Type.BASE);
    appUn = unconfigured.getRegistry(MetricRegistry.Type.APPLICATION);
    vendorUn = unconfigured.getRegistry(MetricRegistry.Type.VENDOR);
    base = configured.getRegistry(MetricRegistry.Type.BASE);
    app = configured.getRegistry(MetricRegistry.Type.APPLICATION);
    vendor = configured.getRegistry(MetricRegistry.Type.VENDOR);
    vendorMod = ((io.helidon.metrics.RegistryFactory) configured).getARegistry(MetricRegistry.Type.VENDOR);
}
Also used : Config(io.helidon.config.Config) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 69 with Config

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

the class TestRegistrySettings method testMultipleValidConfig.

@Test
void testMultipleValidConfig() {
    Map<String, String> configMap = Map.of("filter.include", "mine\\..*|yours\\..*");
    Config config = Config.just(ConfigSources.create(configMap));
    RegistrySettings mts = RegistrySettings.builder().config(config).build();
    assertThat("Overall metrics for application enabled", mts.isEnabled(), is(true));
    assertThat("Specific metric 'should.fail' enabled with prefix 'mine.'", mts.isMetricEnabled("should.fail"), is(false));
    assertThat("Specific metric 'mine.should.work' enabled with prefix 'mine.'", mts.isMetricEnabled("mine.should.work"), is(true));
    assertThat("Specific metric 'yours.should.work' enabled with prefix 'yours.'", mts.isMetricEnabled("yours.should.work"), is(true));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 70 with Config

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

the class TestSystemTagsManager method checkForAppTag.

@Test
void checkForAppTag() {
    Config metricsConfig = Config.just(ConfigSources.create(APP_ONLY_TAGS_SETTINGS)).get("metrics");
    MetricsSettings metricsSettings = MetricsSettings.create(metricsConfig);
    SystemTagsManager mgr = SystemTagsManager.create(metricsSettings);
    MetricID metricID = new MetricID("my-metric", new Tag(METRIC_TAG_NAME, METRIC_TAG_VALUE));
    Map<String, String> fullTags = new HashMap<>();
    mgr.allTags(metricID).forEach(entry -> fullTags.put(entry.getKey(), entry.getValue()));
    assertThat("Global tags derived from tagless metric ID", fullTags, allOf(not(hasEntry(GLOBAL_TAG_1, GLOBAL_VALUE_1)), not(hasEntry(GLOBAL_TAG_2, GLOBAL_VALUE_2)), hasEntry(METRIC_TAG_NAME, METRIC_TAG_VALUE), hasKey(SystemTagsManager.APP_TAG)));
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) HashMap(java.util.HashMap) Config(io.helidon.config.Config) Tag(org.eclipse.microprofile.metrics.Tag) 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