@Test public void deliverShouldReturnTemporaryErrorWhenFirstDNSProblem() throws Exception { Mail mail = FakeMail.builder().name("name").recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build(); UnmodifiableIterator<HostAddress> empty = ImmutableList.<HostAddress>of().iterator(); when(dnsHelper.retrieveHostAddressIterator(MailAddressFixture.JAMES_APACHE_ORG)).thenReturn(empty); ExecutionResult executionResult = testee.deliver(mail); assertThat(executionResult.getExecutionState()).isEqualTo(ExecutionResult.ExecutionState.TEMPORARY_FAILURE); }
public ExecutionResult deliver(Mail mail) { try { return tryDeliver(mail); } catch (SendFailedException sfe) { return handleSenderFailedException(mail, sfe); } catch (MessagingException ex) { boolean isPermanent = new EnhancedMessagingException(ex).isServerError(); return logAndReturn(mail, ExecutionResult.onFailure(isPermanent, ex)); } catch (Exception ex) { LOGGER.error("Generic exception = permanent failure: {}", ex.getMessage(), ex); return logAndReturn(mail, ExecutionResult.permanentFailure(ex)); } }
MailDelivrer { public ExecutionResult deliver(Mail mail) { try { return tryDeliver(mail); } catch (SendFailedException sfe) { return handleSenderFailedException(mail, sfe); } catch (MessagingException ex) { boolean isPermanent = new EnhancedMessagingException(ex).isServerError(); return logAndReturn(mail, ExecutionResult.onFailure(isPermanent, ex)); } catch (Exception ex) { LOGGER.error("Generic exception = permanent failure: {}", ex.getMessage(), ex); return logAndReturn(mail, ExecutionResult.permanentFailure(ex)); } } }
MailDelivrer { public ExecutionResult deliver(Mail mail) { try { return tryDeliver(mail); } catch (SendFailedException sfe) { return handleSenderFailedException(mail, sfe); } catch (MessagingException ex) { boolean isPermanent = new EnhancedMessagingException(ex).isServerError(); return logAndReturn(mail, ExecutionResult.onFailure(isPermanent, ex)); } catch (Exception ex) { LOGGER.error("Generic exception = permanent failure: {}", ex.getMessage(), ex); return logAndReturn(mail, ExecutionResult.permanentFailure(ex)); } } MailDelivrer(RemoteDeliveryConfiguration configuration, MailDelivrerToHost mailDelivrerToHost, DNSService dnsServer, Bouncer bouncer); @VisibleForTesting  MailDelivrer(RemoteDeliveryConfiguration configuration, MailDelivrerToHost mailDelivrerToHost, DnsHelper dnsHelper, Bouncer bouncer); }
MailDelivrer { public ExecutionResult deliver(Mail mail) { try { return tryDeliver(mail); } catch (SendFailedException sfe) { return handleSenderFailedException(mail, sfe); } catch (MessagingException ex) { boolean isPermanent = new EnhancedMessagingException(ex).isServerError(); return logAndReturn(mail, ExecutionResult.onFailure(isPermanent, ex)); } catch (Exception ex) { LOGGER.error("Generic exception = permanent failure: {}", ex.getMessage(), ex); return logAndReturn(mail, ExecutionResult.permanentFailure(ex)); } } MailDelivrer(RemoteDeliveryConfiguration configuration, MailDelivrerToHost mailDelivrerToHost, DNSService dnsServer, Bouncer bouncer); @VisibleForTesting  MailDelivrer(RemoteDeliveryConfiguration configuration, MailDelivrerToHost mailDelivrerToHost, DnsHelper dnsHelper, Bouncer bouncer); ExecutionResult deliver(Mail mail); }
MailDelivrer { public ExecutionResult deliver(Mail mail) { try { return tryDeliver(mail); } catch (SendFailedException sfe) { return handleSenderFailedException(mail, sfe); } catch (MessagingException ex) { boolean isPermanent = new EnhancedMessagingException(ex).isServerError(); return logAndReturn(mail, ExecutionResult.onFailure(isPermanent, ex)); } catch (Exception ex) { LOGGER.error("Generic exception = permanent failure: {}", ex.getMessage(), ex); return logAndReturn(mail, ExecutionResult.permanentFailure(ex)); } } MailDelivrer(RemoteDeliveryConfiguration configuration, MailDelivrerToHost mailDelivrerToHost, DNSService dnsServer, Bouncer bouncer); @VisibleForTesting  MailDelivrer(RemoteDeliveryConfiguration configuration, MailDelivrerToHost mailDelivrerToHost, DnsHelper dnsHelper, Bouncer bouncer); ExecutionResult deliver(Mail mail);  }