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 7 import com.meterware.httpunit.GetMethodWebRequest; 8 import com.meterware.httpunit.WebRequest; 9 import com.meterware.httpunit.WebResponse; 10 import com.meterware.httpunit.WebTable; 11 12 13 18 public abstract class AbstractTitleKeyTest extends DisplaytagCase 19 { 20 21 24 public String getJspName() 25 { 26 return "titlekey.jsp"; 27 } 28 29 33 protected abstract LocaleResolver getResolver(); 34 35 39 protected abstract I18nResourceProvider getI18nResourceProvider(); 40 41 45 protected abstract String getExpectedSuffix(); 46 47 52 public void doTest(String jspName) throws Exception 53 { 54 WebRequest request = new GetMethodWebRequest(jspName); 56 57 TableProperties.setLocaleResolver(getResolver()); 58 TableProperties.setResourceProvider(getI18nResourceProvider()); 59 60 WebResponse response; 61 try 62 { 63 response = runner.getResponse(request); 64 } 65 finally 66 { 67 TableProperties.setLocaleResolver(null); 69 TableProperties.setResourceProvider(null); 70 } 71 72 if (log.isDebugEnabled()) 73 { 74 log.debug(response.getText()); 75 } 76 77 WebTable[] tables = response.getTables(); 78 assertEquals("Expected one table", 1, tables.length); 79 80 assertEquals("Header from resource is not valid.", "foo title" + getExpectedSuffix(), 82 tables[0].getCellAsText(0, 0)); 83 84 assertEquals("Header from resource is not valid.", "baz title" + getExpectedSuffix(), 86 tables[0].getCellAsText(0, 1)); 87 88 assertEquals("Header from resource is not valid.", "camel title" + getExpectedSuffix(), 90 tables[0].getCellAsText(0, 2)); 91 92 assertEquals("Missing resource should generate the ???missing??? header.", "???missing???", tables[0] 93 .getCellAsText(0, 3)); 94 95 } 96 } | Popular Tags |