use of io.smallrye.config.PropertiesConfigSource in project jqa-core-framework by jQAssistant.
the class PropertiesConfigBuilderTest method properties.
@Test
void properties() {
propertiesConfigBuilder.with(PREFIX, "boolean-value", true);
Map<String, Object> map = MapBuilder.<String, Object>builder().entry("key.1", "value1").entry("key.2", "value2").build();
propertiesConfigBuilder.with(PREFIX, "map-value", map);
propertiesConfigBuilder.with(PREFIX, "list-value", asList("element0", "element1"));
PropertiesConfigSource propertiesConfigSource = propertiesConfigBuilder.build();
assertThat(propertiesConfigSource.getValue("jqassistant.test.boolean-value")).isEqualTo("true");
assertThat(propertiesConfigSource.getValue("jqassistant.test.map-value.\"key.1\"")).isEqualTo("value1");
assertThat(propertiesConfigSource.getValue("jqassistant.test.map-value.\"key.2\"")).isEqualTo("value2");
assertThat(propertiesConfigSource.getValue("jqassistant.test.list-value[0]")).isEqualTo("element0");
assertThat(propertiesConfigSource.getValue("jqassistant.test.list-value[1]")).isEqualTo("element1");
}
use of io.smallrye.config.PropertiesConfigSource in project jqa-core-framework by jQAssistant.
the class AbstractPluginIT method createConfiguration.
/**
* Load configuration for ITs.
*
* @return The configuration.
*/
private Configuration createConfiguration(PropertiesConfigBuilder propertiesConfigBuilder) {
ConfigurationLoader configurationLoader = new ConfigurationLoaderImpl(ConfigurationLoader.getDefaultConfigurationDirectory(getClassesDirectory(this.getClass())));
PropertiesConfigSource propertiesConfigSource = propertiesConfigBuilder.build();
return configurationLoader.load(Configuration.class, propertiesConfigSource);
}
use of io.smallrye.config.PropertiesConfigSource in project jqa-commandline-tool by jQAssistant.
the class CliPluginResolverIT method resolve.
@Test
void resolve() {
Map<String, String> configurationProperties = new HashMap<>();
configurationProperties.put("jqassistant.plugins[0].group-id", "org.jqassistant.contrib.plugin");
configurationProperties.put("jqassistant.plugins[0].artifact-id", "jqassistant-docker-plugin");
configurationProperties.put("jqassistant.plugins[0].version", "1.11.0");
PropertiesConfigSource testConfigSource = new PropertiesConfigSource(configurationProperties, "TestConfigSource", 110);
ConfigurationLoaderImpl configurationLoader = new ConfigurationLoaderImpl(new File("src/test/resources"));
CliConfiguration cliConfiguration = configurationLoader.load(CliConfiguration.class, testConfigSource);
PluginResolverFactory pluginResolverFactory = new PluginResolverFactory();
PluginResolver pluginResolver = pluginResolverFactory.create(cliConfiguration);
PluginClassLoader pluginClassLoader = pluginResolver.createClassLoader(PluginResolverFactory.class.getClassLoader(), cliConfiguration.plugins());
assertThat(pluginClassLoader).isNotNull();
}
use of io.smallrye.config.PropertiesConfigSource in project smallrye-open-api by smallrye.
the class DeploymentProcessor method config.
/**
* Creates the config from the microprofile-config.properties file in the application. The spec defines that the
* config file may be present in two locations.
*/
private static OpenApiConfig config(final WebArchive war) {
Optional<Node> microprofileConfig = Stream.of(ofNullable(war.get("/META-INF/microprofile-config.properties")), ofNullable(war.get("/WEB-INF/classes/META-INF/microprofile-config.properties"))).filter(Optional::isPresent).findFirst().flatMap(node -> node);
if (!microprofileConfig.isPresent()) {
return new OpenApiConfigImpl(ConfigProvider.getConfig());
}
Properties properties = new Properties();
try (InputStreamReader reader = new InputStreamReader(microprofileConfig.get().getAsset().openStream(), UTF_8)) {
properties.load(reader);
} catch (IOException e) {
e.printStackTrace();
}
SmallRyeConfig config = new SmallRyeConfigBuilder().addDefaultSources().addDefaultInterceptors().withSources(new PropertiesConfigSource(properties, "microprofile-config.properties")).build();
return new OpenApiConfigImpl(config);
}
use of io.smallrye.config.PropertiesConfigSource in project camel-k-runtime by apache.
the class ApplicationConfigSourceProvider method getConfigSources.
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) {
final Map<String, String> appProperties = RuntimeSupport.loadApplicationProperties();
final Map<String, String> usrProperties = RuntimeSupport.loadUserProperties();
return List.of(new PropertiesConfigSource(appProperties, "camel-k-app", ConfigSource.DEFAULT_ORDINAL), new PropertiesConfigSource(usrProperties, "camel-k-usr", ConfigSource.DEFAULT_ORDINAL + 1));
}
Aggregations