KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > html > TestELHiddenTag


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

18
19 package org.apache.strutsel.taglib.html;
20
21 import java.util.HashMap JavaDoc;
22 import javax.servlet.ServletException JavaDoc;
23 import javax.servlet.jsp.JspException JavaDoc;
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26 import org.apache.struts.util.LabelValueBean;
27 import org.apache.strutsel.taglib.utils.JspTagTestCase;
28 import org.apache.strutsel.taglib.utils.TestHelper;
29 import org.apache.strutsel.taglib.utils.DOMHelper;
30
31 public class TestELHiddenTag
32     extends JspTagTestCase {
33
34     protected ELHiddenTag elHiddenTag = null;
35
36     public TestELHiddenTag(String JavaDoc theName) {
37         super(theName);
38     }
39     
40     public static void main(String JavaDoc[] args) {
41         junit.awtui.TestRunner.
42             main(new String JavaDoc[] { TestELHiddenTag.class.getName() });
43     }
44
45     public static Test suite() {
46         return new TestSuite(TestELHiddenTag.class);
47     }
48
49     public void setUp() {
50         elHiddenTag = new ELHiddenTag();
51         elHiddenTag.setPageContext(pageContext);
52     }
53
54     public void tearDown() {
55         elHiddenTag = null;
56     }
57
58     public void testPlain()
59         throws ServletException JavaDoc, JspException JavaDoc {
60
61         LabelValueBean bean = new LabelValueBean("junk", "stuff");
62         pageContext.setAttribute("testFormBean", bean);
63
64         elHiddenTag.setNameExpr("testFormBean");
65         elHiddenTag.setPropertyExpr("value");
66
67         int startTagReturn = elHiddenTag.doStartTag();
68         int afterBodyReturn = elHiddenTag.doAfterBody();
69         int endTagReturn = elHiddenTag.doEndTag();
70     }
71
72     public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
73         try {
74             TestHelper.printResponse(testResponse);
75
76             org.w3c.dom.Document JavaDoc document = testResponse.getDOM();
77             DOMHelper.printNode(document.getDocumentElement());
78
79             HashMap JavaDoc attrMap = new HashMap JavaDoc();
80             DOMHelper.recordFoundAttributes(testResponse.getDOM(),
81                                             "/html/body/input", attrMap);
82             DOMHelper.
83                 verifyAttributesPresent(attrMap,
84                                         new String JavaDoc[] { "type", "name",
85                                                        "value" },
86                                         false);
87         } catch (Exception JavaDoc ex) {
88             ex.printStackTrace();
89             fail();
90         }
91     }
92 }
93
Popular Tags