KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > html > TestLinkTag2


1 /*
2  * $Id: TestLinkTag2.java 54929 2004-10-16 16:38:42Z 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 package org.apache.struts.taglib.html;
19
20 import java.util.Locale JavaDoc;
21
22 import javax.servlet.jsp.PageContext JavaDoc;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import org.apache.cactus.JspTestCase;
28 import org.apache.struts.Globals;
29 import org.apache.struts.taglib.SimpleBeanForTesting;
30
31 /**
32  * Suite of unit tests for the
33  * <code>org.apache.struts.taglib.html.FrameTag</code> class.
34  *
35  */

36 public class TestLinkTag2 extends JspTestCase {
37
38     /**
39      * Defines the testcase name for JUnit.
40      *
41      * @param theName the testcase's name.
42      */

43     public TestLinkTag2(String JavaDoc theName) {
44         super(theName);
45     }
46
47     /**
48      * Start the tests.
49      *
50      * @param theArgs the arguments. Not used
51      */

52     public static void main(String JavaDoc[] theArgs) {
53         junit.awtui.TestRunner.main(new String JavaDoc[] {TestLinkTag2.class.getName()});
54     }
55
56     /**
57      * @return a test suite (<code>TestSuite</code>) that includes all methods
58      * starting with "test"
59      */

60     public static Test suite() {
61         // All methods starting with "test" will be executed in the test suite.
62
return new TestSuite(TestLinkTag2.class);
63     }
64
65     private void runMyTest(String JavaDoc whichTest, String JavaDoc locale) throws Exception JavaDoc {
66         pageContext.setAttribute(Globals.LOCALE_KEY, new Locale JavaDoc(locale, locale), PageContext.SESSION_SCOPE);
67         pageContext.setAttribute(Constants.BEAN_KEY, new SimpleBeanForTesting("Test Value"), PageContext.REQUEST_SCOPE);
68         request.setAttribute("runTest", whichTest);
69         pageContext.forward("/test/org/apache/struts/taglib/html/TestLinkTag2.jsp");
70     }
71
72     /*
73      * Testing FrameTag.
74      */

75
76 //--------Testing attributes using forward------
77
public void testLinkForwardOnblur() throws Exception JavaDoc {
78         runMyTest("testLinkForwardOnblur", "");
79     }
80
81     public void testLinkForwardOnclick() throws Exception JavaDoc {
82         runMyTest("testLinkForwardOnclick", "");
83     }
84
85     public void testLinkForwardOndblclick() throws Exception JavaDoc {
86         runMyTest("testLinkForwardOndblclick", "");
87     }
88
89     public void testLinkForwardOnfocus() throws Exception JavaDoc {
90         runMyTest("testLinkForwardOnfocus", "");
91     }
92
93     public void testLinkForwardOnkeydown() throws Exception JavaDoc {
94         runMyTest("testLinkForwardOnkeydown", "");
95     }
96
97     public void testLinkForwardOnkeypress() throws Exception JavaDoc {
98         runMyTest("testLinkForwardOnkeypress", "");
99     }
100
101     public void testLinkForwardOnkeyup() throws Exception JavaDoc {
102         runMyTest("testLinkForwardOnkeyup", "");
103     }
104
105     public void testLinkForwardOnmousedown() throws Exception JavaDoc {
106         runMyTest("testLinkForwardOnmousedown", "");
107     }
108
109     public void testLinkForwardOnmousemove() throws Exception JavaDoc {
110         runMyTest("testLinkForwardOnmousemove", "");
111     }
112
113     public void testLinkForwardOnmouseout() throws Exception JavaDoc {
114         runMyTest("testLinkForwardOnmouseout", "");
115     }
116
117     public void testLinkForwardOnmouseover() throws Exception JavaDoc {
118         runMyTest("testLinkForwardOnmouseover", "");
119     }
120
121     public void testLinkForwardOnmouseup() throws Exception JavaDoc {
122         runMyTest("testLinkForwardOnmouseup", "");
123     }
124
125     public void testLinkForwardParamIdParamNameNoScope() throws Exception JavaDoc {
126                 pageContext.setAttribute("paramName", "paramValue", PageContext.REQUEST_SCOPE);
127         runMyTest("testLinkForwardParamIdParamNameNoScope", "");
128     }
129
130     public void testLinkForwardParamIdParamNameParamPropertyNoScope() throws Exception JavaDoc {
131         SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
132                 pageContext.setAttribute("testingParamProperty", sbft, PageContext.REQUEST_SCOPE);
133         runMyTest("testLinkForwardParamIdParamNameParamPropertyNoScope", "");
134     }
135
136     public void testLinkForwardParamIdParamNameApplicationScope() throws Exception JavaDoc {
137                 pageContext.setAttribute("paramName", "paramValue", PageContext.APPLICATION_SCOPE);
138         runMyTest("testLinkForwardParamIdParamNameApplicationScope", "");
139     }
140
141     public void testLinkForwardParamIdParamNameParamPropertyApplicationScope() throws Exception JavaDoc {
142         SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
143                 pageContext.setAttribute("testingParamProperty", sbft, PageContext.APPLICATION_SCOPE);
144         runMyTest("testLinkForwardParamIdParamNameParamPropertyApplicationScope", "");
145     }
146
147     public void testLinkForwardParamIdParamNameSessionScope() throws Exception JavaDoc {
148                 pageContext.setAttribute("paramName", "paramValue", PageContext.SESSION_SCOPE);
149         runMyTest("testLinkForwardParamIdParamNameSessionScope", "");
150     }
151
152     public void testLinkForwardParamIdParamNameParamPropertySessionScope() throws Exception JavaDoc {
153         SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
154                 pageContext.setAttribute("testingParamProperty", sbft, PageContext.SESSION_SCOPE);
155         runMyTest("testLinkForwardParamIdParamNameParamPropertySessionScope", "");
156     }
157
158     public void testLinkForwardParamIdParamNameRequestScope() throws Exception JavaDoc {
159                 pageContext.setAttribute("paramName", "paramValue", PageContext.REQUEST_SCOPE);
160         runMyTest("testLinkForwardParamIdParamNameRequestScope", "");
161     }
162
163     public void testLinkForwardParamIdParamNameParamPropertyRequestScope() throws Exception JavaDoc {
164         SimpleBeanForTesting sbft = new SimpleBeanForTesting("paramPropertyValue");
165                 pageContext.setAttribute("testingParamProperty", sbft, PageContext.REQUEST_SCOPE);
166         runMyTest("testLinkForwardParamIdParamNameParamPropertyRequestScope", "");
167     }
168
169
170     public void testLinkForwardStyle() throws Exception JavaDoc {
171         runMyTest("testLinkForwardStyle", "");
172     }
173
174     public void testLinkForwardStyleClass() throws Exception JavaDoc {
175         runMyTest("testLinkForwardStyleClass", "");
176     }
177
178     public void testLinkForwardStyleId() throws Exception JavaDoc {
179         runMyTest("testLinkForwardStyleId", "");
180     }
181
182     public void testLinkForwardTabIndex() throws Exception JavaDoc {
183         runMyTest("testLinkForwardTabIndex", "");
184     }
185
186     public void testLinkForwardTarget() throws Exception JavaDoc {
187         runMyTest("testLinkForwardTarget", "");
188     }
189
190
191
192
193
194
195
196     public void testLinkForwardTitle() throws Exception JavaDoc {
197         runMyTest("testLinkForwardTitle", "");
198     }
199
200     public void testLinkForwardTitleKey() throws Exception JavaDoc {
201         runMyTest("testLinkForwardTitleKey", "");
202     }
203     public void testLinkForwardTitleKeyAlt() throws Exception JavaDoc {
204         runMyTest("testLinkForwardTitleKeyAlt", "");
205     }
206
207     public void testLinkForwardTransaction() throws Exception JavaDoc {
208         pageContext.setAttribute(Globals.TRANSACTION_TOKEN_KEY, "Some_Token_Here", PageContext.SESSION_SCOPE);
209         runMyTest("testLinkForwardTransaction", "");
210     }
211
212
213
214
215
216 }
217
Popular Tags