KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestELFrameTag.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 javax.servlet.ServletException JavaDoc;
22 import javax.servlet.http.HttpServletResponse 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.JspTagTestCase;
27
28
29 public class TestELFrameTag
30     extends JspTagTestCase {
31
32     private static final String JavaDoc FORWARD_VALUE = "stuff";
33     private static final String JavaDoc PATH_VALUE = "/stuff";
34
35     protected ELFrameTag elFrameTag = null;
36
37     public TestELFrameTag(String JavaDoc theName) {
38         super(theName);
39     }
40
41     public static void main(String JavaDoc[] args) {
42         junit.awtui.TestRunner.
43             main(new String JavaDoc[] { TestELFrameTag.class.getName() });
44     }
45
46     public static Test suite() {
47         return new TestSuite(TestELFrameTag.class);
48     }
49
50     public void setUp() {
51         elFrameTag = new ELFrameTag();
52         elFrameTag.setPageContext(pageContext);
53     }
54
55     public void tearDown() {
56         elFrameTag = null;
57     }
58
59     /**
60      * Tests all attributes unset, which is illegal. At least one of
61      * "forward", "href", or "page" needs to be set.
62      */

63     public void testPlain()
64                    throws ServletException JavaDoc, JspException JavaDoc {
65         HttpServletResponse JavaDoc response =
66             (HttpServletResponse JavaDoc)pageContext.getResponse();
67
68         boolean gotCorrectException = false;
69
70         try {
71             int startTagReturn = elFrameTag.doStartTag();
72         } catch (JspException JavaDoc ex) {
73             // This is supposed to happen.
74
gotCorrectException = true;
75         } catch (Exception JavaDoc ex) {
76             fail();
77         }
78
79         if (!gotCorrectException)
80             fail();
81     }
82
83 // /**
84
// * Tests setting "forward" attribute to a Forward with a null Path.
85
// */
86
// public void testForward()
87
// throws ServletException, JspException {
88

89 // ActionServlet actionServlet = new ActionServlet();
90
// actionServlet.init(pageContext.getServletConfig());
91
// actionServlet.init();
92

93 // ApplicationConfig appConfig = new ApplicationConfig("");
94

95 // pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
96
// PageContext.APPLICATION_SCOPE);
97

98 // ActionForward actionForward = new ActionForward();
99
// actionForward.setName(FORWARD_VALUE);
100
// actionForward.setPath(PATH_VALUE);
101
// appConfig.addForwardConfig(actionForward);
102

103 // elFrameTag.setForwardExpr(FORWARD_VALUE);
104

105 // HttpServletResponse response =
106
// (HttpServletResponse)pageContext.getResponse();
107

108 // int startTagReturn = elFrameTag.doStartTag();
109
// int afterBodyReturn = elFrameTag.doAfterBody();
110
// int endTagReturn = elFrameTag.doEndTag();
111
// }
112

113 // public void endForward(com.meterware.httpunit.WebResponse testResponse) {
114
// try {
115
// TestHelper.printResponse(testResponse);
116

117 // org.w3c.dom.Document document = testResponse.getDOM();
118
// DOMHelper.printNode(document.getDocumentElement());
119
// } catch (Exception ex) {
120
// ex.printStackTrace();
121
// fail();
122
// }
123
// }
124
}
125
Popular Tags