if(!wiserMessages.isEmpty())
fail("incorrect send method");
}
else
{
WiserMessage wiserMessage = wiserMessages.get(0);
String from = wiserMessage.getEnvelopeSender();
assertEquals("not correct from", "from@domain",from);
String to = wiserMessage.getEnvelopeReceiver();
assertEquals("not correct to", "address1",to);
String contentType = wiserMessage.getMimeMessage().getContentType();
assertTrue("not correct content type", contentType.startsWith("text/html"));
wiserMessage = wiserMessages.get(1);
from = wiserMessage.getEnvelopeSender();
assertEquals("not correct from", "from@domain",from);
to = wiserMessage.getEnvelopeReceiver();
assertEquals("not correct to", "address2",to);
contentType = wiserMessage.getMimeMessage().getContentType();
assertTrue("not correct content type", contentType.startsWith("text/html"));
}
} catch(QwertoMailerException qme)
{
if(emailsTo == null || emailsTo.isEmpty())
;//pass
else
{
qme.printStackTrace();
fail(qme.getMessage());
}
} catch (Exception e)
{
e.printStackTrace();
fail(e.getMessage());
}
//--------------------
try
{
emlFile = new File("test_files/test_multipart_alt.eml");
MessageContent message = new MessageContent(emlFile);
message.setAddressFrom("from", "from@domain", "utf-8");
sender.send(message, emailsTo);
//check results
List<WiserMessage> wiserMessages = wiser.getMessages();
if(emailsTo.equals(invalidTo))
{
if(!wiserMessages.isEmpty())
fail("incorrect send method");
}
else
{
WiserMessage wiserMessage = wiserMessages.get(2);
String from = wiserMessage.getEnvelopeSender();
assertEquals("not correct from", "from@domain",from);
String to = wiserMessage.getEnvelopeReceiver();
assertEquals("not correct to", "address1",to);
String contentType = wiserMessage.getMimeMessage().getContentType();
assertTrue("not correct content type", contentType.startsWith("multipart/alternative"));
wiserMessage = wiserMessages.get(3);
from = wiserMessage.getEnvelopeSender();
assertEquals("not correct from", "from@domain",from);
to = wiserMessage.getEnvelopeReceiver();
assertEquals("not correct to", "address2",to);
contentType = wiserMessage.getMimeMessage().getContentType();
assertTrue("not correct content type", contentType.startsWith("multipart/alternative"));
}
} catch(QwertoMailerException qme)
{
if(emailsTo == null || emailsTo.isEmpty())
;//pass
else
{
qme.printStackTrace();
fail(qme.getMessage());
}
} catch (Exception e)
{
e.printStackTrace();
fail(e.getMessage());
}
//--------------------
try
{
emlFile = new File("test_files/test_multipart_mixed.eml");
MessageContent message = new MessageContent(emlFile);
message.setAddressFrom("from", "from@domain", "utf-8");
sender.send(message, emailsTo);
//check results
List<WiserMessage> wiserMessages = wiser.getMessages();
if(emailsTo.equals(invalidTo))
{
if(!wiserMessages.isEmpty())
fail("incorrect send method");
}
else
{
WiserMessage wiserMessage = wiserMessages.get(4);
String from = wiserMessage.getEnvelopeSender();
assertEquals("not correct from", "from@domain",from);
String to = wiserMessage.getEnvelopeReceiver();
assertEquals("not correct to", "address1",to);
String contentType = wiserMessage.getMimeMessage().getContentType();
assertTrue("not correct content type", contentType.startsWith("multipart/mixed"));
wiserMessage = wiserMessages.get(5);
from = wiserMessage.getEnvelopeSender();
assertEquals("not correct from", "from@domain",from);
to = wiserMessage.getEnvelopeReceiver();
assertEquals("not correct to", "address2",to);
contentType = wiserMessage.getMimeMessage().getContentType();
assertTrue("not correct content type", contentType.startsWith("multipart/mixed"));
}
} catch(QwertoMailerException qme)
{
if(emailsTo == null || emailsTo.isEmpty())