1 package org.displaytag.jsptests; 2 3 import org.displaytag.test.DisplaytagCase; 4 5 import com.meterware.httpunit.GetMethodWebRequest; 6 import com.meterware.httpunit.WebRequest; 7 import com.meterware.httpunit.WebResponse; 8 import com.meterware.httpunit.WebTable; 9 10 11 /** 12 * Tests for DISPL-2 - Ability to use java var in id attribute in tabletag. 13 * @author Fabrizio Giustina 14 * @version $Revision: 876 $ ($Author: fgiust $) 15 */ 16 public class Displ002Test extends DisplaytagCase 17 { 18 19 /** 20 * @see org.displaytag.test.DisplaytagCase#getJspName() 21 */ 22 public String getJspName() 23 { 24 return "DISPL-002.jsp"; 25 } 26 27 /** 28 * Check if tables are generated with variable id and content in column is filled appropriately. 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; 36 37 response = runner.getResponse(request); 38 39 if (log.isDebugEnabled()) 40 { 41 log.debug(response.getText()); 42 } 43 44 WebTable[] tables = response.getTables(); 45 assertEquals("Wrong number of tables in result.", 4, tables.length); 46 47 for (int j = 0; j < tables.length; j++) 48 { 49 WebTable table = tables[j]; 50 assertEquals("Wrong number of rows in table " + (j + 1), 2, table.getRowCount()); 51 assertEquals("Wrong content in cell for table " + (j + 1), "ant", table.getCellAsText(1, 0)); 52 assertEquals("Wrong content in cell for table " + (j + 1), "bee", table.getCellAsText(1, 1)); 53 } 54 } 55 }