KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > taglib > html > DivTagCactusTest


1 /*
2  * Copyright 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.taglib.html;
17
18 import com.meterware.httpunit.WebForm;
19 import com.meterware.httpunit.WebResponse;
20 import org.w3c.dom.Node JavaDoc;
21 import org.w3c.dom.NodeList JavaDoc;
22
23 import org.apache.cactus.ServletTestCase;
24
25 import javax.servlet.RequestDispatcher JavaDoc;
26
27 /**
28  * @author Bill Dudney (latest modification by $Author: bdudney $)
29  * @version $Revision: 1.1 $ $Date: 2004/11/08 13:33:50 $
30  * $Log: DivTagCactusTest.java,v $
31  * Revision 1.1 2004/11/08 13:33:50 bdudney
32  * adding a cactus test for the new div element
33  *
34  */

35 public class DivTagCactusTest
36         extends ServletTestCase
37 {
38
39     public DivTagCactusTest(String JavaDoc name) {
40         super(name);
41     }
42
43     public void testSimpleRender() throws Exception JavaDoc {
44         RequestDispatcher JavaDoc rd = config.getServletContext().getRequestDispatcher(
45                 "/DivTagCactusTest.jsf");
46         // render the page for the first time
47
rd.forward(request, response);
48     }
49
50     public void endSimpleRender(WebResponse response)
51             throws Exception JavaDoc
52     {
53         WebForm form = response.getFormWithID("testForm");
54         Node JavaDoc node = form.getDOMSubtree();
55         NodeList JavaDoc lst = node.getChildNodes();
56         assertTrue(2 <= lst.getLength());
57         Node JavaDoc div = lst.item(0);
58         assertEquals("bar", div.getAttributes().getNamedItem("style").getNodeValue());
59         div = lst.item(1);
60         assertEquals("foo", div.getAttributes().getNamedItem("class").getNodeValue());
61     }
62 }
63
Popular Tags