1
2
3
4
5
6
7
8
9
10
11 package test.mock.mail.server;
12
13 import com.atlassian.mail.MailException;
14 import com.atlassian.mail.MailUtils;
15 import com.atlassian.mail.Email;
16 import com.atlassian.mail.server.impl.SMTPMailServerImpl;
17 import org.mockito.MockSettings;
18
19 import javax.mail.Authenticator;
20 import javax.mail.internet.AddressException;
21 import javax.mail.internet.InternetAddress;
22 import javax.naming.NamingException;
23
24 import javax.mail.Session;
25
26 public class MockSMTPMailServer extends SMTPMailServerImpl
27 {
28 private final Session mockSession;
29
30 public MockSMTPMailServer(Long id, String name, String description, String from, String prefix, boolean isSession, String location, String username, String password, Session session)
31 {
32 super(id, name, description, from, prefix, isSession, location, username, password);
33 this.mockSession = session;
34 }
35
36 public void send(Email email) throws MailException
37 {
38 super.send(email);
39 }
40
41 public InternetAddress[] parseAddresses(String addresses) throws AddressException
42 {
43 return MailUtils.parseAddresses(addresses);
44 }
45
46 public String getDefaultFrom()
47 {
48 return super.getDefaultFrom();
49 }
50
51 public void setDefaultFrom(String from)
52 {
53 super.setDefaultFrom(from);
54 }
55
56 public String getPrefix()
57 {
58 return super.getPrefix();
59 }
60
61 public void setPrefix(String prefix)
62 {
63 super.setPrefix(prefix);
64 }
65
66 public void setSessionServer(boolean sessionServer)
67 {
68 super.setSessionServer(sessionServer);
69 }
70
71
72 public Session getSession() throws NamingException, MailException
73 {
74 return mockSession;
75 }
76 }