You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/09/14 21:11:03 UTC
incubator-juneau git commit: Fix warning message in tests about
RestClient not being closed.
Repository: incubator-juneau
Updated Branches:
refs/heads/master a1b71e1b9 -> 1ce1569be
Fix warning message in tests about RestClient not being closed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/1ce1569b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/1ce1569b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/1ce1569b
Branch: refs/heads/master
Commit: 1ce1569befed26984338ba49a424a659fd64a65f
Parents: a1b71e1
Author: JamesBognar <ja...@apache.org>
Authored: Thu Sep 14 17:11:00 2017 -0400
Committer: JamesBognar <ja...@apache.org>
Committed: Thu Sep 14 17:11:00 2017 -0400
----------------------------------------------------------------------
.../apache/juneau/rest/test/FormDataTest.java | 64 +++++++++++---------
1 file changed, 34 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1ce1569b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/FormDataTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/FormDataTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/FormDataTest.java
index d0f1874..95aabdf 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/FormDataTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/FormDataTest.java
@@ -69,36 +69,40 @@ public class FormDataTest extends RestTestcase {
@Test
public void testPlainTextParams() throws Exception {
RestClient c = TestMicroservice.client(UrlEncodingSerializer.class, UrlEncodingParser.class).plainTextParts().build();
- String r;
-
- Map<String,Object> m = new AMap<String,Object>()
- .append("foo", "foo")
- .append("'foo'", "'foo'")
- .append("(foo)", "(foo)")
- .append("@(foo)", "@(foo)");
-
- r = c.doPost(URL, m).getResponseAsString();
- assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[foo=foo&'foo'='foo'&(foo)=(foo)&@(foo)=@(foo)]", r);
-
- List<String> l = new AList<String>().appendAll("foo", "'foo'", "(foo)", "@(foo)");
- r = c.doPost(URL, l).getResponseAsString();
- assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[0=foo&1='foo'&2=(foo)&3=@(foo)]", r);
-
- NameValuePairs nvp = new NameValuePairs()
- .append("foo", "foo")
- .append("'foo'", "'foo'")
- .append("(foo)", "(foo)")
- .append("@(foo)", "@(foo)");
- r = c.doPost(URL, nvp).getResponseAsString();
- assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[foo=foo&%27foo%27=%27foo%27&%28foo%29=%28foo%29&%40%28foo%29=%40%28foo%29]", r);
-
- r = c.doPost(URL)
- .formData("foo", "foo")
- .formData("'foo'", "'foo'")
- .formData("(foo)", "(foo)")
- .formData("@(foo)", "@(foo)")
- .getResponseAsString();
- assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[foo=foo&%27foo%27=%27foo%27&%28foo%29=%28foo%29&%40%28foo%29=%40%28foo%29]", r);
+ try {
+ String r;
+
+ Map<String,Object> m = new AMap<String,Object>()
+ .append("foo", "foo")
+ .append("'foo'", "'foo'")
+ .append("(foo)", "(foo)")
+ .append("@(foo)", "@(foo)");
+
+ r = c.doPost(URL, m).getResponseAsString();
+ assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[foo=foo&'foo'='foo'&(foo)=(foo)&@(foo)=@(foo)]", r);
+
+ List<String> l = new AList<String>().appendAll("foo", "'foo'", "(foo)", "@(foo)");
+ r = c.doPost(URL, l).getResponseAsString();
+ assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[0=foo&1='foo'&2=(foo)&3=@(foo)]", r);
+
+ NameValuePairs nvp = new NameValuePairs()
+ .append("foo", "foo")
+ .append("'foo'", "'foo'")
+ .append("(foo)", "(foo)")
+ .append("@(foo)", "@(foo)");
+ r = c.doPost(URL, nvp).getResponseAsString();
+ assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[foo=foo&%27foo%27=%27foo%27&%28foo%29=%28foo%29&%40%28foo%29=%40%28foo%29]", r);
+
+ r = c.doPost(URL)
+ .formData("foo", "foo")
+ .formData("'foo'", "'foo'")
+ .formData("(foo)", "(foo)")
+ .formData("@(foo)", "@(foo)")
+ .getResponseAsString();
+ assertEquals("Content-Type=[application/x-www-form-urlencoded], contents=[foo=foo&%27foo%27=%27foo%27&%28foo%29=%28foo%29&%40%28foo%29=%40%28foo%29]", r);
+ } finally {
+ c.close();
+ }
}
//====================================================================================================