- added more test case for Dispatcher



git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@429146 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Toby Jee
2006-08-06 16:06:08 +00:00
parent c75af104cc
commit 1aac25c1a2
@@ -19,8 +19,16 @@ package org.apache.struts2.dispatcher;
import java.util.Locale;
import org.apache.struts2.StrutsTestCase;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.StrutsTestCase;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.config.Settings;
import org.apache.struts2.dispatcher.Dispatcher;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
/**
@@ -44,4 +52,30 @@ public class DispatcherTest extends StrutsTestCase {
"Error uploading: some error messages");
}
public void testPrepareSetEncodingProperly() throws Exception {
HttpServletRequest req = new MockHttpServletRequest();
HttpServletResponse res = new MockHttpServletResponse();
Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
Dispatcher du = Dispatcher.getInstance();
du.prepare(req, res);
assertEquals(req.getCharacterEncoding(), "utf-8");
}
public void testPrepareSetEncodingPropertyWithMultipartRequest() throws Exception {
MockHttpServletRequest req = new MockHttpServletRequest();
MockHttpServletResponse res = new MockHttpServletResponse();
req.setContentType("multipart/form-data");
Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
Dispatcher du = Dispatcher.getInstance();
du.prepare(req, res);
assertEquals(req.getCharacterEncoding(), "utf-8");
}
}