1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.transport.mail.support;
18
19 import java.net.URI;
20 import javax.mail.URLName;
21 import javax.mail.internet.InternetAddress;
22
23 import org.junit.Assert;
24 import org.junit.Test;
25
26 public class MailTransportUtilsTest {
27
28 @Test
29 public void testToPasswordProtectedString() throws Exception {
30 URLName name = new URLName("imap://john:[email protected]/INBOX");
31 String result = MailTransportUtils.toPasswordProtectedString(name);
32 Assert.assertEquals("Password found in string", -1, result.indexOf("secret"));
33 }
34
35 @Test
36 public void testGetTo() throws Exception {
37 URI uri = new URI("mailto:[email protected]?subject=current-issue");
38 InternetAddress to = MailTransportUtils.getTo(uri);
39 Assert.assertEquals("Invalid destination", new InternetAddress("[email protected]"), to);
40
41 uri = new URI("mailto:[email protected]");
42 to = MailTransportUtils.getTo(uri);
43 Assert.assertEquals("Invalid destination", new InternetAddress("[email protected]"), to);
44 }
45
46 @Test
47 public void testGetSubject() throws Exception {
48 URI uri = new URI("mailto:[email protected]?subject=current-issue");
49 String subject = MailTransportUtils.getSubject(uri);
50 Assert.assertEquals("Invalid destination", "current-issue", subject);
51
52 uri = new URI("mailto:[email protected]");
53 subject = MailTransportUtils.getSubject(uri);
54 Assert.assertNull("Invalid destination", subject);
55 }
56 }