diff options
Diffstat (limited to 'core/src/test/java/fi/iki/elonen/integration/GetAndPostIntegrationTest.java')
-rw-r--r-- | core/src/test/java/fi/iki/elonen/integration/GetAndPostIntegrationTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/src/test/java/fi/iki/elonen/integration/GetAndPostIntegrationTest.java b/core/src/test/java/fi/iki/elonen/integration/GetAndPostIntegrationTest.java index d4fc5cf..d2f5181 100644 --- a/core/src/test/java/fi/iki/elonen/integration/GetAndPostIntegrationTest.java +++ b/core/src/test/java/fi/iki/elonen/integration/GetAndPostIntegrationTest.java @@ -35,6 +35,7 @@ package fi.iki.elonen.integration; import static org.junit.Assert.assertEquals; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -154,4 +155,27 @@ public class GetAndPostIntegrationTest extends IntegrationTestBase<GetAndPostInt assertEquals("GET:testSimpleGetRequest", responseBody); } + + @Test + public void testPostRequestWithMultipartExtremEncodedParameters() throws Exception { + this.testServer.response = "testPostRequestWithMultipartEncodedParameters"; + + HttpPost httppost = new HttpPost("http://localhost:8192/"); + MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, "sfsadfasdf", Charset.forName("UTF-8")); + reqEntity.addPart("specialString", new StringBody("拖拉图片到浏览器,可以实现预览功能", "text/plain", Charset.forName("UTF-8"))); + reqEntity.addPart("gender", new StringBody("图片名称", Charset.forName("UTF-8")) { + + @Override + public String getFilename() { + return "图片名称"; + } + }); + httppost.setEntity(reqEntity); + + ResponseHandler<String> responseHandler = new BasicResponseHandler(); + String responseBody = this.httpclient.execute(httppost, responseHandler); + + // assertEquals("POST:testPostRequestWithMultipartEncodedParameters-params=2;age=120;gender=Male", + // responseBody); + } } |