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 9 10 15 public class I18nPropertiesTest extends DisplaytagCase 16 { 17 18 21 private static final String MSG_DEFAULT = "There are no results."; 22 23 26 private static final String MSG_IT = "Non ci sono risultati."; 27 28 31 public String getJspName() 32 { 33 return "i18nProperties.jsp"; 34 } 35 36 41 public void doTest(String jspName) throws Exception 42 { 43 44 WebRequest request = new GetMethodWebRequest(jspName); 45 request.setHeaderField("Accept-Language", "en-us,en;q=0.5"); 46 47 WebResponse response = runner.getResponse(request); 48 49 if (log.isDebugEnabled()) 50 { 51 log.debug("RESPONSE: " + response.getText()); 52 } 53 54 assertTrue("Expected message\"" + MSG_DEFAULT + "\" has not been found in response with locale en", response 55 .getText() 56 .indexOf(MSG_DEFAULT) > -1); 57 assertTrue("Unexpected message\"" + MSG_IT + "\" has been found in response with locale en", response 58 .getText() 59 .indexOf(MSG_IT) == -1); 60 61 request = new GetMethodWebRequest(jspName); 63 request.setHeaderField("Accept-Language", "it-it,it;q=0.5"); 64 65 response = runner.getResponse(request); 66 67 if (log.isDebugEnabled()) 68 { 69 log.debug("RESPONSE: " + response.getText()); 70 } 71 72 assertTrue("Expected message\"" + MSG_IT + "\" has not been found in response with locale it", response 73 .getText() 74 .indexOf(MSG_IT) > -1); 75 assertTrue("Unexpected message\"" + MSG_DEFAULT + "\" has been found in response with locale it", response 76 .getText() 77 .indexOf(MSG_DEFAULT) == -1); 78 } 79 } 80 | Popular Tags |