1 package org.displaytag.properties; 2 3 import org.displaytag.localization.I18nResourceProvider; 4 import org.displaytag.localization.LocaleResolver; 5 import org.displaytag.test.DisplaytagCase; 6 import org.displaytag.test.KnownValue; 7 8 import com.meterware.httpunit.GetMethodWebRequest; 9 import com.meterware.httpunit.WebRequest; 10 import com.meterware.httpunit.WebResponse; 11 import com.meterware.httpunit.WebTable; 12 13 14 19 public abstract class AbstractTitleKeyAutoColumnTest extends DisplaytagCase 20 { 21 22 25 public String getJspName() 26 { 27 return "titlekeyautocolumn.jsp"; 28 } 29 30 34 protected abstract String getExpectedSuffix(); 35 36 40 protected abstract LocaleResolver getResolver(); 41 42 46 protected abstract I18nResourceProvider getI18nResourceProvider(); 47 48 53 public void doTest(String jspName) throws Exception 54 { 55 WebRequest request = new GetMethodWebRequest(jspName); 57 58 TableProperties.setLocaleResolver(getResolver()); 59 TableProperties.setResourceProvider(getI18nResourceProvider()); 60 61 WebResponse response; 62 try 63 { 64 response = runner.getResponse(request); 65 } 66 finally 67 { 68 TableProperties.setLocaleResolver(null); 70 TableProperties.setResourceProvider(null); 71 } 72 73 if (log.isDebugEnabled()) 74 { 75 log.debug(response.getText()); 76 } 77 78 WebTable[] tables = response.getTables(); 79 assertEquals("Expected one table", 1, tables.length); 80 81 int j; 83 for (j = 0; j < tables[0].getColumnCount(); j++) 84 { 85 if (KnownValue.CAMEL.equals(tables[0].getCellAsText(1, j))) 86 { 87 break; 88 } 89 } 90 91 assertEquals("Header from resource is not valid.", "camel title" + getExpectedSuffix(), tables[0] 93 .getCellAsText(0, j)); 94 95 } 96 } | Popular Tags |