use of org.springframework.integration.endpoint.MethodInvokingMessageSource in project spring-integration by spring-projects.
the class IntegrationFlows method from.
/**
* Populate the provided {@link MethodInvokingMessageSource} for the method of the provided service.
* The {@link org.springframework.integration.dsl.IntegrationFlow} {@code startMessageSource}.
* @param service the service to use.
* @param methodName the method to invoke.
* @param endpointConfigurer the {@link Consumer} to provide more options for the
* {@link org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean}.
* @return new {@link IntegrationFlowBuilder}.
* @since 1.1
* @see MethodInvokingMessageSource
*/
public static IntegrationFlowBuilder from(Object service, String methodName, Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
Assert.notNull(service, "'service' must not be null");
Assert.hasText(methodName, "'methodName' must not be empty");
MethodInvokingMessageSource messageSource = new MethodInvokingMessageSource();
messageSource.setObject(service);
messageSource.setMethodName(methodName);
return from(messageSource, endpointConfigurer);
}
use of org.springframework.integration.endpoint.MethodInvokingMessageSource in project spring-integration by spring-projects.
the class MethodInvokingMessageSourceTests method testNoMatchingMethodName.
@Test(expected = MessagingException.class)
public void testNoMatchingMethodName() {
MethodInvokingMessageSource source = new MethodInvokingMessageSource();
source.setBeanFactory(mock(BeanFactory.class));
source.setObject(new TestBean());
source.setMethodName("noMatchingMethod");
source.receive();
}
use of org.springframework.integration.endpoint.MethodInvokingMessageSource in project spring-integration by spring-projects.
the class MethodInvokingMessageSourceTests method testInvalidMethodWithNoReturnValue.
@Test(expected = MessagingException.class)
public void testInvalidMethodWithNoReturnValue() {
MethodInvokingMessageSource source = new MethodInvokingMessageSource();
source.setBeanFactory(mock(BeanFactory.class));
source.setObject(new TestBean());
source.setMethodName("invalidMethodWithNoReturnValue");
source.receive();
}
use of org.springframework.integration.endpoint.MethodInvokingMessageSource in project spring-integration by spring-projects.
the class MethodInvokingMessageSourceTests method testInvalidMethodWithArg.
@Test(expected = MessagingException.class)
public void testInvalidMethodWithArg() {
MethodInvokingMessageSource source = new MethodInvokingMessageSource();
source.setBeanFactory(mock(BeanFactory.class));
source.setObject(new TestBean());
source.setMethodName("invalidMethodWithArg");
source.receive();
}
use of org.springframework.integration.endpoint.MethodInvokingMessageSource in project spring-integration by spring-projects.
the class MethodInvokingMessageSourceTests method testNullReturningMethodReturnsNullMessage.
@Test
public void testNullReturningMethodReturnsNullMessage() {
MethodInvokingMessageSource source = new MethodInvokingMessageSource();
source.setBeanFactory(mock(BeanFactory.class));
source.setObject(new TestBean());
source.setMethodName("nullReturningMethod");
Message<?> message = source.receive();
assertNull(message);
}
Aggregations