KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestELHtmlTag.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.strutsel.taglib.utils.DOMHelper;
27 import org.apache.strutsel.taglib.utils.JspTagTestCase;
28 import org.apache.strutsel.taglib.utils.TestHelper;
29
30 public class TestELHtmlTag
31     extends JspTagTestCase {
32
33     protected ELHtmlTag elHtmlTag = null;
34
35     public TestELHtmlTag(String JavaDoc theName) {
36         super(theName);
37     }
38     
39     public static void main(String JavaDoc[] args) {
40         junit.awtui.TestRunner.
41             main(new String JavaDoc[] { TestELHtmlTag.class.getName() });
42     }
43
44     public static Test suite() {
45         return new TestSuite(TestELHtmlTag.class);
46     }
47
48     public void setUp() {
49         elHtmlTag = new ELHtmlTag();
50         elHtmlTag.setPageContext(pageContext);
51     }
52
53     public void tearDown() {
54         elHtmlTag = null;
55     }
56
57     public void testPlain()
58         throws ServletException JavaDoc, JspException JavaDoc {
59
60         Boolean JavaDoc bool = new Boolean JavaDoc(true);
61         pageContext.setAttribute("localeFlag", bool);
62 // elHtmlTag.setLocale("${localeFlag}");
63
elHtmlTag.setLocaleExpr("true");
64         elHtmlTag.setXhtmlExpr("true");
65
66         int startTagReturn = elHtmlTag.doStartTag();
67         int afterBodyReturn = elHtmlTag.doAfterBody();
68         int endTagReturn = elHtmlTag.doEndTag();
69     }
70
71     public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
72         try {
73             TestHelper.printResponse(testResponse);
74
75             org.w3c.dom.Document JavaDoc document = testResponse.getDOM();
76             DOMHelper.printNode(document.getDocumentElement());
77
78             HashMap JavaDoc attrMap = new HashMap JavaDoc();
79             DOMHelper.recordFoundAttributes(testResponse.getDOM(),
80                                             "/html", attrMap);
81             DOMHelper.
82                 verifyAttributesPresent(attrMap,
83                                         new String JavaDoc[] { "lang", "xml:lang",
84                                                        "xmlns" },
85                                         false);
86         } catch (Exception JavaDoc ex) {
87             ex.printStackTrace();
88             fail();
89         }
90     }
91 }
92
Popular Tags