use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method testTransformer.
@Test
public void testTransformer() {
TestApplicationContext context = TestUtils.createTestApplicationContext();
DirectChannel inputChannel = new DirectChannel();
context.registerChannel("inputChannel", inputChannel);
QueueChannel outputChannel = new QueueChannel();
context.registerChannel("outputChannel", outputChannel);
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
TransformerAnnotationTestBean testBean = new TransformerAnnotationTestBean();
postProcessor.postProcessAfterInitialization(testBean, "testBean");
context.refresh();
inputChannel.send(new GenericMessage<String>("foo"));
Message<?> reply = outputChannel.receive(0);
assertEquals("FOO", reply.getPayload());
context.stop();
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method testMessageEndpointAnnotationInherited.
@Test
public void testMessageEndpointAnnotationInherited() {
TestApplicationContext context = TestUtils.createTestApplicationContext();
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
context.registerChannel("inputChannel", inputChannel);
context.registerChannel("outputChannel", outputChannel);
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
postProcessor.postProcessAfterInitialization(new SimpleAnnotatedEndpointSubclass(), "subclass");
context.refresh();
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method testChannelResolution.
@Test
public void testChannelResolution() {
TestApplicationContext context = TestUtils.createTestApplicationContext();
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
DirectChannel eventBus = new DirectChannel();
context.registerChannel("inputChannel", inputChannel);
context.registerChannel("outputChannel", outputChannel);
context.registerChannel("eventBus", eventBus);
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
ServiceActivatorAnnotatedBean bean = new ServiceActivatorAnnotatedBean();
postProcessor.postProcessAfterInitialization(bean, "testBean");
context.refresh();
Message<?> message = MessageBuilder.withPayload("test").setReplyChannelName("outputChannel").build();
inputChannel.send(message);
Message<?> reply = outputChannel.receive(0);
assertNotNull(reply);
eventBus.send(new GenericMessage<String>("foo"));
assertTrue(bean.getInvoked());
context.stop();
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method serviceActivatorAnnotation.
@Test
public void serviceActivatorAnnotation() {
TestApplicationContext context = TestUtils.createTestApplicationContext();
DirectChannel inputChannel = new DirectChannel();
context.registerChannel("inputChannel", inputChannel);
context.refresh();
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
ServiceActivatorAnnotatedBean bean = new ServiceActivatorAnnotatedBean();
postProcessor.postProcessAfterInitialization(bean, "testBean");
assertTrue(context.containsBean("testBean.test.serviceActivator"));
Object endpoint = context.getBean("testBean.test.serviceActivator");
assertTrue(endpoint instanceof AbstractEndpoint);
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method testMessageEndpointAnnotationInheritedWithProxy.
@Test
public void testMessageEndpointAnnotationInheritedWithProxy() {
TestApplicationContext context = TestUtils.createTestApplicationContext();
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
context.registerChannel("inputChannel", inputChannel);
context.registerChannel("outputChannel", outputChannel);
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
ProxyFactory proxyFactory = new ProxyFactory(new SimpleAnnotatedEndpointSubclass());
Object proxy = proxyFactory.getProxy();
postProcessor.postProcessAfterInitialization(proxy, "proxy");
context.refresh();
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
}
Aggregations