1 |
|
package test.mock.mail; |
2 |
|
|
3 |
|
import alt.javax.mail.Session; |
4 |
|
import alt.javax.mail.Transport; |
5 |
|
import com.mockobjects.ExpectationValue; |
6 |
|
import com.mockobjects.MockObject; |
7 |
|
|
8 |
|
import javax.mail.*; |
9 |
|
import java.util.HashMap; |
10 |
|
import java.util.Map; |
11 |
|
import java.util.Properties; |
12 |
|
|
|
|
| 29% |
Uncovered Elements: 66 (93) |
Complexity: 32 |
Complexity Density: 0.55 |
|
13 |
|
public class MockSession extends MockObject implements Session |
14 |
|
{ |
15 |
|
private Map urlAuthenticators = new HashMap(); |
16 |
|
private final ExpectationValue myDebug = new ExpectationValue("debug"); |
17 |
|
private Transport myTransport; |
18 |
|
private Properties props; |
19 |
|
private javax.mail.Session wrapped; |
20 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
21 |
1
|
public Session getInstance(Properties props, Authenticator authenticator)... |
22 |
|
{ |
23 |
1
|
getInstance(props); |
24 |
1
|
if (authenticator == null) |
25 |
0
|
setPasswordAuthentication(new URLName((String) props.get("mail.smtp.host")), null); |
26 |
|
else |
27 |
1
|
setPasswordAuthentication(new URLName((String) props.get("mail.smtp.host")), ((MockAuthenticator) authenticator).getPasswordAuthentication()); |
28 |
1
|
wrapped = javax.mail.Session.getInstance(props, authenticator); |
29 |
1
|
return this; |
30 |
|
} |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
32 |
1
|
public Session getInstance(Properties props)... |
33 |
|
{ |
34 |
1
|
this.props = props; |
35 |
1
|
wrapped = javax.mail.Session.getInstance(props); |
36 |
1
|
return this; |
37 |
|
} |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
39 |
0
|
public Session getDefaultInstance(Properties props, Authenticator authenticator)... |
40 |
|
{ |
41 |
0
|
wrapped = javax.mail.Session.getDefaultInstance(props, authenticator); |
42 |
0
|
return getInstance(props, authenticator); |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
45 |
0
|
public Session getDefaultInstance(Properties props)... |
46 |
|
{ |
47 |
0
|
wrapped = javax.mail.Session.getDefaultInstance(props); |
48 |
0
|
return getInstance(props); |
49 |
|
} |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
0
|
public void setExpectedDebug(boolean aDebug)... |
52 |
|
{ |
53 |
0
|
myDebug.setActual(aDebug); |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
0
|
public void setDebug(boolean aDebug)... |
57 |
|
{ |
58 |
0
|
myDebug.setActual(aDebug); |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
61 |
0
|
public boolean getDebug()... |
62 |
|
{ |
63 |
0
|
notImplemented(); |
64 |
0
|
return false; |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
67 |
0
|
public Provider getProviders()[]... |
68 |
|
{ |
69 |
0
|
notImplemented(); |
70 |
0
|
return null; |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
73 |
0
|
public Provider getProvider(String name)... |
74 |
|
{ |
75 |
0
|
notImplemented(); |
76 |
0
|
return null; |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
0
|
public void setProvider(Provider provider)... |
80 |
|
{ |
81 |
0
|
notImplemented(); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
84 |
10
|
public Transport getTransport()... |
85 |
|
{ |
86 |
10
|
if (myTransport == null) |
87 |
5
|
myTransport = new MockTransport(); |
88 |
10
|
return myTransport; |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0
|
public void setupGetTransport(Transport aTransport)... |
92 |
|
{ |
93 |
0
|
myTransport = aTransport; |
94 |
|
} |
95 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
96 |
5
|
public Transport getTransport(String aTransportName)... |
97 |
|
{ |
98 |
5
|
if ("smtp".equals(aTransportName)) |
99 |
5
|
return getTransport(); |
100 |
|
else |
101 |
0
|
return null; |
102 |
|
} |
103 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
104 |
0
|
public Transport getTransport(Address address)... |
105 |
|
{ |
106 |
0
|
notImplemented(); |
107 |
0
|
return null; |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
110 |
0
|
public Transport getTransport(Provider provider)... |
111 |
|
{ |
112 |
0
|
notImplemented(); |
113 |
0
|
return null; |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
116 |
0
|
public Transport getTransport(URLName url)... |
117 |
|
{ |
118 |
0
|
notImplemented(); |
119 |
0
|
return null; |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
122 |
0
|
public Store getStore()... |
123 |
|
{ |
124 |
0
|
notImplemented(); |
125 |
0
|
return null; |
126 |
|
} |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
128 |
0
|
public Store getStore(String name)... |
129 |
|
{ |
130 |
0
|
notImplemented(); |
131 |
0
|
return null; |
132 |
|
} |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
134 |
0
|
public Store getStore(URLName url)... |
135 |
|
{ |
136 |
0
|
notImplemented(); |
137 |
0
|
return null; |
138 |
|
} |
139 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
140 |
0
|
public Store getStore(Provider provider)... |
141 |
|
{ |
142 |
0
|
notImplemented(); |
143 |
0
|
return null; |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
146 |
0
|
public Folder getFolder()... |
147 |
|
{ |
148 |
0
|
notImplemented(); |
149 |
0
|
return null; |
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
152 |
0
|
public Folder getFolder(Store store)... |
153 |
|
{ |
154 |
0
|
notImplemented(); |
155 |
0
|
return null; |
156 |
|
} |
157 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
158 |
0
|
public Folder getFolder(URLName url)... |
159 |
|
{ |
160 |
0
|
notImplemented(); |
161 |
0
|
return null; |
162 |
|
} |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
164 |
1
|
public void setPasswordAuthentication(URLName url, PasswordAuthentication... |
165 |
|
passwordAuthentication) |
166 |
|
{ |
167 |
1
|
urlAuthenticators.put(url.getHost(), passwordAuthentication); |
168 |
|
} |
169 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
170 |
2
|
public PasswordAuthentication getPasswordAuthentication(URLName url)... |
171 |
|
{ |
172 |
2
|
return (PasswordAuthentication) urlAuthenticators.get(url.getHost()); |
173 |
|
} |
174 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
175 |
0
|
public PasswordAuthentication requestPasswordAuthentication(java.net.InetAddress address, int port, String protocol, String prompt, String defaultUserName)... |
176 |
|
{ |
177 |
0
|
notImplemented(); |
178 |
0
|
return null; |
179 |
|
} |
180 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
181 |
0
|
public Properties getProperties()... |
182 |
|
{ |
183 |
0
|
notImplemented(); |
184 |
0
|
return null; |
185 |
|
} |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
187 |
0
|
public String getProperty(String name)... |
188 |
|
{ |
189 |
0
|
notImplemented(); |
190 |
0
|
return null; |
191 |
|
} |
192 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
193 |
13
|
public javax.mail.Session getWrappedSession()... |
194 |
|
{ |
195 |
13
|
return wrapped; |
196 |
|
} |
197 |
|
|
198 |
|
} |