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