use of jakarta.mail.internet.AddressException in project spring-framework by spring-projects.
the class JavaMailSenderTests method javaMailSenderWithParseExceptionOnSimpleMessage.
@Test
public void javaMailSenderWithParseExceptionOnSimpleMessage() {
MockJavaMailSender sender = new MockJavaMailSender();
SimpleMailMessage simpleMessage = new SimpleMailMessage();
simpleMessage.setFrom("");
try {
sender.send(simpleMessage);
} catch (MailParseException ex) {
// expected
boolean condition = ex.getCause() instanceof AddressException;
assertThat(condition).isTrue();
}
}
use of jakarta.mail.internet.AddressException in project spring-framework by spring-projects.
the class JavaMailSenderTests method javaMailSenderWithParseExceptionOnMimeMessagePreparator.
@Test
public void javaMailSenderWithParseExceptionOnMimeMessagePreparator() {
MockJavaMailSender sender = new MockJavaMailSender();
MimeMessagePreparator preparator = mimeMessage -> mimeMessage.setFrom(new InternetAddress(""));
try {
sender.send(preparator);
} catch (MailParseException ex) {
// expected
boolean condition = ex.getCause() instanceof AddressException;
assertThat(condition).isTrue();
}
}
Aggregations