List of usage examples for org.apache.commons.mail EmailException EmailException
public EmailException()
EmailException
with no detail message. From source file:jmockit.tutorial.domain.MyBusinessServiceTest.java
@Test(expected = EmailException.class) public void doBusinessOperationXyzWithInvalidEmailAddress() throws Exception { new Expectations() { {// ww w .j a v a 2 s. c om anyEmail.addTo((String) withNotNull()); result = new EmailException(); } }; EntityX data = new EntityX(5, "abc", "someone@somewhere.com"); new MyBusinessService(data).doBusinessOperationXyz(); }
From source file:jmockit.tutorial.domain.MyBusinessService_MockupsAPI_Test.java
@Test(expected = EmailException.class) public void doBusinessOperationXyzWithInvalidEmailAddress() throws Exception { new MockUp<Email>() { @Mock/* w ww.j a v a 2 s. co m*/ Email addTo(String email) throws EmailException { assertNotNull(email); throw new EmailException(); } }; new MyBusinessService(data).doBusinessOperationXyz(); }
From source file:com.intuit.wasabi.email.impl.EmailServiceImplTest.java
@Test(expected = WasabiEmailException.class) public void testSend() throws EmailException { EmailTextProcessor emailTextProcessor = mock(EmailTextProcessor.class); Email simpleEmail = mock(Email.class); EmailServiceImpl emailService = spy( new EmailServiceImpl(false, "host1", "from1", "prefix", emailTextProcessor)); emailService.setActive(true);//from w w w . j av a 2 s . co m when(emailService.createSimpleMailService()).thenReturn(simpleEmail); emailService.send("mocked subject", "mocked message", "mock@example.com"); verify(simpleEmail, times(1)).send(); doThrow(new EmailException()).when(simpleEmail).send(); emailService.send("mocked subject", "mocked message", "mock@example.com"); }