io.smallrye.config.PropertiesConfigSource Java Examples

The following examples show how to use io.smallrye.config.PropertiesConfigSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigProfileTestCase.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Test
public void testBackwardCompatibleOrdinalProfile() {
    System.setProperty("quarkus-profile", "foo");
    try {
        final SmallRyeConfigBuilder builder = new SmallRyeConfigBuilder();
        builder.withInterceptors(new QuarkusProfileConfigSourceInterceptor(ProfileManager.getActiveProfile()));
        builder.withSources(new PropertiesConfigSource(new HashMap<String, String>() {
            {
                put("foo", "default");
            }
        }, "source", Integer.MAX_VALUE));
        builder.withSources(new PropertiesConfigSource(new HashMap<String, String>() {
            {
                put("%foo.foo", "profile");
            }
        }, "source", Integer.MIN_VALUE));
        final SmallRyeConfig config = builder.build();
        cpr.registerConfig(config, classLoader);

        assertEquals("profile", config.getValue("foo", String.class));
    } finally {
        System.clearProperty("quarkus-profile");
    }
}
 
Example #2
Source File: ApplicationRuntimeConfigSourceProvider.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) {
    final Properties applicationProperties = PropertiesSupport.loadProperties();
    final Properties quarkusProperties = new Properties();

    for (String name : applicationProperties.stringPropertyNames()) {
        if (name.startsWith("quarkus.")) {
            quarkusProperties.put(name, applicationProperties.get(name));
        }
    }

    return Collections.singletonList(
        new PropertiesConfigSource(quarkusProperties, "camel-k")
    );
}
 
Example #3
Source File: InjectionTestConfigFactory.java    From smallrye-config with Apache License 2.0 5 votes vote down vote up
@Override
public SmallRyeConfig getConfigFor(
        final SmallRyeConfigProviderResolver configProviderResolver, final ClassLoader classLoader) {
    return configProviderResolver.getBuilder().forClassLoader(classLoader)
            .addDefaultSources()
            .withSources(new PropertiesConfigSource(new HashMap<String, String>() {
                {
                    put("testkey", "testvalue");
                }
            }, "memory", 0))
            .addDefaultInterceptors()
            .build();
}
 
Example #4
Source File: ConfigExpanderTestCase.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private SmallRyeConfig buildConfig(Map<String, String> configMap) {
    final SmallRyeConfigBuilder builder = new SmallRyeConfigBuilder();
    builder.withInterceptors(new ExpressionConfigSourceInterceptor());
    builder.withSources(new PropertiesConfigSource(configMap, "test input", 500));
    final SmallRyeConfig config = (SmallRyeConfig) builder.build();
    cpr.registerConfig(config, classLoader);
    this.config = config;
    return config;
}
 
Example #5
Source File: ConfigProfileTestCase.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private SmallRyeConfig buildConfig(Map<String, String> configMap) {
    final SmallRyeConfigBuilder builder = new SmallRyeConfigBuilder();
    builder.withInterceptors(new QuarkusProfileConfigSourceInterceptor(ProfileManager.getActiveProfile()));
    builder.withSources(new PropertiesConfigSource(configMap, "test input", 500));
    final SmallRyeConfig config = (SmallRyeConfig) builder.build();
    cpr.registerConfig(config, classLoader);
    this.config = config;
    return config;
}
 
Example #6
Source File: TestUtils.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
static Config config(Map<String, String> map) {
    return new SmallRyeConfigBuilder()
            .withSources(new PropertiesConfigSource(map, "", 0)).build();
}