1 package org.displaytag.jsptests; 2 3 import org.apache.commons.lang.StringUtils; 4 import org.displaytag.test.DisplaytagCase; 5 6 import com.meterware.httpunit.GetMethodWebRequest; 7 import com.meterware.httpunit.WebLink; 8 import com.meterware.httpunit.WebRequest; 9 import com.meterware.httpunit.WebResponse; 10 import com.meterware.httpunit.WebTable; 11 12 13 19 public class Displ056Test extends DisplaytagCase 20 { 21 22 25 public String getJspName() 26 { 27 return "DISPL-056.jsp"; 28 } 29 30 35 public void doTest(String jspName) throws Exception 36 { 37 WebRequest request = new GetMethodWebRequest(jspName); 38 WebResponse response; 39 40 response = runner.getResponse(request); 41 42 if (log.isDebugEnabled()) 43 { 44 log.debug(response.getText()); 45 } 46 47 WebTable[] tables = response.getTables(); 48 assertEquals("Wrong number of tables in result.", 3, tables.length); 49 50 for (int j = 0; j < tables.length; j++) 51 { 52 assertEquals("invalid id", "row" + j, tables[j].getID()); 53 } 54 55 WebLink[] links = response.getLinks(); 56 assertEquals("Wrong number of links in result.", 3, links.length); 57 58 response = links[0].click(); 60 61 links = response.getLinks(); 63 assertEquals("Wrong number of links in result.", 3, links.length); 64 65 response = links[0].click(); 67 68 if (log.isDebugEnabled()) 69 { 70 log.debug(response.getText()); 71 } 72 73 tables = response.getTables(); 74 assertEquals("Wrong number of tables in result.", 3, tables.length); 75 76 assertTrue("First table should be sorted. Wrong class attribute.", StringUtils.contains(tables[0].getTableCell(0, 0).getClassName(), "sorted")); 79 assertEquals("Second table should not be sorted. Wrong class attribute.", "sortable", 81 tables[1].getTableCell(0, 0).getClassName()); 82 assertEquals("Third table should not be sorted. Wrong class attribute.", "sortable", 84 tables[2].getTableCell(0, 0).getClassName()); 85 86 for (int j = 1; j < tables[0].getRowCount(); j++) 88 { 89 assertEquals("Unexpected value in table cell", Integer.toString(4 - j), tables[0].getCellAsText(j, 0)); 90 } 91 92 for (int j = 1; j < tables[1].getRowCount(); j++) 94 { 95 assertEquals("Unexpected value in table cell", Integer.toString(j), tables[1].getCellAsText(j, 0)); 96 assertEquals("Unexpected value in table cell", Integer.toString(j), tables[2].getCellAsText(j, 0)); 97 } 98 } 99 } | Popular Tags |