@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
ParamEncoder p1 = new ParamEncoder("table");
ParamEncoder p2 = new ParamEncoder("table2");
request.setParameter(p2.encodeParameterName(TableTagParameters.PARAMETER_SORT), "number");
request.setParameter(p2.encodeParameterName(TableTagParameters.PARAMETER_SORTUSINGNAME), "1");
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug("RESPONSE: " + response.getText());
}
WebLink[] links = response.getLinks();
Assert.assertEquals(
"0",
links[0].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_SORT))[0]);
Assert.assertEquals(
"2",
links[0].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_ORDER))[0]);
Assert.assertEquals(
"buzz",
links[1].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_SORT))[0]);
Assert.assertEquals(
"2",
links[1].getParameterValues(p1.encodeParameterName(TableTagParameters.PARAMETER_ORDER))[0]);
// test that the column with sortName buzz was set as sorted and now has a link to sort desc
Assert.assertEquals(
"number",
links[2].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_SORT))[0]);
Assert.assertEquals(
"1",
links[2].getParameterValues(p2.encodeParameterName(TableTagParameters.PARAMETER_ORDER))[0]);
// now ensure that our data has not been sorted at all since we are doing it 'externally'
WebTable[] tables = response.getTables();
Assert.assertEquals("1", tables[1].getCellAsText(1, 0));
Assert.assertEquals("4", tables[1].getCellAsText(2, 0));