use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class ValidatedProps method testValidatedValueValue.
@Test
public void testValidatedValueValue() {
ValidatedProps validatedProps = new SpringApplicationBuilder(SampleConfiguration.class).web(WebApplicationType.NONE).run("--props.value=2", "--spring.jmx.enabled=false").getBean(ValidatedProps.class);
assertThat(validatedProps.getValue()).isEqualTo(2);
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class RetryTemplateTests method testSpecificCustomRetryTemplate.
@SuppressWarnings("rawtypes")
@Test
public void testSpecificCustomRetryTemplate() throws Exception {
ApplicationContext context = new SpringApplicationBuilder(SpecificCustomRetryTemplateConfiguration.class).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.stream.bindings.processor-in-0.consumer.retry-template-name=retryTemplateTwo");
RetryTemplate retryTemplateTwo = context.getBean("retryTemplateTwo", RetryTemplate.class);
BindingServiceProperties bindingServiceProperties = context.getBean(BindingServiceProperties.class);
ConsumerProperties consumerProperties = bindingServiceProperties.getConsumerProperties("processor-in-0");
AbstractBinder binder = context.getBean(AbstractBinder.class);
Method m = AbstractBinder.class.getDeclaredMethod("buildRetryTemplate", ConsumerProperties.class);
m.setAccessible(true);
RetryTemplate retryTemplate = (RetryTemplate) m.invoke(binder, consumerProperties);
assertThat(retryTemplate).isEqualTo(retryTemplateTwo);
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class MultipleInputOutputFunctionTests method testMultipleFunctionsWithComposition.
@Test
public void testMultipleFunctionsWithComposition() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(ReactiveFunctionConfiguration.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.function.definition=uppercase|reverse;reverse|uppercase")) {
context.getBean(InputDestination.class);
InputDestination inputDestination = context.getBean(InputDestination.class);
OutputDestination outputDestination = context.getBean(OutputDestination.class);
Message<byte[]> inputMessage = MessageBuilder.withPayload("Hello".getBytes()).build();
inputDestination.send(inputMessage, "uppercasereverse-in-0");
inputDestination.send(inputMessage, "reverseuppercase-in-0");
Message<byte[]> outputMessage = outputDestination.receive(0, "uppercasereverse-out-0");
System.out.println(new String(outputMessage.getPayload()));
assertThat(outputMessage.getPayload()).isEqualTo("OLLEH".getBytes());
outputMessage = outputDestination.receive(0, "reverseuppercase-out-0");
assertThat(outputMessage.getPayload()).isEqualTo("OLLEH".getBytes());
}
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class MultipleInputOutputFunctionTests method testMultiInputSingleOutput.
@Test
public void testMultiInputSingleOutput() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(ReactiveFunctionConfiguration.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.function.definition=multiInputSingleOutput")) {
context.getBean(InputDestination.class);
InputDestination inputDestination = context.getBean(InputDestination.class);
OutputDestination outputDestination = context.getBean(OutputDestination.class);
Message<byte[]> stringInputMessage = MessageBuilder.withPayload("one".getBytes()).build();
Message<byte[]> integerInputMessage = MessageBuilder.withPayload("1".getBytes()).build();
inputDestination.send(stringInputMessage, "multiInputSingleOutput-in-0");
inputDestination.send(integerInputMessage, "multiInputSingleOutput-in-1");
Message<byte[]> outputMessage = outputDestination.receive();
assertThat(outputMessage.getPayload()).isEqualTo("one".getBytes());
outputMessage = outputDestination.receive(0, "multiInputSingleOutput-out-0");
assertThat(outputMessage.getPayload()).isEqualTo("1".getBytes());
}
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-cloud-stream by spring-cloud.
the class MultipleInputOutputFunctionTests method testMultiInputSingleOutputWithCustomContentType2.
@Test
public void testMultiInputSingleOutputWithCustomContentType2() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(ContentTypeConfiguration.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.function.definition=multiInputSingleOutput2", "--spring.cloud.stream.bindings.multiInputSingleOutput2-in-0.content-type=string/person", "--spring.cloud.stream.bindings.multiInputSingleOutput2-in-1.content-type=string/employee", "--spring.cloud.stream.bindings.multiInputSingleOutput2-out-0.content-type=string/person")) {
context.getBean(InputDestination.class);
InputDestination inputDestination = context.getBean(InputDestination.class);
OutputDestination outputDestination = context.getBean(OutputDestination.class);
Message<byte[]> stringInputMessage = MessageBuilder.withPayload("ricky".getBytes()).build();
Message<byte[]> integerInputMessage = MessageBuilder.withPayload("bobby".getBytes()).build();
inputDestination.send(stringInputMessage, "multiInputSingleOutput2-in-0");
inputDestination.send(integerInputMessage, "multiInputSingleOutput2-in-1");
Message<byte[]> outputMessage = outputDestination.receive(1000, "multiInputSingleOutput2-out-0");
assertThat(outputMessage.getPayload()).isEqualTo("rickybobby".getBytes());
}
}
Aggregations