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 public class EmailAttachmentTest extends BaseEmailTestCase
30 {
31
32 private EmailAttachment attachment;
33
34
35
36
37 public EmailAttachmentTest(String name)
38 {
39 super(name);
40 }
41
42
43
44 @Override
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://foo.notexisting.org" };
93
94 for (int i = 0; i < tests.length; i++)
95 {
96 try
97 {
98 URL testURL = new URL(tests[i]);
99 this.attachment.setURL(testURL);
100 assertEquals(testURL, this.attachment.getURL());
101 }
102 catch (MalformedURLException e)
103 {
104 fail(e.getMessage());
105 }
106 }
107 }
108
109
110 public void testGetSetDisposition()
111 {
112
113 for (int i = 0; i < testCharsValid.length; i++)
114 {
115 this.attachment.setDisposition(testCharsValid[i]);
116 assertEquals(testCharsValid[i], this.attachment.getDisposition());
117 }
118 }
119
120 }