use of org.springframework.integration.handler.support.MessagingMethodInvokerHelper in project spring-integration by spring-projects.
the class MethodInvokingMessageProcessorTests method testPrivateMethod.
@Test
public void testPrivateMethod() throws Exception {
class Foo {
@ServiceActivator
private String service(String payload) {
return payload.toUpperCase();
}
}
MessagingMethodInvokerHelper helper = new MessagingMethodInvokerHelper(new Foo(), ServiceActivator.class, false);
assertEquals("FOO", helper.process(new GenericMessage<>("foo")));
assertEquals("BAR", helper.process(new GenericMessage<>("bar")));
}
use of org.springframework.integration.handler.support.MessagingMethodInvokerHelper in project spring-integration by spring-projects.
the class MethodInvokingMessageProcessorTests method testInt3199GenericTypeResolvingAndObjectMethod.
@Test
public void testInt3199GenericTypeResolvingAndObjectMethod() throws Exception {
class Foo {
@SuppressWarnings("unused")
public String handleMessage(Message<Number> message) {
return "" + (message.getPayload().intValue() * 2);
}
@SuppressWarnings("unused")
public String objectMethod(Integer foo) {
return foo.toString();
}
@SuppressWarnings("unused")
public String voidMethod() {
return "foo";
}
}
MessagingMethodInvokerHelper helper = new MessagingMethodInvokerHelper(new Foo(), (String) null, false);
assertEquals("4", helper.process(new GenericMessage<Object>(2L)));
assertEquals("1", helper.process(new GenericMessage<Object>(1)));
assertEquals("foo", helper.process(new GenericMessage<Object>(new Date())));
}
use of org.springframework.integration.handler.support.MessagingMethodInvokerHelper in project spring-integration by spring-projects.
the class MethodInvokingMessageProcessorTests method gatewayTest.
@Test
public void gatewayTest() throws Exception {
GatewayProxyFactoryBean gwFactoryBean = new GatewayProxyFactoryBean();
gwFactoryBean.setBeanFactory(mock(BeanFactory.class));
gwFactoryBean.afterPropertiesSet();
Object target = gwFactoryBean.getObject();
// just instantiate a helper with a simple target; we're going to invoke getTargetClass with reflection
MessagingMethodInvokerHelper helper = new MessagingMethodInvokerHelper(new TestErrorService(), "error", true);
Method method = MessagingMethodInvokerHelper.class.getDeclaredMethod("getTargetClass", Object.class);
method.setAccessible(true);
Object result = method.invoke(helper, target);
assertSame(RequestReplyExchanger.class, result);
}
Aggregations