Home » displaytag-1.1.1-src » org » displaytag » jsptests » [javadoc | source]

    1   package org.displaytag.jsptests;
    2   
    3   import org.displaytag.tags.TableTagParameters;
    4   import org.displaytag.test.DisplaytagCase;
    5   import org.displaytag.test.URLAssert;
    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   
   13   
   14   /**
   15    * Testcase for #944056.
   16    * @author Fabrizio Giustina
   17    * @version $Revision: 707 $ ($Author: fgiust $)
   18    */
   19   public class PaginationLinksTest extends DisplaytagCase
   20   {
   21   
   22       /**
   23        * @see org.displaytag.test.DisplaytagCase#getJspName()
   24        */
   25       public String getJspName()
   26       {
   27           return "pagination-links.jsp";
   28       }
   29   
   30       /**
   31        * Checks generated pagination links.
   32        * @param jspName jsp name, with full path
   33        * @throws Exception any axception thrown during test.
   34        */
   35       public void doTest(String jspName) throws Exception
   36       {
   37   
   38           WebRequest request = new GetMethodWebRequest(jspName
   39               + "?initiator=AVINASH&wfid=&approvedTDate=&initiatedFDate=&status=default"
   40               + "&initiatedTDate=04/28/2004&approvedFDate=&method=search&approver=");
   41   
   42           WebResponse response = runner.getResponse(request);
   43   
   44           if (log.isDebugEnabled())
   45           {
   46               log.debug("RESPONSE: " + response.getText());
   47           }
   48   
   49           WebLink[] links = response.getLinks();
   50   
   51           assertEquals("Wrong number of pagination links", 36, links.length);
   52   
   53           String lastLink = links[links.length - 1].getURLString();
   54   
   55           // remove prefix
   56           lastLink = lastLink.substring(lastLink.indexOf(getJspName()), lastLink.length());
   57   
   58           String encodedParam = new ParamEncoder("table2").encodeParameterName(TableTagParameters.PARAMETER_PAGE);
   59   
   60           String expected = "pagination-links.jsp?initiator=AVINASH&wfid=&approvedTDate=&initiatedFDate=&status=default"
   61               + "&initiatedTDate=04%2F28%2F2004&approvedFDate=&method=search&approver=&"
   62               + encodedParam
   63               + "=12";
   64   
   65           URLAssert.assertEquals(expected, lastLink);
   66   
   67       }
   68   }

Home » displaytag-1.1.1-src » org » displaytag » jsptests » [javadoc | source]