use of org.springframework.integration.mail.MailReceivingMessageSource 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());
}
Aggregations