KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > util > AddressListRendererTest


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.util;
17
18 import junit.framework.TestCase;
19
20 import org.columba.ristretto.message.Address;
21
22 /**
23  */

24 public class AddressListRendererTest extends TestCase {
25
26     /**
27      * Test to send an empty Address array to the list.
28      * The method should not throw an <code>IndexOutOfBoundsException</code> if
29      * an empty array is sent in.
30      * @author redsolo
31      */

32     public void testRenderWithEmptyArray() {
33         Address[] addresses = new Address[0];
34         AddressListRenderer.renderToHTMLWithLinks(addresses);
35     }
36
37     /**
38      * Test the rendering with only one address.
39      */

40     public void testRenderWithSingleItem() {
41         Address[] addresses = new Address[] {new Address("email@internet.org")};
42         String JavaDoc actual = AddressListRenderer.renderToHTMLWithLinks(addresses).toString();
43         String JavaDoc expected = "<a HREF=\"mailto:email@internet.org\">email@internet.org</a>";
44         assertEquals("address wasnt rendered correctly", expected.toLowerCase(), actual.toLowerCase());
45     }
46
47     /**
48      * Test the rendering with multiple addresses.
49      */

50     public void testRenderWithMultipleItems() {
51         Address[] addresses = new Address[] {new Address("email@internet.org"), new Address("ftp@internet.org"), new Address("web@internet.org")};
52         String JavaDoc actual = AddressListRenderer.renderToHTMLWithLinks(addresses).toString();
53         String JavaDoc expected = "<a HREF=\"mailto:email@internet.org\">email@internet.org</a>, "
54                 + "<a HREF=\"mailto:ftp@internet.org\">ftp@internet.org</a>, "
55                 + "<a HREF=\"mailto:web@internet.org\">web@internet.org</a>";
56         assertEquals("addresses wasnt rendered correctly", expected.toLowerCase(), actual.toLowerCase());
57     }
58
59     /**
60      * Test the rendering with multiple addresses with display names.
61      */

62     public void testRenderWithDisplayName() {
63         Address[] addresses = new Address[] {new Address("Emil", "email@internet.org"), new Address("Alfred", "ftp@internet.org")};
64         String JavaDoc actual = AddressListRenderer.renderToHTMLWithLinks(addresses).toString();
65         String JavaDoc expected = "<a HREF=\"mailto:email@internet.org\">Emil</a>, "
66             + "<a HREF=\"mailto:ftp@internet.org\">Alfred</a>";
67         assertEquals("address wasnt rendered correctly", expected.toLowerCase(), actual.toLowerCase());
68     }
69 }
70
Popular Tags