The following test takes about 5 seconds to complete due to the inclusion of m.saveChanges() .
import org.junit.Before; import org.junit.Test; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.MimeMessage; import java.io.IOException; import java.util.Properties; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @Test public void test1() throws MessagingException, IOException { Session s = Session.getDefaultInstance(new Properties()); MimeMessage m = new MimeMessage(s); m.setContent("<b>Hello</b>", "text/html; charset=utf-8"); m.saveChanges(); assertEquals(m.getContent(), "<b>Hello</b>"); assertEquals(m.getContentType(), "text/html; charset=utf-8"); }
I also made fun of the session with mockito, but this does not help:
Session s = mock(Session.class); when(s.getProperties()).thenReturn(new Properties());
What is the problem? What can I make fun of to speed up the process?
source share