use of org.springframework.integration.mail.support.DefaultMailHeaderMapper in project spring-integration by spring-projects.
the class ImapMailReceiverTests method testIdleWithMessageMapping.
@Test
public void testIdleWithMessageMapping() throws Exception {
ImapMailReceiver receiver = new ImapMailReceiver("imap://user:pw@localhost:" + imapIdleServer.getPort() + "/INBOX");
receiver.setHeaderMapper(new DefaultMailHeaderMapper());
testIdleWithServerGuts(receiver, true);
}
use of org.springframework.integration.mail.support.DefaultMailHeaderMapper in project spring-integration by spring-projects.
the class ImapMailReceiverTests method testAttachmentsWithMappingMultiAsBytes.
@Test
public void testAttachmentsWithMappingMultiAsBytes() throws Exception {
final ImapMailReceiver receiver = new ImapMailReceiver("imap://foo");
receiver.setHeaderMapper(new DefaultMailHeaderMapper());
testAttachmentsGuts(receiver);
org.springframework.messaging.Message<?>[] messages = (org.springframework.messaging.Message<?>[]) receiver.receive();
org.springframework.messaging.Message<?> received = messages[0];
Object content = received.getPayload();
assertThat(content, instanceOf(byte[].class));
assertThat((String) received.getHeaders().get(MailHeaders.CONTENT_TYPE), equalTo("multipart/mixed;\r\n boundary=\"------------040903000701040401040200\""));
assertThat((String) received.getHeaders().get(MessageHeaders.CONTENT_TYPE), equalTo("application/octet-stream"));
}
use of org.springframework.integration.mail.support.DefaultMailHeaderMapper in project spring-integration by spring-projects.
the class Pop3Tests method testPop3.
@Test
public void testPop3() throws Exception {
Pop3MailReceiver receiver = new Pop3MailReceiver("localhost", pop3Server.getPort(), "user", "pw");
receiver.setHeaderMapper(new DefaultMailHeaderMapper());
MailReceivingMessageSource source = new MailReceivingMessageSource(receiver);
Message<?> message = source.receive();
assertNotNull(message);
MessageHeaders headers = message.getHeaders();
assertEquals("Foo <foo@bar>", headers.get(MailHeaders.TO, String[].class)[0]);
assertEquals("[a@b, c@d]", Arrays.toString(headers.get(MailHeaders.CC, String[].class)));
assertEquals("[e@f, g@h]", Arrays.toString(headers.get(MailHeaders.BCC, String[].class)));
assertEquals("Bar <bar@baz>", headers.get(MailHeaders.FROM));
assertEquals("Test Email", headers.get(MailHeaders.SUBJECT));
assertEquals("foo\r\n\r\n", message.getPayload());
}
use of org.springframework.integration.mail.support.DefaultMailHeaderMapper in project spring-integration by spring-projects.
the class ImapMailReceiverTests method testIdleWithMessageMappingSimple.
@Test
public void testIdleWithMessageMappingSimple() throws Exception {
ImapMailReceiver receiver = new ImapMailReceiver("imap://user:pw@localhost:" + imapIdleServer.getPort() + "/INBOX");
receiver.setSimpleContent(true);
receiver.setHeaderMapper(new DefaultMailHeaderMapper());
testIdleWithServerGuts(receiver, true, true);
}
use of org.springframework.integration.mail.support.DefaultMailHeaderMapper in project spring-integration by spring-projects.
the class ImapMailReceiverTests method testAttachmentsWithMapping.
@Test
public void testAttachmentsWithMapping() throws Exception {
final ImapMailReceiver receiver = new ImapMailReceiver("imap://foo");
receiver.setHeaderMapper(new DefaultMailHeaderMapper());
receiver.setEmbeddedPartsAsBytes(false);
testAttachmentsGuts(receiver);
org.springframework.messaging.Message<?>[] messages = (org.springframework.messaging.Message<?>[]) receiver.receive();
Object content = messages[0].getPayload();
assertThat(content, instanceOf(Multipart.class));
assertEquals("bar", ((Multipart) content).getBodyPart(0).getContent().toString().trim());
assertEquals("foo", ((Multipart) content).getBodyPart(1).getContent().toString().trim());
}
Aggregations