1 package org.displaytag.jsptests; 2 3 import org.displaytag.tags.TableTagParameters; 4 import org.displaytag.test.DisplaytagCase; 5 import org.displaytag.util.ParamEncoder; 6 7 import com.meterware.httpunit.GetMethodWebRequest; 8 import com.meterware.httpunit.WebLink; 9 import com.meterware.httpunit.WebRequest; 10 import com.meterware.httpunit.WebResponse; 11 import com.meterware.httpunit.WebTable; 12 13 14 19 public class PartialListTest extends DisplaytagCase 20 { 21 22 25 public String getJspName() 26 { 27 return "partialList.jsp"; 28 } 29 30 36 public void doTest(String jspName) throws Exception 37 { 38 39 WebRequest request = new GetMethodWebRequest(jspName); 40 41 ParamEncoder p2 = new ParamEncoder("table2"); 42 ParamEncoder p3 = new ParamEncoder("table3"); 43 44 request.setParameter(p2.encodeParameterName(TableTagParameters.PARAMETER_PAGE), "2"); request.setParameter(p3.encodeParameterName(TableTagParameters.PARAMETER_SORT), "0"); request.setParameter(p3.encodeParameterName(TableTagParameters.PARAMETER_ORDER), "1"); 48 WebResponse response = runner.getResponse(request); 49 50 if (log.isDebugEnabled()) 51 { 52 log.debug("RESPONSE: " + response.getText()); 53 } 54 55 WebLink[] links = response.getLinks(); 56 WebTable[] tables = response.getTables(); 57 assertEquals("2", links[0].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_PAGE))[0]); 59 assertEquals("2", links[1].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_PAGE))[0]); 60 assertEquals("2", links[2].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_PAGE))[0]); 61 assertEquals(3, tables[0].getRowCount()); assertEquals("1", tables[0].getCellAsText(1, 0)); 63 assertEquals("4", tables[0].getCellAsText(2, 0)); 64 65 assertEquals("1", links[4].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_PAGE))[0]); 68 assertEquals("1", links[5].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_PAGE))[0]); 69 assertEquals("1", links[6].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_PAGE))[0]); 70 assertEquals(3, tables[1].getRowCount()); assertEquals("1", tables[1].getCellAsText(1, 0)); 72 assertEquals("4", tables[1].getCellAsText(2, 0)); 73 74 assertEquals(3, tables[2].getRowCount()); assertEquals("4", tables[2].getCellAsText(1, 0)); 77 assertEquals("1", tables[2].getCellAsText(2, 0)); 78 } 79 } | Popular Tags |