* Here we test asynchronous email sending of {@link Message}.
* We check concurrent execution of {@link FutureTask}
*/
public void testSendMessageInFuture() throws Exception
{
Message message;
Attachment attachment = new Attachment();
attachment.setInputStream(new ByteArrayInputStream(ATTACHMENT.getBytes()));
attachment.setMimeType(TEXT_PLAIN);
@SuppressWarnings("unchecked")
Future<Boolean>[] futures = new Future[THREAD_NUMBER];
assertEquals("SMTP server should be now empty", 0, mailServer.getMessages().size());
for (int i = 0; i < THREAD_NUMBER; i++)
{
assertFalse(isEmailMessageSent(MAIL_SUBJECT + i));
message = new Message();
message.setFrom(generateRandomEmailSender());
message.setTo(generateRandomEmailRecipient());
message.setCC(generateRandomEmailRecipient() + "," + generateRandomEmailRecipient());
message.setBCC(generateRandomEmailRecipient() + "," + generateRandomEmailRecipient());
message.setSubject(MAIL_SUBJECT + i);
message.setBody(MAIL_CONTENTS + i);
message.setMimeType(TEXT_HTML);
message.addAttachment(attachment);
futures[i] = service.sendMessageInFuture(message);
}
for (int i = 0; i < THREAD_NUMBER; i++)