use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class JdbcPollingChannelAdapterParserTests method setupMessagingTemplate.
protected void setupMessagingTemplate() {
PollableChannel pollableChannel = this.appCtx.getBean("target", PollableChannel.class);
this.messagingTemplate = new MessagingTemplate();
this.messagingTemplate.setDefaultDestination(pollableChannel);
this.messagingTemplate.setReceiveTimeout(10000);
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class JdbcOutboundGatewayParserTests method testReplyTimeoutIsSet.
@Test
public void testReplyTimeoutIsSet() {
setUp("JdbcOutboundGatewayWithPollerTest-context.xml", getClass());
PollingConsumer outboundGateway = this.context.getBean("jdbcOutboundGateway", PollingConsumer.class);
DirectFieldAccessor accessor = new DirectFieldAccessor(outboundGateway);
Object source = accessor.getPropertyValue("handler");
accessor = new DirectFieldAccessor(source);
source = accessor.getPropertyValue("messagingTemplate");
MessagingTemplate messagingTemplate = (MessagingTemplate) source;
accessor = new DirectFieldAccessor(messagingTemplate);
Long sendTimeout = (Long) accessor.getPropertyValue("sendTimeout");
assertEquals("Wrong sendTimeout", Long.valueOf(444L), sendTimeout);
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class MailHeaderEnricherTests method literalValues.
@Test
public void literalValues() {
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(literalValuesInput);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("test"));
Map<String, Object> headers = result.getHeaders();
assertEquals("test.to", headers.get(MailHeaders.TO));
assertEquals("test.cc", headers.get(MailHeaders.CC));
assertEquals("test.bcc", headers.get(MailHeaders.BCC));
assertEquals("test.from", headers.get(MailHeaders.FROM));
assertEquals("test.reply-to", headers.get(MailHeaders.REPLY_TO));
assertEquals("test.subject", headers.get(MailHeaders.SUBJECT));
assertEquals("foo.txt", headers.get(MailHeaders.ATTACHMENT_FILENAME));
assertEquals("1", headers.get(MailHeaders.MULTIPART_MODE));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class MailHeaderEnricherTests method expressions.
@Test
public void expressions() {
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(expressionsInput);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("foo"));
Map<String, Object> headers = result.getHeaders();
assertEquals("foo.to", headers.get(MailHeaders.TO));
assertEquals("foo.cc", headers.get(MailHeaders.CC));
assertEquals("foo.bcc", headers.get(MailHeaders.BCC));
assertEquals("foo.from", headers.get(MailHeaders.FROM));
assertEquals("foo.reply-to", headers.get(MailHeaders.REPLY_TO));
assertEquals("foo.subject", headers.get(MailHeaders.SUBJECT));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class FileOutboundGatewayParserTests method gatewayWithReplaceMode.
/**
* Test uses the Replace Mode of the File OutboundGateway. When persisting
* a payload using the File Outbound Gateway and the mode is set to REPLACE,
* then the destination file will be created and written if it does not yet exist.
* If the destination file exists, it will be replaced.
*
* The reply message will contain the concatenated destination
* {@link File} as its payload.
*/
@Test
public void gatewayWithReplaceMode() throws Exception {
assertFalse(TestUtils.getPropertyValue(this.gatewayWithReplaceModeHandler, "requiresReply", Boolean.class));
final MessagingTemplate messagingTemplate = new MessagingTemplate();
messagingTemplate.setDefaultDestination(this.gatewayWithReplaceModeChannel);
String expectedFileContent = "String content:";
File testFile = new File("test/fileToAppend.txt");
if (testFile.exists()) {
testFile.delete();
}
messagingTemplate.sendAndReceive(new GenericMessage<String>("Initial File Content:"));
Message<?> m = messagingTemplate.sendAndReceive(new GenericMessage<String>("String content:"));
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
assertEquals(expectedFileContent, actualFileContent);
assertTrue(m.getPayload() instanceof File);
File replyPayload = (File) m.getPayload();
assertEquals(expectedFileContent, new String(FileCopyUtils.copyToByteArray(replyPayload)));
}
Aggregations