01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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(
42: "email@internet.org") };
43: String actual = AddressListRenderer.renderToHTMLWithLinks(
44: addresses).toString();
45: String expected = "<a href=\"mailto:email@internet.org\">email@internet.org</a>";
46: assertEquals("address wasnt rendered correctly", expected
47: .toLowerCase(), actual.toLowerCase());
48: }
49:
50: /**
51: * Test the rendering with multiple addresses.
52: */
53: public void testRenderWithMultipleItems() {
54: Address[] addresses = new Address[] {
55: new Address("email@internet.org"),
56: new Address("ftp@internet.org"),
57: new Address("web@internet.org") };
58: String actual = AddressListRenderer.renderToHTMLWithLinks(
59: addresses).toString();
60: String expected = "<a href=\"mailto:email@internet.org\">email@internet.org</a>, "
61: + "<a href=\"mailto:ftp@internet.org\">ftp@internet.org</a>, "
62: + "<a href=\"mailto:web@internet.org\">web@internet.org</a>";
63: assertEquals("addresses wasnt rendered correctly", expected
64: .toLowerCase(), actual.toLowerCase());
65: }
66:
67: /**
68: * Test the rendering with multiple addresses with display names.
69: */
70: public void testRenderWithDisplayName() {
71: Address[] addresses = new Address[] {
72: new Address("Emil", "email@internet.org"),
73: new Address("Alfred", "ftp@internet.org") };
74: String actual = AddressListRenderer.renderToHTMLWithLinks(
75: addresses).toString();
76: String expected = "<a href=\"mailto:email@internet.org\">Emil</a>, "
77: + "<a href=\"mailto:ftp@internet.org\">Alfred</a>";
78: assertEquals("address wasnt rendered correctly", expected
79: .toLowerCase(), actual.toLowerCase());
80: }
81: }
|