use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class RoutingFunctionTests method testPojoFunction.
@Test
public void testPojoFunction() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(RoutingFunctionConfiguration.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.stream.function.definition=" + RoutingFunction.FUNCTION_NAME)) {
InputDestination inputDestination = context.getBean(InputDestination.class);
OutputDestination outputDestination = context.getBean(OutputDestination.class);
Message<byte[]> inputMessage = MessageBuilder.withPayload("{\"name\":\"bob\"}".getBytes()).setHeader("spring.cloud.function.definition", "pojoecho").build();
inputDestination.send(inputMessage);
Message<byte[]> outputMessage = outputDestination.receive();
assertThat(outputMessage.getPayload()).isEqualTo("{\"name\":\"bob\"}".getBytes());
}
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class StreamBridgeTests method testBridgeActivationWhenFunctionDefinitionIsPresent.
// see https://github.com/spring-cloud/spring-cloud-function/issues/573 for more details
@Test
public void testBridgeActivationWhenFunctionDefinitionIsPresent() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(SimpleConfiguration.class)).web(WebApplicationType.NONE).run("--spring.cloud.function.definition=echo;uppercase", "--spring.jmx.enabled=false")) {
StreamBridge bridge = context.getBean(StreamBridge.class);
bridge.send("echo-in-0", "hello foo");
OutputDestination outputDestination = context.getBean(OutputDestination.class);
assertThat(new String(outputDestination.receive(100, "echo-out-0").getPayload())).isEqualTo("hello foo");
}
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class StreamBridgeTests method testBindingPropertiesAreHonored.
@Test
public void testBindingPropertiesAreHonored() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(ConsumerConfiguration.class)).web(WebApplicationType.NONE).run("--spring.cloud.function.definition=consumer;function", "--spring.jmx.enabled=false", "--spring.cloud.stream.bindings.foo.destination=function-in-0", "--spring.cloud.stream.bindings.foo.producer.partitionCount=5", "--spring.cloud.stream.bindings.foo.consumer.concurrency=2")) {
BindingServiceProperties bsProperties = context.getBean(BindingServiceProperties.class);
assertThat(bsProperties.getConsumerProperties("foo").getConcurrency()).isEqualTo(2);
assertThat(bsProperties.getProducerProperties("foo").getPartitionCount()).isEqualTo(5);
StreamBridge bridge = context.getBean(StreamBridge.class);
bridge.send("consumer-in-0", "hello foo");
OutputDestination outputDestination = context.getBean(OutputDestination.class);
Message<byte[]> message = outputDestination.receive(100, "function-out-0");
assertThat(new String(message.getPayload())).isEqualTo("hello foo");
assertThat(message.getHeaders().get("concurrency")).isEqualTo(2);
assertThat(message.getHeaders().get("partitionCount")).isEqualTo(5);
}
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class StreamBridgeTests method testWithIntegrationFlowBecauseMarcinSaidSo.
@Test
public void testWithIntegrationFlowBecauseMarcinSaidSo() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(IntegrationFlowConfiguration.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false")) {
StreamBridge bridge = context.getBean(StreamBridge.class);
bridge.send("foo", "blah");
OutputDestination outputDestination = context.getBean(OutputDestination.class);
Message<byte[]> message = outputDestination.receive(100, "output");
assertThat(new String(message.getPayload())).isEqualTo("BLAH");
}
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class StreamBridgeTests method testNoBridgeIfNoSourcePropertyDefined.
@Test(expected = NoSuchBeanDefinitionException.class)
public void testNoBridgeIfNoSourcePropertyDefined() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration()).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false")) {
context.getBean(StreamBridge.class);
fail();
}
}
Aggregations