001: /*
002: * Copyright 2001-2005 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.mail;
017:
018: import java.net.MalformedURLException;
019: import java.net.URL;
020:
021: /**
022: * JUnit test case for EmailAttachment Class
023: *
024: * @since 1.0
025: * @author <a href="mailto:corey.scott@gmail.com">Corey Scott</a>
026: * @version $Id: EmailAttachmentTest.java 240031 2005-08-25 10:01:21Z henning $
027: */
028:
029: public class EmailAttachmentTest extends BaseEmailTestCase {
030: /** */
031: private EmailAttachment attachment = null;
032:
033: /**
034: * @param name name
035: */
036: public EmailAttachmentTest(String name) {
037: super (name);
038: }
039:
040: /** */
041: protected void setUp() {
042: super .setUp();
043: // reusable objects to be used across multiple tests
044: this .attachment = new EmailAttachment();
045: }
046:
047: /** */
048: public void testGetSetDescription() {
049:
050: for (int i = 0; i < testCharsValid.length; i++) {
051: this .attachment.setDescription(testCharsValid[i]);
052: assertEquals(testCharsValid[i], this .attachment
053: .getDescription());
054: }
055: }
056:
057: /** */
058: public void testGetSetName() {
059:
060: for (int i = 0; i < testCharsValid.length; i++) {
061: this .attachment.setName(testCharsValid[i]);
062: assertEquals(testCharsValid[i], this .attachment.getName());
063: }
064: }
065:
066: /** */
067: public void testGetSetPath() {
068:
069: for (int i = 0; i < testCharsValid.length; i++) {
070: this .attachment.setPath(testCharsValid[i]);
071: assertEquals(testCharsValid[i], this .attachment.getPath());
072: }
073: }
074:
075: /** */
076: public void testGetSetURL() {
077: String[] tests = { "http://localhost/",
078: "http://www.apache.org/", "http://bad.url.com" };
079:
080: for (int i = 0; i < tests.length; i++) {
081: try {
082: URL testURL = new URL(tests[i]);
083: this .attachment.setURL(testURL);
084: assertEquals(testURL, this .attachment.getURL());
085: } catch (MalformedURLException e) {
086: e.printStackTrace();
087: continue;
088: }
089: }
090: }
091:
092: /** */
093: public void testGetSetDisposition() {
094:
095: for (int i = 0; i < testCharsValid.length; i++) {
096: this.attachment.setDisposition(testCharsValid[i]);
097: assertEquals(testCharsValid[i], this.attachment
098: .getDisposition());
099: }
100: }
101:
102: }
|