use of org.springframework.mail.MailPreparationException in project BroadleafCommerce by BroadleafCommerce.
the class EmailServiceMDP method onMessage.
/*
* (non-Javadoc)
* @see javax.jms.MessageListener#onMessage(javax.jms.Message)
*/
@SuppressWarnings("unchecked")
public void onMessage(Message message) {
try {
HashMap props = (HashMap) ((ObjectMessage) message).getObject();
messageCreator.sendMessage(props);
} catch (MailAuthenticationException e) {
throw new EmailException(e);
} catch (MailPreparationException e) {
throw new EmailException(e);
} catch (MailParseException e) {
throw new EmailException(e);
} catch (MailSendException e) {
/*
* TODO find the specific exception that results from the smtp
* server being down, and throw this as an EmailException.
* Otherwise, log and then swallow this exception, as it may have
* been possible that this email was actually sent.
*/
throw new EmailException(e);
} catch (JMSException e) {
throw new EmailException(e);
}
}
use of org.springframework.mail.MailPreparationException in project molgenis by molgenis.
the class ProgressImplTest method jobCanceledAndMailFails.
@Test
public void jobCanceledAndMailFails() {
doThrow(new MailPreparationException("fail!")).when(mailSender).send(any(SimpleMailMessage.class));
jobExecution.setProgressMessage("Downloading...");
jobExecution.setFailureEmail("test@test");
progress.start();
progress.canceled();
Mockito.verify(mailSender).send(any(SimpleMailMessage.class));
assertEquals(jobExecution.getProgressMessage(), "Downloading... (Mail not sent: fail!)");
}
use of org.springframework.mail.MailPreparationException in project spring-framework by spring-projects.
the class JavaMailSenderImpl method send.
@Override
public void send(MimeMessagePreparator... mimeMessagePreparators) throws MailException {
try {
List<MimeMessage> mimeMessages = new ArrayList<>(mimeMessagePreparators.length);
for (MimeMessagePreparator preparator : mimeMessagePreparators) {
MimeMessage mimeMessage = createMimeMessage();
preparator.prepare(mimeMessage);
mimeMessages.add(mimeMessage);
}
send(mimeMessages.toArray(new MimeMessage[0]));
} catch (MailException ex) {
throw ex;
} catch (MessagingException ex) {
throw new MailParseException(ex);
} catch (Exception ex) {
throw new MailPreparationException(ex);
}
}
use of org.springframework.mail.MailPreparationException in project molgenis by molgenis.
the class ProgressImplTest method jobSucceedsButMailFails.
@Test
public void jobSucceedsButMailFails() {
doThrow(new MailPreparationException("fail!")).when(mailSender).send(any(SimpleMailMessage.class));
jobExecution.setProgressMessage("Job finished.");
jobExecution.setSuccessEmail("test@test");
progress.start();
progress.success();
Mockito.verify(mailSender).send(any(SimpleMailMessage.class));
assertEquals(jobExecution.getProgressMessage(), "Job finished. (Mail not sent: fail!)");
}
use of org.springframework.mail.MailPreparationException in project molgenis by molgenis.
the class ProgressImplTest method jobFailsAndMailFails.
@Test
public void jobFailsAndMailFails() {
doThrow(new MailPreparationException("fail!")).when(mailSender).send(any(SimpleMailMessage.class));
jobExecution.setProgressMessage("Downloading...");
jobExecution.setFailureEmail("test@test");
progress.start();
String exceptionMessage = "x is not a number";
Exception ex = new IllegalArgumentException(exceptionMessage);
progress.failed(ex);
Mockito.verify(mailSender).send(any(SimpleMailMessage.class));
assertEquals(jobExecution.getProgressMessage(), exceptionMessage + " (Mail not sent: fail!)");
}
Aggregations