KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > displaytag > jsptests > CaptionTagTest


1 package org.displaytag.jsptests;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.displaytag.test.DisplaytagCase;
5
6 import com.meterware.httpunit.GetMethodWebRequest;
7 import com.meterware.httpunit.WebRequest;
8 import com.meterware.httpunit.WebResponse;
9 import com.meterware.httpunit.WebTable;
10
11
12 /**
13  * Tests for caption tag.
14  * @author Fabrizio Giustina
15  * @version $Revision: 894 $ ($Author: fgiust $)
16  */

17 public class CaptionTagTest extends DisplaytagCase
18 {
19
20     /**
21      * @see org.displaytag.test.DisplaytagCase#getJspName()
22      */

23     public String JavaDoc getJspName()
24     {
25         return "caption.jsp";
26     }
27
28     /**
29      * Verifies that the generated page contains a table with a caption and checks all the caption html attributes.
30      * @param jspName jsp name, with full path
31      * @throws Exception any axception thrown during test.
32      */

33     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
34     {
35
36         WebRequest request = new GetMethodWebRequest(jspName);
37
38         WebResponse response = runner.getResponse(request);
39
40         if (log.isDebugEnabled())
41         {
42             log.debug("RESPONSE: " + response.getText());
43         }
44
45         WebTable[] tables = response.getTables();
46
47         assertEquals("Wrong number of tables.", 1, tables.length);
48
49         String JavaDoc output = response.getText();
50
51         assertTrue("Caption tag missing", StringUtils.contains(output, "<caption"));
52
53         assertTrue(StringUtils.contains(output, "class=\"theclass\""));
54         assertTrue(StringUtils.contains(output, "dir=\"thedir\""));
55         assertTrue(StringUtils.contains(output, "id=\"theid\""));
56         assertTrue(StringUtils.contains(output, "lang=\"thelang\""));
57         assertTrue(StringUtils.contains(output, "style=\"thestyle\""));
58         assertTrue(StringUtils.contains(output, "title=\"thetitle\""));
59
60     }
61 }
Popular Tags