1 package org.displaytag.jsptests; 2 3 import org.apache.commons.lang.StringUtils; 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.HTMLElement; 10 import com.meterware.httpunit.TableCell; 11 import com.meterware.httpunit.WebLink; 12 import com.meterware.httpunit.WebRequest; 13 import com.meterware.httpunit.WebResponse; 14 import com.meterware.httpunit.WebTable; 15 16 17 22 public class Displ129Test extends DisplaytagCase 23 { 24 25 28 public String getJspName() 29 { 30 return "DISPL-129.jsp"; 31 } 32 33 38 public void doTest(String jspName) throws Exception 39 { 40 WebRequest request = new GetMethodWebRequest(jspName); 41 42 ParamEncoder encoder = new ParamEncoder("table"); 43 String pageParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_PAGE); 44 request.setParameter(pageParameter, "2"); 45 46 WebResponse response = runner.getResponse(request); 47 48 if (log.isDebugEnabled()) 49 { 50 log.debug(response.getText()); 51 } 52 53 WebTable[] tables = response.getTables(); 54 assertEquals("Wrong number of tables in result.", 1, tables.length); 55 assertEquals("Wrong number of rows in result.", 3, tables[0].getRowCount()); 56 57 if (log.isDebugEnabled()) 58 { 59 log.debug(response.getText()); 60 } 61 62 assertEquals("Wrong column header.", "Number", tables[0].getCellAsText(0, 0)); 63 assertEquals("Wrong column content.", "3", tables[0].getCellAsText(1, 0)); 64 assertEquals("Wrong column content.", "4", tables[0].getCellAsText(2, 0)); 65 66 TableCell headerCell = tables[0].getTableCell(0, 0); 67 68 String cssClass = headerCell.getClassName(); 69 assertEqualsIgnoreOrder("Wrong css attributes.", new String []{"sortable", "sorted", "order2"}, StringUtils 70 .split(cssClass)); 71 72 WebLink[] headerLinks = headerCell.getLinks(); 73 assertEquals("Sorting link not found.", 1, headerLinks.length); 74 WebLink sortingLink = headerLinks[0]; 75 assertEqualsIgnoreOrder( 76 "Wrong parameters.", 77 new String []{"sort", "searchid", "dir", pageParameter}, 78 sortingLink.getParameterNames()); 79 80 HTMLElement pagebanner = response.getElementWithID("pagebanner"); 81 assertEquals("Wrong page banner", "10|3|4", pagebanner.getText()); 82 HTMLElement pagelinks = response.getElementWithID("pagelinks"); 83 assertEquals("Wrong page links", "1|[2]|3|4|5", pagelinks.getText()); 84 85 } 86 87 } | Popular Tags |