use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class UnmarshallingTransformerParserTests method testUnmarshallString.
@Test
public void testUnmarshallString() throws Exception {
MessageChannel input = (MessageChannel) appContext.getBean("input");
PollableChannel output = (PollableChannel) appContext.getBean("output");
GenericMessage<Object> message = new GenericMessage<Object>("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>");
input.send(message);
Message<?> result = output.receive(0);
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof StringSource);
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class UnmarshallingTransformerParserTests method testDefaultUnmarshall.
@Test
public void testDefaultUnmarshall() throws Exception {
MessageChannel input = (MessageChannel) appContext.getBean("input");
PollableChannel output = (PollableChannel) appContext.getBean("output");
GenericMessage<Object> message = new GenericMessage<Object>(new StringSource("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>"));
input.send(message);
Message<?> result = output.receive(0);
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof StringSource);
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class UnmarshallingTransformerParserTests method testUnmarshallDocument.
@Test
public void testUnmarshallDocument() throws Exception {
MessageChannel input = (MessageChannel) appContext.getBean("input");
PollableChannel output = (PollableChannel) appContext.getBean("output");
GenericMessage<Object> message = new GenericMessage<Object>(XmlTestUtil.getDocumentForString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>"));
input.send(message);
Message<?> result = output.receive(0);
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof DOMSource);
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class XPathFilterParserTests method stringExpressionWithNamespaceString.
@Test
public void stringExpressionWithNamespaceString() throws Exception {
MessageChannel inputChannel = context.getBean("stringFilterWithNamespaceInput", MessageChannel.class);
QueueChannel replyChannel = new QueueChannel();
PollableChannel discardChannel = context.getBean("stringFilterWithNamespaceRejections", PollableChannel.class);
Document docToAccept = XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>");
Document docToReject = XmlTestUtil.getDocumentForString("<name>outputOne</name>");
Message<?> shouldBeAccepted = MessageBuilder.withPayload(docToAccept).setReplyChannel(replyChannel).build();
Message<?> shouldBeRejected = MessageBuilder.withPayload(docToReject).setReplyChannel(replyChannel).build();
inputChannel.send(shouldBeAccepted);
inputChannel.send(shouldBeRejected);
assertEquals(shouldBeAccepted, replyChannel.receive(0));
assertEquals(shouldBeRejected, discardChannel.receive(0));
assertNull(replyChannel.receive(0));
assertNull(discardChannel.receive(0));
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class XPathFilterParserTests method simpleStringExpressionBoolean.
@Test
public void simpleStringExpressionBoolean() throws Exception {
MessageChannel inputChannel = context.getBean("booleanFilterInput", MessageChannel.class);
QueueChannel replyChannel = new QueueChannel();
PollableChannel discardChannel = context.getBean("booleanFilterRejections", PollableChannel.class);
Message<?> shouldBeAccepted = MessageBuilder.withPayload("<name>outputOne</name>").setReplyChannel(replyChannel).build();
Message<?> shouldBeRejected = MessageBuilder.withPayload("<other>outputOne</other>").setReplyChannel(replyChannel).build();
inputChannel.send(shouldBeAccepted);
inputChannel.send(shouldBeRejected);
assertEquals(shouldBeAccepted, replyChannel.receive(0));
assertEquals(shouldBeRejected, discardChannel.receive(0));
assertNull(replyChannel.receive(0));
assertNull(discardChannel.receive(0));
}
Aggregations