KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.displaytag.jsptests;
2
3 import org.displaytag.test.DisplaytagCase;
4
5 import com.meterware.httpunit.GetMethodWebRequest;
6 import com.meterware.httpunit.WebRequest;
7 import com.meterware.httpunit.WebResponse;
8
9
10 /**
11  * Tests for DISPL-9 - Send user back to Page 1 on Desc/Asc.
12  * @author Fabrizio Giustina
13  * @version $Revision: 876 $ ($Author: fgiust $)
14  */

15 public class Displ009Test extends DisplaytagCase
16 {
17
18     /**
19      * @see org.displaytag.test.DisplaytagCase#getJspName()
20      */

21     public String JavaDoc getJspName()
22     {
23         return "DISPL-009.jsp";
24     }
25
26     /**
27      * Verifies that the generated page contains a table with the expected number of columns.
28      * @param jspName jsp name, with full path
29      * @throws Exception any axception thrown during test.
30      */

31     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
32     {
33         WebRequest request = new GetMethodWebRequest(jspName);
34         WebResponse response;
35
36         // step 0
37
response = runner.getResponse(request);
38
39         // link[0] is a column header
40
// link[1] is paging link
41

42         // 1. User clicks column 3 header to sort ascending. User returned to page 1.
43
response = response.getLinks()[0].click();
44         assertNotNull("Not in page one as expected", response.getElementWithID("PAGEONE"));
45
46         // 2. User clicks column 3 header to sort descending. User returned to page 1.
47
response = response.getLinks()[0].click();
48         assertNotNull("Not in page one as expected", response.getElementWithID("PAGEONE"));
49
50         // 3. User navigates to page other than page 1.
51
response = response.getLinks()[1].click();
52         assertNotNull("Not in page two as expected", response.getElementWithID("OTHERPAGE"));
53
54         // 4. User clicks column 3 header to sort ascending. User NOT returned to page 1, rather, user stays on current
55
// page number.
56
response = response.getLinks()[0].click();
57         assertNotNull("Not in page one as expected", response.getElementWithID("PAGEONE"));
58     }
59
60 }
Popular Tags