use of org.apache.logging.log4j.core.net.MimeMessageBuilder in project logging-log4j2 by apache.
the class SmtpAppenderTest method testMessageFactorySetFrom.
@Test
public void testMessageFactorySetFrom() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String address = "testing@example.com";
assertNull(builder.build().getFrom());
builder.setFrom(null);
Address[] array = null;
final Address addr = InternetAddress.getLocalAddress(null);
if (addr != null) {
array = new Address[] { addr };
}
assertArrayEquals(array, builder.build().getFrom());
builder.setFrom(address);
assertArrayEquals(new Address[] { new InternetAddress(address) }, builder.build().getFrom());
}
use of org.apache.logging.log4j.core.net.MimeMessageBuilder in project logging-log4j2 by apache.
the class SmtpAppenderTest method testMessageFactorySetReplyTo.
@Test
public void testMessageFactorySetReplyTo() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String addresses = "testing1@example.com,testing2@example.com";
assertNull(builder.build().getReplyTo());
builder.setReplyTo(null);
assertNull(builder.build().getReplyTo());
builder.setReplyTo(addresses);
assertArrayEquals(InternetAddress.parse(addresses), builder.build().getReplyTo());
}
use of org.apache.logging.log4j.core.net.MimeMessageBuilder in project logging-log4j2 by apache.
the class SmtpAppenderTest method testMessageFactorySetSubject.
@Test
public void testMessageFactorySetSubject() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String subject = "Test Subject";
assertNull(builder.build().getSubject());
builder.setSubject(null);
assertNull(builder.build().getSubject());
builder.setSubject(subject);
assertEquals(subject, builder.build().getSubject());
}
use of org.apache.logging.log4j.core.net.MimeMessageBuilder in project logging-log4j2 by apache.
the class SmtpAppenderTest method testMessageFactorySetRecipients.
@Test
public void testMessageFactorySetRecipients() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String addresses = "testing1@example.com,testing2@example.com";
assertNull(builder.build().getRecipients(Message.RecipientType.TO));
builder.setRecipients(Message.RecipientType.TO, null);
assertNull(builder.build().getRecipients(Message.RecipientType.TO));
builder.setRecipients(Message.RecipientType.TO, addresses);
assertArrayEquals(InternetAddress.parse(addresses), builder.build().getRecipients(Message.RecipientType.TO));
}
Aggregations