Skip to content

Commit

Permalink
WW-4862 Adds additional tests to cover new regex
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Oct 22, 2017
1 parent 10027da commit 7ad2a42
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.LocalizedTextProvider;
import org.apache.commons.io.Charsets;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
Expand All @@ -40,6 +41,7 @@

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -291,6 +293,36 @@ public void testMultipartSupportEnabledByDefault() throws Exception {
assertTrue(du.isMultipartSupportEnabled(req));
}

public void testIsMultipartRequest() throws Exception {
MockHttpServletRequest req = new MockHttpServletRequest();
HttpServletResponse res = new MockHttpServletResponse();

req.setMethod("POST");
Dispatcher du = initDispatcher(Collections.<String, String>emptyMap());
du.prepare(req, res);

req.setContentType("multipart/form-data");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=UTF-8");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=ISO-8859-1");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=Windows-1250");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=US-ASCII");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=UTF-16LE");
assertTrue(du.isMultipartRequest(req));
}

class InternalConfigurationManager extends ConfigurationManager {
public boolean destroyConfiguration = false;

Expand Down

0 comments on commit 7ad2a42

Please sign in to comment.