KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > view > jsp > html > test > BaseTagTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.view.jsp.html.test;
8
9
10 import javax.servlet.jsp.JspException JavaDoc;
11 import javax.servlet.jsp.tagext.Tag JavaDoc;
12
13 import com.inversoft.junit.JspTestCase;
14 import com.inversoft.verge.mvc.view.jsp.html.ImgTag;
15
16
17 /**
18  * <p>
19  * This class stores the tests for the base html attributes
20  * of the html tags
21  * </p>
22  *
23  * @author Brian Pontarelli
24  * @since 2.0
25  * @version 2.0
26  */

27 public class BaseTagTest extends JspTestCase {
28
29     /**
30      * Constructor for BaseTagTest.
31      * @param name
32      */

33     public BaseTagTest(String JavaDoc name) {
34         super(name);
35         setLocal(true);
36     }
37
38
39     /**
40      * Tests the id attribute
41      */

42     public void testId() {
43         ImgTag tag = new ImgTag();
44         tag.setPageContext(pageContext);
45         tag.setId("test");
46         tag.setSrc("test.gif");
47         
48         try {
49             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
50             String JavaDoc tagStr = getPageContext().getMockOut().getText();
51
52             System.out.println("Img tag: " + tagStr);
53             assertEquals("Should have tag", tagStr,
54                 "<img id=\"test\" SRC=\"test.gif\"/>");
55         } catch (JspException JavaDoc e) {
56             fail(e.toString());
57         }
58     }
59
60     /**
61      * Tests the accept attribute
62      */

63     public void testAccept() {
64         ImgTag tag = new ImgTag();
65         tag.setPageContext(pageContext);
66         tag.setSrc("test.gif");
67         tag.setAccept("test");
68         
69         try {
70             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
71             String JavaDoc tagStr = getPageContext().getMockOut().getText();
72
73             System.out.println("Img tag: " + tagStr);
74             assertEquals("Should have tag", tagStr,
75                 "<img SRC=\"test.gif\" accept=\"test\"/>");
76         } catch (JspException JavaDoc e) {
77             fail(e.toString());
78         }
79     }
80
81     /**
82      * Tests the accesskey attribute
83      */

84     public void testAccessKey() {
85         ImgTag tag = new ImgTag();
86         tag.setPageContext(pageContext);
87         tag.setSrc("test.gif");
88         tag.setAccesskey("test");
89         
90         try {
91             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
92             String JavaDoc tagStr = getPageContext().getMockOut().getText();
93
94             System.out.println("Img tag: " + tagStr);
95             assertEquals("Should have tag", tagStr,
96                 "<img SRC=\"test.gif\" accesskey=\"test\"/>");
97         } catch (JspException JavaDoc e) {
98             fail(e.toString());
99         }
100     }
101
102     /**
103      * Tests the alt attribute
104      */

105     public void testAlt() {
106         ImgTag tag = new ImgTag();
107         tag.setPageContext(pageContext);
108         tag.setSrc("test.gif");
109         tag.setAlt("test");
110         
111         try {
112             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
113             String JavaDoc tagStr = getPageContext().getMockOut().getText();
114
115             System.out.println("Img tag: " + tagStr);
116             assertEquals("Should have tag", tagStr,
117                 "<img SRC=\"test.gif\" alt=\"test\"/>");
118         } catch (JspException JavaDoc e) {
119             fail(e.toString());
120         }
121     }
122
123     /**
124      * Tests the dir attribute
125      */

126     public void testDir() {
127         ImgTag tag = new ImgTag();
128         tag.setPageContext(pageContext);
129         tag.setSrc("test.gif");
130         tag.setDir("test");
131         
132         try {
133             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
134             String JavaDoc tagStr = getPageContext().getMockOut().getText();
135
136             System.out.println("Img tag: " + tagStr);
137             assertEquals("Should have tag", tagStr,
138                 "<img SRC=\"test.gif\" dir=\"test\"/>");
139         } catch (JspException JavaDoc e) {
140             fail(e.toString());
141         }
142     }
143
144     /**
145      * Tests the lang attribute
146      */

147     public void testLang() {
148         ImgTag tag = new ImgTag();
149         tag.setPageContext(pageContext);
150         tag.setSrc("test.gif");
151         tag.setLang("test");
152         
153         try {
154             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
155             String JavaDoc tagStr = getPageContext().getMockOut().getText();
156
157             System.out.println("Img tag: " + tagStr);
158             assertEquals("Should have tag", tagStr,
159                 "<img SRC=\"test.gif\" lang=\"test\"/>");
160         } catch (JspException JavaDoc e) {
161             fail(e.toString());
162         }
163     }
164
165     /**
166      * Tests the onclick attribute
167      */

168     public void testOnClick() {
169         ImgTag tag = new ImgTag();
170         tag.setPageContext(pageContext);
171         tag.setSrc("test.gif");
172         tag.setOnclick("test");
173         
174         try {
175             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
176             String JavaDoc tagStr = getPageContext().getMockOut().getText();
177
178             System.out.println("Img tag: " + tagStr);
179             assertEquals("Should have tag", tagStr,
180                 "<img SRC=\"test.gif\" onclick=\"test\"/>");
181         } catch (JspException JavaDoc e) {
182             fail(e.toString());
183         }
184     }
185
186     /**
187      * Tests the ondblclick attribute
188      */

189     public void testOnDblClick() {
190         ImgTag tag = new ImgTag();
191         tag.setPageContext(pageContext);
192         tag.setSrc("test.gif");
193         tag.setOndblclick ("test");
194         
195         try {
196             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
197             String JavaDoc tagStr = getPageContext().getMockOut().getText();
198
199             System.out.println("Img tag: " + tagStr);
200             assertEquals("Should have tag", tagStr,
201                 "<img SRC=\"test.gif\" ondblclick=\"test\"/>");
202         } catch (JspException JavaDoc e) {
203             fail(e.toString());
204         }
205     }
206
207     /**
208      * Tests the onkeydown attribute
209      */

210     public void testOnKeyDown() {
211         ImgTag tag = new ImgTag();
212         tag.setPageContext(pageContext);
213         tag.setSrc("test.gif");
214         tag.setOnkeydown("test");
215         
216         try {
217             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
218             String JavaDoc tagStr = getPageContext().getMockOut().getText();
219
220             System.out.println("Img tag: " + tagStr);
221             assertEquals("Should have tag", tagStr,
222                 "<img SRC=\"test.gif\" onkeydown=\"test\"/>");
223         } catch (JspException JavaDoc e) {
224             fail(e.toString());
225         }
226     }
227
228     /**
229      * Tests the onkeypress attribute
230      */

231     public void testOnKeyPress() {
232         ImgTag tag = new ImgTag();
233         tag.setPageContext(pageContext);
234         tag.setSrc("test.gif");
235         tag.setOnkeypress("test");
236         
237         try {
238             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
239             String JavaDoc tagStr = getPageContext().getMockOut().getText();
240
241             System.out.println("Img tag: " + tagStr);
242             assertEquals("Should have tag", tagStr,
243                 "<img SRC=\"test.gif\" onkeypress=\"test\"/>");
244         } catch (JspException JavaDoc e) {
245             fail(e.toString());
246         }
247     }
248
249     /**
250      * Tests the onkeydown attribute
251      */

252     public void testOnKeyUp() {
253         ImgTag tag = new ImgTag();
254         tag.setPageContext(pageContext);
255         tag.setSrc("test.gif");
256         tag.setOnkeyup("test");
257         
258         try {
259             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
260             String JavaDoc tagStr = getPageContext().getMockOut().getText();
261
262             System.out.println("Img tag: " + tagStr);
263             assertEquals("Should have tag", tagStr,
264                 "<img SRC=\"test.gif\" onkeyup=\"test\"/>");
265         } catch (JspException JavaDoc e) {
266             fail(e.toString());
267         }
268     }
269
270     /**
271      * Tests the onmousedown attribute
272      */

273     public void testOnMouseDown() {
274         ImgTag tag = new ImgTag();
275         tag.setPageContext(pageContext);
276         tag.setSrc("test.gif");
277         tag.setOnmousedown("test");
278         
279         try {
280             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
281             String JavaDoc tagStr = getPageContext().getMockOut().getText();
282
283             System.out.println("Img tag: " + tagStr);
284             assertEquals("Should have tag", tagStr,
285                 "<img SRC=\"test.gif\" onmousedown=\"test\"/>");
286         } catch (JspException JavaDoc e) {
287             fail(e.toString());
288         }
289     }
290
291     /**
292      * Tests the onmousemove attribute
293      */

294     public void testOnMouseMove() {
295         ImgTag tag = new ImgTag();
296         tag.setPageContext(pageContext);
297         tag.setSrc("test.gif");
298         tag.setOnmousemove("test");
299         
300         try {
301             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
302             String JavaDoc tagStr = getPageContext().getMockOut().getText();
303
304             System.out.println("Img tag: " + tagStr);
305             assertEquals("Should have tag", tagStr,
306                 "<img SRC=\"test.gif\" onmousemove=\"test\"/>");
307         } catch (JspException JavaDoc e) {
308             fail(e.toString());
309         }
310     }
311
312     /**
313      * Tests the onmouseout attribute
314      */

315     public void testOnMouseOut() {
316         ImgTag tag = new ImgTag();
317         tag.setPageContext(pageContext);
318         tag.setSrc("test.gif");
319         tag.setOnmouseout("test");
320         
321         try {
322             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
323             String JavaDoc tagStr = getPageContext().getMockOut().getText();
324
325             System.out.println("Img tag: " + tagStr);
326             assertEquals("Should have tag", tagStr,
327                 "<img SRC=\"test.gif\" onmouseout=\"test\"/>");
328         } catch (JspException JavaDoc e) {
329             fail(e.toString());
330         }
331     }
332
333     /**
334      * Tests the onmouseover attribute
335      */

336     public void testOnMouseOver() {
337         ImgTag tag = new ImgTag();
338         tag.setPageContext(pageContext);
339         tag.setSrc("test.gif");
340         tag.setOnmouseover("test");
341         
342         try {
343             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
344             String JavaDoc tagStr = getPageContext().getMockOut().getText();
345
346             System.out.println("Img tag: " + tagStr);
347             assertEquals("Should have tag", tagStr,
348                 "<img SRC=\"test.gif\" onmouseover=\"test\"/>");
349         } catch (JspException JavaDoc e) {
350             fail(e.toString());
351         }
352     }
353
354     /**
355      * Tests the onmouseup attribute
356      */

357     public void testOnMouseUp() {
358         ImgTag tag = new ImgTag();
359         tag.setPageContext(pageContext);
360         tag.setSrc("test.gif");
361         tag.setOnmouseup("test");
362         
363         try {
364             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
365             String JavaDoc tagStr = getPageContext().getMockOut().getText();
366
367             System.out.println("Img tag: " + tagStr);
368             assertEquals("Should have tag", tagStr,
369                 "<img SRC=\"test.gif\" onmouseup=\"test\"/>");
370         } catch (JspException JavaDoc e) {
371             fail(e.toString());
372         }
373     }
374
375     /**
376      * Tests the style attribute
377      */

378     public void testStyle() {
379         ImgTag tag = new ImgTag();
380         tag.setPageContext(pageContext);
381         tag.setSrc("test.gif");
382         tag.setStyle("test");
383         
384         try {
385             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
386             String JavaDoc tagStr = getPageContext().getMockOut().getText();
387
388             System.out.println("Img tag: " + tagStr);
389             assertEquals("Should have tag", tagStr,
390                 "<img SRC=\"test.gif\" style=\"test\"/>");
391         } catch (JspException JavaDoc e) {
392             fail(e.toString());
393         }
394     }
395
396     /**
397      * Tests the class attribute
398      */

399     public void testClass() {
400         ImgTag tag = new ImgTag();
401         tag.setPageContext(pageContext);
402         tag.setSrc("test.gif");
403         tag.setStyleclass("test");
404         
405         try {
406             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
407             String JavaDoc tagStr = getPageContext().getMockOut().getText();
408
409             System.out.println("Img tag: " + tagStr);
410             assertEquals("Should have tag", tagStr,
411                 "<img SRC=\"test.gif\" class=\"test\"/>");
412         } catch (JspException JavaDoc e) {
413             fail(e.toString());
414         }
415     }
416
417     /**
418      * Tests the tabindex attribute
419      */

420     public void testTabIndex() {
421         ImgTag tag = new ImgTag();
422         tag.setPageContext(pageContext);
423         tag.setSrc("test.gif");
424         tag.setTabindex("test");
425         
426         try {
427             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
428             String JavaDoc tagStr = getPageContext().getMockOut().getText();
429
430             System.out.println("Img tag: " + tagStr);
431             assertEquals("Should have tag", tagStr,
432                 "<img SRC=\"test.gif\" tabindex=\"test\"/>");
433         } catch (JspException JavaDoc e) {
434             fail(e.toString());
435         }
436     }
437
438     /**
439      * Tests the title attribute
440      */

441     public void testTitle() {
442         ImgTag tag = new ImgTag();
443         tag.setPageContext(pageContext);
444         tag.setSrc("test.gif");
445         tag.setTitle("test");
446         
447         try {
448             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
449             String JavaDoc tagStr = getPageContext().getMockOut().getText();
450
451             System.out.println("Img tag: " + tagStr);
452             assertEquals("Should have tag", tagStr,
453                 "<img SRC=\"test.gif\" title=\"test\"/>");
454         } catch (JspException JavaDoc e) {
455             fail(e.toString());
456         }
457     }
458 }
Popular Tags