use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingGatewayTests method validateErrorChannelWithSuccessfulReply.
// should not fail but it does now
@Test
public void validateErrorChannelWithSuccessfulReply() {
TestUtils.TestApplicationContext testApplicationContext = TestUtils.createTestApplicationContext();
testApplicationContext.refresh();
DirectChannel reqChannel = new DirectChannel();
reqChannel.subscribe(message -> {
throw new RuntimeException("ooops");
});
PublishSubscribeChannel errorChannel = new PublishSubscribeChannel();
ServiceActivatingHandler handler = new ServiceActivatingHandler(new MyOneWayErrorService());
handler.setBeanFactory(testApplicationContext);
handler.afterPropertiesSet();
errorChannel.subscribe(handler);
this.messagingGateway = new MessagingGatewaySupport() {
};
this.messagingGateway.setRequestChannel(reqChannel);
this.messagingGateway.setErrorChannel(errorChannel);
this.messagingGateway.setReplyChannel(null);
this.messagingGateway.setBeanFactory(mock(BeanFactory.class));
this.messagingGateway.afterPropertiesSet();
this.messagingGateway.start();
this.messagingGateway.send("hello");
testApplicationContext.close();
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingGatewayTests method initializeSample.
@Before
public void initializeSample() {
this.messagingGateway = new MessagingGatewaySupport() {
};
this.messagingGateway.setRequestChannel(requestChannel);
this.messagingGateway.setReplyChannel(replyChannel);
TestApplicationContext applicationContext = TestUtils.createTestApplicationContext();
this.messagingGateway.setBeanFactory(applicationContext);
this.messagingGateway.setCountsEnabled(true);
this.messagingGateway.afterPropertiesSet();
this.messagingGateway.start();
applicationContext.refresh();
Mockito.when(this.messageMock.getHeaders()).thenReturn(new MessageHeaders(Collections.emptyMap()));
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MethodInvokingMessageHandlerTests method subscription.
@Test
public void subscription() throws Exception {
TestApplicationContext context = TestUtils.createTestApplicationContext();
SynchronousQueue<String> queue = new SynchronousQueue<String>();
TestBean testBean = new TestBean(queue);
QueueChannel channel = new QueueChannel();
context.registerChannel("channel", channel);
Message<String> message = new GenericMessage<String>("testing");
channel.send(message);
assertNull(queue.poll());
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(testBean, "foo");
PollingConsumer endpoint = new PollingConsumer(channel, handler);
endpoint.setTrigger(new PeriodicTrigger(10));
context.registerEndpoint("testEndpoint", endpoint);
context.refresh();
String result = queue.poll(2000, TimeUnit.MILLISECONDS);
assertNotNull(result);
assertEquals("testing", result);
context.stop();
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method testMessageEndpointAnnotationInheritedFromInterfaceWithProxy.
@Test
public void testMessageEndpointAnnotationInheritedFromInterfaceWithProxy() {
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 SimpleAnnotatedEndpointImplementation());
Object proxy = proxyFactory.getProxy();
postProcessor.postProcessAfterInitialization(proxy, "proxy");
context.refresh();
inputChannel.send(new GenericMessage<String>("ABC"));
Message<?> message = outputChannel.receive(1000);
assertEquals("test-ABC", message.getPayload());
context.stop();
}
use of org.springframework.integration.test.util.TestUtils.TestApplicationContext in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method testProxiedMessageEndpointAnnotation.
@Test
public void testProxiedMessageEndpointAnnotation() {
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 AnnotatedTestService());
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