1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.mail;
17
18 import java.net.MalformedURLException;
19 import java.net.URL;
20
21 /***
22 * JUnit test case for EmailAttachment Class
23 *
24 * @since 1.0
25 * @author <a href="mailto:corey.scott@gmail.com">Corey Scott</a>
26 * @version $Id: EmailAttachmentTest.java 240031 2005-08-25 10:01:21Z henning $
27 */
28
29 public class EmailAttachmentTest extends BaseEmailTestCase
30 {
31 /*** */
32 private EmailAttachment attachment = null;
33
34 /***
35 * @param name name
36 */
37 public EmailAttachmentTest(String name)
38 {
39 super(name);
40 }
41
42 /*** */
43 protected void setUp()
44 {
45 super.setUp();
46
47 this.attachment = new EmailAttachment();
48 }
49
50 /*** */
51 public void testGetSetDescription()
52 {
53
54 for (int i = 0; i < testCharsValid.length; i++)
55 {
56 this.attachment.setDescription(testCharsValid[i]);
57 assertEquals(testCharsValid[i], this.attachment.getDescription());
58 }
59 }
60
61 /*** */
62 public void testGetSetName()
63 {
64
65 for (int i = 0; i < testCharsValid.length; i++)
66 {
67 this.attachment.setName(testCharsValid[i]);
68 assertEquals(testCharsValid[i], this.attachment.getName());
69 }
70 }
71
72 /*** */
73 public void testGetSetPath()
74 {
75
76 for (int i = 0; i < testCharsValid.length; i++)
77 {
78 this.attachment.setPath(testCharsValid[i]);
79 assertEquals(testCharsValid[i], this.attachment.getPath());
80 }
81 }
82
83 /*** */
84 public void testGetSetURL()
85 {
86 String[] tests =
87 {
88 "http://localhost/",
89 "http://www.apache.org/",
90 "http://bad.url.com" };
91
92 for (int i = 0; i < tests.length; i++)
93 {
94 try
95 {
96 URL testURL = new URL(tests[i]);
97 this.attachment.setURL(testURL);
98 assertEquals(testURL, this.attachment.getURL());
99 }
100 catch (MalformedURLException e)
101 {
102 e.printStackTrace();
103 continue;
104 }
105 }
106 }
107
108 /*** */
109 public void testGetSetDisposition()
110 {
111
112 for (int i = 0; i < testCharsValid.length; i++)
113 {
114 this.attachment.setDisposition(testCharsValid[i]);
115 assertEquals(testCharsValid[i], this.attachment.getDisposition());
116 }
117 }
118
119 }