use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class PollingTransactionTests method propagationMandatory.
@Test
public void propagationMandatory() throws Throwable {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("propagationMandatoryTests.xml", this.getClass());
TestTransactionManager txManager = (TestTransactionManager) context.getBean("txManager");
PollableChannel input = (PollableChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
PollableChannel errorChannel = (PollableChannel) context.getBean("errorChannel");
assertEquals(0, txManager.getCommitCount());
input.send(new GenericMessage<String>("test"));
Message<?> errorMessage = errorChannel.receive(3000);
assertNotNull(errorMessage);
Object payload = errorMessage.getPayload();
assertEquals(MessagingException.class, payload.getClass());
MessagingException messagingException = (MessagingException) payload;
assertEquals(IllegalTransactionStateException.class, messagingException.getCause().getClass());
assertNull(output.receive(0));
assertEquals(0, txManager.getCommitCount());
context.close();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ReturnAddressTests method outputChannelTakesPrecedence.
@Test
public void outputChannelTakesPrecedence() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("returnAddressTests.xml", this.getClass());
MessageChannel channel4 = (MessageChannel) context.getBean("channel4");
PollableChannel replyChannel = (PollableChannel) context.getBean("replyChannel");
context.start();
Message<String> message = MessageBuilder.withPayload("*").setReplyChannelName("channel5").build();
channel4.send(message);
Message<?> response = replyChannel.receive(3000);
assertNotNull(response);
assertEquals("**", response.getPayload());
PollableChannel channel5 = (PollableChannel) context.getBean("channel5");
assertNull(channel5.receive(0));
context.close();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ReturnAddressTests method outputChannelWithNoReturnAddress.
@Test
public void outputChannelWithNoReturnAddress() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("returnAddressTests.xml", this.getClass());
MessageChannel channel4 = (MessageChannel) context.getBean("channel4");
PollableChannel replyChannel = (PollableChannel) context.getBean("replyChannel");
context.start();
GenericMessage<String> message = new GenericMessage<String>("*");
channel4.send(message);
Message<?> response = replyChannel.receive(3000);
assertNotNull(response);
assertEquals("**", response.getPayload());
context.close();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ReturnAddressTests method returnAddressWithChannelReferenceAfterMultipleEndpoints.
@Test
public void returnAddressWithChannelReferenceAfterMultipleEndpoints() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("returnAddressTests.xml", this.getClass());
MessageChannel channel1 = (MessageChannel) context.getBean("channel1");
PollableChannel replyChannel = (PollableChannel) context.getBean("replyChannel");
context.start();
Message<String> message = MessageBuilder.withPayload("*").setReplyChannel(replyChannel).build();
channel1.send(message);
Message<?> response = replyChannel.receive(3000);
assertNotNull(response);
assertEquals("********", response.getPayload());
PollableChannel channel2 = (PollableChannel) context.getBean("channel2");
assertNull(channel2.receive(0));
context.close();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ReturnAddressTests method returnAddressFallbackWithChannelName.
@Test
public void returnAddressFallbackWithChannelName() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("returnAddressTests.xml", this.getClass());
MessageChannel channel3 = (MessageChannel) context.getBean("channel3");
PollableChannel channel5 = (PollableChannel) context.getBean("channel5");
context.start();
Message<String> message = MessageBuilder.withPayload("*").setReplyChannelName("channel5").build();
channel3.send(message);
Message<?> response = channel5.receive(3000);
assertNotNull(response);
assertEquals("**", response.getPayload());
context.close();
}
Aggregations