KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.displaytag.jsptests;
2
3 import org.displaytag.test.DisplaytagCase;
4
5 import com.meterware.httpunit.GetMethodWebRequest;
6 import com.meterware.httpunit.WebLink;
7 import com.meterware.httpunit.WebRequest;
8 import com.meterware.httpunit.WebResponse;
9 import com.meterware.httpunit.WebTable;
10
11
12 /**
13  * Test for DISPL-237 - Problems using sorting, defaultsort
14  * @author Fabrizio Giustina
15  * @version $Revision$ ($Author$)
16  */

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

23     public String JavaDoc getJspName()
24     {
25         return "DISPL-237.jsp";
26     }
27
28     /**
29      * Trying to reproduce an IndexOutOfBoundsException...
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         WebRequest request = new GetMethodWebRequest(jspName);
36
37         WebResponse response = runner.getResponse(request);
38
39         if (log.isDebugEnabled())
40         {
41             log.debug(response.getText());
42         }
43
44         WebTable[] tables = response.getTables();
45         assertEquals("Wrong number of tables", 1, tables.length);
46
47         WebLink[] links = response.getLinks();
48         assertEquals("Wrong number of links", 6, links.length); // sorting + paging
49

50         response = links[3].click(); // sort again on default sorted column
51
response = links[4].click(); // sort on column 2
52

53         response.getTables();
54         assertEquals("Wrong number of tables", 1, tables.length);
55
56         links = response.getLinks();
57         assertEquals("Wrong number of links", 6, links.length); // sorting + paging
58

59         response = links[0].click(); // go to page 2
60

61         response.getTables();
62         assertEquals("Wrong number of tables", 1, tables.length);
63
64         links = response.getLinks();
65         assertEquals("Wrong number of links", 6, links.length); // sorting + paging
66

67         response = links[3].click(); // sort again on default sorted column
68
response = links[4].click(); // sort on column 2
69

70     }
71
72 }
Popular Tags