use of javax.mail.Message in project camel by apache.
the class MailShutdownCompleteCurrentTaskOnlyTest method prepareMailbox.
private void prepareMailbox() throws Exception {
// connect to mailbox
Mailbox.clearAll();
JavaMailSender sender = new DefaultJavaMailSender();
Store store = sender.getSession().getStore("pop3");
store.connect("localhost", 25, "jones", "secret");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
folder.expunge();
// inserts 8 new messages
Message[] messages = new Message[5];
for (int i = 0; i < 5; i++) {
messages[i] = new MimeMessage(sender.getSession());
messages[i].setText("Message " + i);
messages[i].setHeader("Message-ID", "" + i);
}
folder.appendMessages(messages);
folder.close(true);
}
use of javax.mail.Message in project camel by apache.
the class MailSortTermTest method prepareMailbox.
private void prepareMailbox() throws Exception {
// connect to mailbox
Mailbox.clearAll();
JavaMailSender sender = new DefaultJavaMailSender();
Store store = sender.getSession().getStore("pop3");
store.connect("localhost", 25, "bill", "secret");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
folder.expunge();
// inserts 3 messages, one with earlier, one with later sent date and one with invalid subject (not returned in search)
Message[] messages = new Message[3];
messages[0] = new MimeMessage(sender.getSession());
messages[0].setText("Earlier date");
messages[0].setHeader("Message-ID", "0");
messages[0].setSentDate(new Date(10000));
messages[0].setSubject("Camel");
messages[1] = new MimeMessage(sender.getSession());
messages[1].setText("Later date");
messages[1].setHeader("Message-ID", "1");
messages[1].setSentDate(new Date(20000));
messages[1].setSubject("Camel");
messages[2] = new MimeMessage(sender.getSession());
messages[2].setText("Even later date");
messages[2].setHeader("Message-ID", "2");
messages[2].setSentDate(new Date(30000));
messages[2].setSubject("Invalid");
folder.appendMessages(messages);
folder.close(true);
}
use of javax.mail.Message in project camel by apache.
the class MailSortTermThreeTest method prepareMailbox.
private void prepareMailbox() throws Exception {
// connect to mailbox
Mailbox.clearAll();
JavaMailSender sender = new DefaultJavaMailSender();
Store store = sender.getSession().getStore("pop3");
store.connect("localhost", 25, "bill", "secret");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
folder.expunge();
// inserts 3 messages, one with earlier, one with later sent date and one with invalid subject (not returned in search)
Message[] messages = new Message[3];
messages[0] = new MimeMessage(sender.getSession());
messages[0].setText("Earlier date");
messages[0].setHeader("Message-ID", "0");
messages[0].setSentDate(new Date(10000));
messages[0].setSubject("Camel");
messages[1] = new MimeMessage(sender.getSession());
messages[1].setText("Later date");
messages[1].setHeader("Message-ID", "1");
messages[1].setSentDate(new Date(20000));
messages[1].setSubject("Camel");
messages[2] = new MimeMessage(sender.getSession());
messages[2].setText("Even later date");
messages[2].setHeader("Message-ID", "2");
messages[2].setSentDate(new Date(30000));
messages[2].setSubject("Invalid");
folder.appendMessages(messages);
folder.close(true);
}
use of javax.mail.Message in project camel by apache.
the class MailSortTermTwoTest method prepareMailbox.
private void prepareMailbox() throws Exception {
// connect to mailbox
Mailbox.clearAll();
JavaMailSender sender = new DefaultJavaMailSender();
Store store = sender.getSession().getStore("pop3");
store.connect("localhost", 25, "bill", "secret");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
folder.expunge();
// inserts 3 messages, one with earlier, one with later sent date and one with invalid subject (not returned in search)
Message[] messages = new Message[3];
messages[0] = new MimeMessage(sender.getSession());
messages[0].setText("Earlier date");
messages[0].setHeader("Message-ID", "0");
messages[0].setSentDate(new Date(10000));
messages[0].setSubject("Camel");
messages[1] = new MimeMessage(sender.getSession());
messages[1].setText("Later date");
messages[1].setHeader("Message-ID", "1");
messages[1].setSentDate(new Date(20000));
messages[1].setSubject("Camel");
messages[2] = new MimeMessage(sender.getSession());
messages[2].setText("Even later date");
messages[2].setHeader("Message-ID", "2");
messages[2].setSentDate(new Date(30000));
messages[2].setSubject("Invalid");
folder.appendMessages(messages);
folder.close(true);
}
use of javax.mail.Message in project camel by apache.
the class MailSorterTest method testSortMessagesReverse.
@Test
public void testSortMessagesReverse() throws Exception {
Message[] expected = new Message[] { MESSAGES[2], MESSAGES[1], MESSAGES[0] };
// Sort using all the terms. Message order should be the same no matter what term is used
for (SortTerm term : POSSIBLE_TERMS) {
Message[] actual = MESSAGES.clone();
MailSorter.sortMessages(actual, new SortTerm[] { SortTerm.REVERSE, term });
try {
assertArrayEquals(actual, expected);
} catch (AssertionError ex) {
throw new AssertionError("Term: " + term.toString(), ex);
}
}
}
Aggregations