1 package org.displaytag.jsptests; 2 3 import com.meterware.httpunit.WebRequest; 4 import com.meterware.httpunit.GetMethodWebRequest; 5 import com.meterware.httpunit.WebResponse; 6 import com.meterware.httpunit.WebTable; 7 import org.displaytag.test.DisplaytagCase; 8 import org.displaytag.test.KnownTypes; 9 import org.apache.commons.lang.StringUtils; 10 11 12 /** 13 * @author rapruitt 14 * @version $Revision: 894 $ ($Author: fgiust $) 15 */ 16 public class TotalsTest extends DisplaytagCase 17 { 18 19 /** 20 * @see org.displaytag.test.DisplaytagCase#getJspName() 21 */ 22 public String getJspName() 23 { 24 return "totals.jsp"; 25 } 26 27 /** 28 * Check sorted columns. 29 * @param jspName jsp name, with full path 30 * @throws Exception any axception thrown during test. 31 */ 32 public void doTest(String jspName) throws Exception 33 { 34 WebRequest request = new GetMethodWebRequest(jspName); 35 WebResponse response = runner.getResponse(request); 36 37 if (log.isDebugEnabled()) 38 { 39 log.debug(response.getText()); 40 } 41 42 WebTable[] tables = response.getTables(); 43 44 assertEquals("Wrong number of tables.", 1, tables.length); 45 46 assertEquals("Bad number of generated columns.", 3, tables[0].getColumnCount()); 47 // The footer will PRECEDE the body. 48 assertTrue("Totals should not be calculated / present if the column is not so marked.", StringUtils 49 .isBlank(tables[0].getCellAsText(1, 0))); 50 assertEquals("Bad value in footer cell total.", "" + (KnownTypes.LONG_VALUE.doubleValue() * 2), tables[0] 51 .getCellAsText(1, 1)); 52 assertEquals("Bad value in footer cell total.", "" + (KnownTypes.LONG_VALUE.doubleValue() * 2), tables[0] 53 .getCellAsText(1, 2)); 54 } 55 }