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 test.mock.mail.MockAuthenticator;
18 import test.mock.mail.MockSession;
19
20 import javax.mail.Authenticator;
21 import javax.mail.internet.AddressException;
22 import javax.mail.internet.InternetAddress;
23 import javax.naming.NamingException;
24
25 import alt.javax.mail.Session;
26
27 public class MockSMTPMailServer extends SMTPMailServerImpl
28 {
29 Session mockSession;
30
31 public MockSMTPMailServer(Long id, String name, String description, String from, String prefix, boolean isSession, String location, String username, String password)
32 {
33 super(id, name, description, from, prefix, isSession, location, username, password);
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 protected Authenticator getAuthenticator()
72 {
73 return new MockAuthenticator(getUsername(), getPassword());
74 }
75
76 public Session getSession() throws NamingException, MailException
77 {
78 if (mockSession == null)
79 mockSession = new MockSession();
80 return mockSession;
81 }
82 }