@Test void testValidateConnectionInvalidConnection() { Exception exception = assertThrows( IllegalStateException.class, () -> javaMailSenderFactory.validateConnection(mailSettings)); assertEquals("Unable to ping to host", exception.getMessage()); }
@Override public void validateConnection(MailSettings mailSettings) { LOG.info("Validating mail settings..."); try { JavaMailSenderImpl sender = createMailSender(mailSettings); sender.testConnection(); LOG.info("OK."); } catch (MessagingException ex) { String message = format("Unable to ping to %s", mailSettings.getHost()); LOG.info(message, ex); throw new IllegalStateException(message, ex); } }
JavaMailSenderFactory implements MailSenderFactory { @Override public void validateConnection(MailSettings mailSettings) { LOG.info("Validating mail settings..."); try { JavaMailSenderImpl sender = createMailSender(mailSettings); sender.testConnection(); LOG.info("OK."); } catch (MessagingException ex) { String message = format("Unable to ping to %s", mailSettings.getHost()); LOG.info(message, ex); throw new IllegalStateException(message, ex); } } }
JavaMailSenderFactory implements MailSenderFactory { @Override public void validateConnection(MailSettings mailSettings) { LOG.info("Validating mail settings..."); try { JavaMailSenderImpl sender = createMailSender(mailSettings); sender.testConnection(); LOG.info("OK."); } catch (MessagingException ex) { String message = format("Unable to ping to %s", mailSettings.getHost()); LOG.info(message, ex); throw new IllegalStateException(message, ex); } }  }
JavaMailSenderFactory implements MailSenderFactory { @Override public void validateConnection(MailSettings mailSettings) { LOG.info("Validating mail settings..."); try { JavaMailSenderImpl sender = createMailSender(mailSettings); sender.testConnection(); LOG.info("OK."); } catch (MessagingException ex) { String message = format("Unable to ping to %s", mailSettings.getHost()); LOG.info(message, ex); throw new IllegalStateException(message, ex); } }  @Override JavaMailSenderImpl createMailSender(MailSettings mailSettings); @Override void validateConnection(MailSettings mailSettings); }
JavaMailSenderFactory implements MailSenderFactory { @Override public void validateConnection(MailSettings mailSettings) { LOG.info("Validating mail settings..."); try { JavaMailSenderImpl sender = createMailSender(mailSettings); sender.testConnection(); LOG.info("OK."); } catch (MessagingException ex) { String message = format("Unable to ping to %s", mailSettings.getHost()); LOG.info(message, ex); throw new IllegalStateException(message, ex); } }  @Override JavaMailSenderImpl createMailSender(MailSettings mailSettings); @Override void validateConnection(MailSettings mailSettings); static final String MAIL_SMTP_STARTTLS_ENABLE; static final String MAIL_SMTP_QUITWAIT; static final String MAIL_SMTP_AUTH; static final String MAIL_SMTP_FROM_ADDRESS; }