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)));
}
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");
}
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);
}
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));
}
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)));
}
Aggregations