KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > webui > list > WebListTest


1 /*
2 Copyright (c) 2003 eInnovation Inc. All rights reserved
3
4 This library is free software; you can redistribute it and/or modify it under the terms
5 of the GNU Lesser General Public License as published by the Free Software Foundation;
6 either version 2.1 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the GNU Lesser General Public License for more details.
11 */

12
13 package com.openedit.webui.list;
14
15 import javax.swing.DefaultListModel JavaDoc;
16
17 import junit.framework.TestCase;
18
19 import org.dom4j.Document;
20
21
22 /**
23  * Test for WebList
24  *
25  * @author Eric Galluzzo
26  */

27 public class WebListTest extends TestCase
28 {
29     protected WebList fieldWebList;
30
31     public WebListTest(String JavaDoc inName)
32     {
33         super(inName);
34     }
35
36     /**
37      * DOCUMENT ME!
38      *
39      * @throws Exception
40      */

41     public void testRender() throws Exception JavaDoc
42     {
43         Document doc = fieldWebList.render();
44         assertEquals(
45             
46         // Look ma, fake XML formatting!
47
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
48             "<list:list xmlns:list=\"http://www.einnovation.com/xmlns/WebUI/List\">" +
49             "<list:node url=\"first-node.html\">" + "<list:name>First node</list:name>" +
50             "</list:node>" + "</list:list>", doc.asXML());
51     }
52
53     /**
54      * DOCUMENT ME!
55      *
56      * @throws Exception
57      */

58     public void testRender_WithName() throws Exception JavaDoc
59     {
60         fieldWebList.setName("foo");
61
62         Document doc = fieldWebList.render();
63         assertEquals(
64             
65         // Look ma, fake XML formatting!
66
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
67             "<list:list xmlns:list=\"http://www.einnovation.com/xmlns/WebUI/List\" name=\"foo\">" +
68             "<list:node url=\"first-node.html\">" + "<list:name>First node</list:name>" +
69             "</list:node>" + "</list:list>", doc.asXML());
70     }
71
72     /*
73      * @see TestCase#setUp()
74      */

75     protected void setUp() throws Exception JavaDoc
76     {
77         DefaultListModel JavaDoc model = new DefaultListModel JavaDoc();
78         DefaultWebListNode node = new DefaultWebListNode("First node", "first-node.html");
79         model.addElement(node);
80         fieldWebList = new WebList(model);
81         fieldWebList.setCellRenderer(new DefaultWebListCellRenderer());
82     }
83 }
84
Popular Tags