Search in sources :

Example 6 with SourceConfigurer

use of org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder.SourceConfigurer in project spring-cloud-stream by spring-cloud.

the class AggregationTest method testNamespacePrefixesFromCmdLine.

@Test
@SuppressWarnings("unchecked")
public void testNamespacePrefixesFromCmdLine() {
    AggregateApplicationBuilder aggregateApplicationBuilder = new AggregateApplicationBuilder(MockBinderRegistryConfiguration.class);
    aggregatedApplicationContext = aggregateApplicationBuilder.parent(DummyConfig.class).web(false).from(TestSource.class).namespace("a").via(TestProcessor.class).namespace("b").via(TestProcessor.class).namespace("c").run("--a.foo1=bar1", "--b.foo1=bar2", "--c.foo1=bar3");
    DirectFieldAccessor aggregateApplicationBuilderAccessor = new DirectFieldAccessor(aggregateApplicationBuilder);
    assertTrue(Arrays.equals(((SourceConfigurer) aggregateApplicationBuilderAccessor.getPropertyValue("sourceConfigurer")).getArgs(), new String[] { "--foo1=bar1" }));
    final List<AggregateApplicationBuilder.ProcessorConfigurer> processorConfigurers = (List<AggregateApplicationBuilder.ProcessorConfigurer>) aggregateApplicationBuilderAccessor.getPropertyValue("processorConfigurers");
    for (AggregateApplicationBuilder.ProcessorConfigurer processorConfigurer : processorConfigurers) {
        if (processorConfigurer.getNamespace().equals("b")) {
            assertTrue(Arrays.equals(processorConfigurer.getArgs(), new String[] { "--foo1=bar2" }));
        }
        if (processorConfigurer.getNamespace().equals("c")) {
            assertTrue(Arrays.equals(processorConfigurer.getArgs(), new String[] { "--foo1=bar3" }));
        }
    }
    aggregatedApplicationContext.close();
}
Also used : SourceConfigurer(org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder.SourceConfigurer) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) AggregateApplicationBuilder(org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)6 AggregateApplicationBuilder (org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder)6 SourceConfigurer (org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder.SourceConfigurer)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5