1 package org.displaytag.jsptests; 2 3 import org.displaytag.properties.SortOrderEnum; 4 import org.displaytag.tags.TableTagParameters; 5 import org.displaytag.test.DisplaytagCase; 6 import org.displaytag.util.ParamEncoder; 7 8 import com.meterware.httpunit.GetMethodWebRequest; 9 import com.meterware.httpunit.WebLink; 10 import com.meterware.httpunit.WebRequest; 11 import com.meterware.httpunit.WebResponse; 12 import com.meterware.httpunit.WebTable; 13 14 15 20 public class Displ243Test extends DisplaytagCase 21 { 22 23 26 public String getJspName() 27 { 28 return "DISPL-243.jsp"; 29 } 30 31 36 public void doTest(String jspName) throws Exception 37 { 38 WebRequest request = new GetMethodWebRequest(jspName); 39 ParamEncoder encoder = new ParamEncoder("table"); 40 String orderParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_ORDER); 41 42 WebResponse response = runner.getResponse(request); 43 44 if (log.isDebugEnabled()) 45 { 46 log.debug(response.getText()); 47 } 48 49 WebTable[] tables = response.getTables(); 50 assertEquals("Wrong number of tables.", 1, tables.length); 51 52 WebLink[] links = response.getLinks(); 53 assertEquals("Wrong number of links.", 1, links.length); 54 55 assertEquals("wrong sorting order", Integer.toString(SortOrderEnum.DESCENDING.getCode()), links[0] 56 .getParameterValues(orderParameter)[0]); 57 58 for (int j = 0; j < 10; j++) 60 { 61 String expectedSortOrder = (j % 2 == 0) ? SortOrderEnum.ASCENDING.getName() : SortOrderEnum.DESCENDING 62 .getName(); 63 64 response = links[0].click(); 65 66 if (log.isDebugEnabled()) 67 { 68 log.debug(response.getText()); 69 } 70 71 tables = response.getTables(); 72 assertEquals("Wrong number of tables.", 1, tables.length); 73 74 links = response.getLinks(); 75 assertEquals("Wrong number of links.", 1, links.length); 76 77 assertEquals("Wrong sorting order for iteration " + j, expectedSortOrder, SortOrderEnum.fromCode( 78 Integer.parseInt(links[0].getParameterValues(orderParameter)[0])).getName()); 79 } 80 81 } 82 83 } | Popular Tags |