use of org.apache.camel.k.listener.SourcesConfigurer in project camel-k-runtime by apache.
the class PropertiesSupportTest method propertiesAreBoundToSourcesConfigurer.
@Test
public void propertiesAreBoundToSourcesConfigurer() {
CamelContext context = new DefaultCamelContext();
context.getPropertiesComponent().setInitialProperties(asProperties("camel.k.sources[0].name", "MyRoutesWithBeans", "camel.k.sources[0].location", "classpath:MyRoutesWithBeans.java", "camel.k.sources[1].name", "MyRoutesConfig", "camel.k.sources[1].location", "classpath:MyRoutesConfig.java", "camel.k.sources[1].property-names[0]", "foo", "camel.k.sources[1].property-names[1]", "bar"));
SourcesConfigurer configuration = new SourcesConfigurer();
PropertiesSupport.bindProperties(context, configuration, k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX), SourcesConfigurer.CAMEL_K_PREFIX);
assertThat(configuration.getSources()).hasSize(2).anyMatch(byNameAndLocation("MyRoutesWithBeans", "classpath:MyRoutesWithBeans.java").and(d -> d.getPropertyNames() == null)).anyMatch(byNameAndLocation("MyRoutesConfig", "classpath:MyRoutesConfig.java").and(d -> d.getPropertyNames() != null && d.getPropertyNames().containsAll(List.of("foo", "bar"))));
}
use of org.apache.camel.k.listener.SourcesConfigurer in project camel-k-runtime by apache.
the class PropertiesSupportTest method propertiesWithGapsAreBoundToSourcesConfigurer.
@Test
public void propertiesWithGapsAreBoundToSourcesConfigurer() {
CamelContext context = new DefaultCamelContext();
context.getPropertiesComponent().setInitialProperties(asProperties("camel.k.sources[0].name", "MyRoutesWithBeans", "camel.k.sources[0].location", "classpath:MyRoutesWithBeans.java", "camel.k.sources[2].name", "MyRoutesConfig", "camel.k.sources[2].location", "classpath:MyRoutesConfig.java"));
SourcesConfigurer configuration = new SourcesConfigurer();
PropertiesSupport.bindProperties(context, configuration, k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX), SourcesConfigurer.CAMEL_K_PREFIX);
assertThat(configuration.getSources()).hasSize(3).filteredOn(Objects::nonNull).hasSize(2).anyMatch(byNameAndLocation("MyRoutesWithBeans", "classpath:MyRoutesWithBeans.java")).anyMatch(byNameAndLocation("MyRoutesConfig", "classpath:MyRoutesConfig.java"));
}
Aggregations