KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestImageTag8.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.ArrayList JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Locale JavaDoc;
23 import java.util.StringTokenizer JavaDoc;
24
25 import javax.servlet.jsp.PageContext JavaDoc;
26
27 import junit.framework.Test;
28 import junit.framework.TestSuite;
29
30 import org.apache.cactus.JspTestCase;
31 import org.apache.struts.Globals;
32 import org.apache.struts.taglib.SimpleBeanForTesting;
33
34 /**
35  * Suite of unit tests for the
36  * <code>org.apache.struts.taglib.html.ImageTag</code> class.
37  *
38  */

39 public class TestImageTag8 extends JspTestCase {
40
41     /**
42      * Defines the testcase name for JUnit.
43      *
44      * @param theName the testcase's name.
45      */

46     public TestImageTag8(String JavaDoc theName) {
47         super(theName);
48     }
49
50     /**
51      * Start the tests.
52      *
53      * @param theArgs the arguments. Not used
54      */

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

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

78
79 //--------Testing attributes using page------
80

81     public void testImageSrcKeyOnmousedown() throws Exception JavaDoc {
82         runMyTest("testImageSrcKeyOnmousedown", "");
83     }
84
85     public void testImageSrcKeyOnmousemove() throws Exception JavaDoc {
86         runMyTest("testImageSrcKeyOnmousemove", "");
87     }
88
89     public void testImageSrcKeyOnmouseout() throws Exception JavaDoc {
90         runMyTest("testImageSrcKeyOnmouseout", "");
91     }
92
93     public void testImageSrcKeyOnmouseover() throws Exception JavaDoc {
94         runMyTest("testImageSrcKeyOnmouseover", "");
95     }
96
97     public void testImageSrcKeyOnmouseup() throws Exception JavaDoc {
98         runMyTest("testImageSrcKeyOnmouseup", "");
99     }
100
101     public void testImageSrcKeyProperty() throws Exception JavaDoc {
102         runMyTest("testImageSrcKeyProperty", "");
103     }
104
105     public void testImageSrcKeyStyle() throws Exception JavaDoc {
106         runMyTest("testImageSrcKeyStyle", "");
107     }
108
109     public void testImageSrcKeyStyleClass() throws Exception JavaDoc {
110         runMyTest("testImageSrcKeyStyleClass", "");
111     }
112
113     public void testImageSrcKeyStyleId() throws Exception JavaDoc {
114         runMyTest("testImageSrcKeyStyleId", "");
115     }
116
117     public void testImageSrcKeyTabindex() throws Exception JavaDoc {
118         runMyTest("testImageSrcKeyTabindex", "");
119     }
120
121     public void testImageSrcKeyTitle() throws Exception JavaDoc {
122         runMyTest("testImageSrcKeyTitle", "");
123     }
124
125     public void testImageSrcKeyTitleKeyDefaultBundle() throws Exception JavaDoc {
126         runMyTest("testImageSrcKeyTitleKeyDefaultBundle", "");
127     }
128
129     public void testImageSrcKeyTitleKeyAlternateBundle() throws Exception JavaDoc {
130         runMyTest("testImageSrcKeyTitleKeyAlternateBundle", "");
131     }
132
133     public void testImageSrcKeyTitleKeyDefaultBundle_fr() throws Exception JavaDoc {
134         runMyTest("testImageSrcKeyTitleKeyDefaultBundle_fr", "fr");
135     }
136
137     public void testImageSrcKeyTitleKeyAlternateBundle_fr() throws Exception JavaDoc {
138         runMyTest("testImageSrcKeyTitleKeyAlternateBundle_fr", "fr");
139     }
140
141     public void testImageSrcKeyIndexedArray() throws Exception JavaDoc {
142         ArrayList JavaDoc lst = new ArrayList JavaDoc();
143         lst.add("Test Message");
144         pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
145         runMyTest("testImageSrcKeyIndexedArray", "");
146         }
147
148     public void testImageSrcKeyIndexedArrayProperty() throws Exception JavaDoc {
149         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
150         ArrayList JavaDoc lst = new ArrayList JavaDoc();
151         lst.add("Test Message");
152         sbft.setList(lst);
153         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
154         runMyTest("testImageSrcKeyIndexedArrayProperty", "");
155         }
156
157     public void testImageSrcKeyIndexedMap() throws Exception JavaDoc {
158         HashMap JavaDoc map = new HashMap JavaDoc();
159         map.put("tst1", "Test Message");
160         pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
161         runMyTest("testImageSrcKeyIndexedMap", "");
162         }
163
164     public void testImageSrcKeyIndexedMapProperty() throws Exception JavaDoc {
165         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
166         HashMap JavaDoc map = new HashMap JavaDoc();
167         map.put("tst1", "Test Message");
168         sbft.setMap(map);
169         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
170         runMyTest("testImageSrcKeyIndexedMapProperty", "");
171         }
172
173     public void testImageSrcKeyIndexedEnumeration() throws Exception JavaDoc {
174         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
175         pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
176         runMyTest("testImageSrcKeyIndexedEnumeration", "");
177         }
178
179     public void testImageSrcKeyIndexedEnumerationProperty() throws Exception JavaDoc {
180         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
181         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
182         sbft.setEnumeration(st);
183         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
184         runMyTest("testImageSrcKeyIndexedEnumerationProperty", "");
185         }
186
187
188
189
190
191 }
192
Popular Tags