org.springframework.mail.MailAuthenticationException Java Examples
The following examples show how to use
org.springframework.mail.MailAuthenticationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FeedbackControllerTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void submitAuthenticationErrorWhileSendingMail() throws Exception { List<String> adminEmails = Collections.singletonList("[email protected]"); when(userService.getSuEmailAddresses()).thenReturn(adminEmails); when(appSettings.getRecaptchaIsEnabled()).thenReturn(true); when(reCaptchaService.validate("validCaptcha")).thenReturn(true); SimpleMailMessage expected = new SimpleMailMessage(); expected.setTo("[email protected]"); expected.setCc("[email protected]"); expected.setReplyTo("[email protected]"); expected.setSubject("[feedback-app123] Feedback form"); expected.setText("Feedback from First Last ([email protected]):\n\n" + "Feedback.\nLine two."); doThrow(new MailAuthenticationException("ERRORRR!")).when(mailSender).send(expected); mockMvcFeedback .perform( MockMvcRequestBuilders.post(FeedbackController.URI) .param("name", "First Last") .param("subject", "Feedback form") .param("email", "[email protected]") .param("feedback", "Feedback.\nLine two.") .param("recaptcha", "validCaptcha")) .andExpect(status().isOk()) .andExpect(view().name("view-feedback")) .andExpect(model().attribute("feedbackForm", hasProperty("submitted", equalTo(false)))) .andExpect( model() .attribute( "feedbackForm", hasProperty( "errorMessage", equalTo( "Unfortunately, we were unable to send the mail containing " + "your feedback. Please contact the administrator.")))); verify(reCaptchaService, times(1)).validate("validCaptcha"); }