This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 015f8c8  Tests.
015f8c8 is described below

commit 015f8c8f74829bd24fa45e26f61b0189f6360c65
Author: JamesBognar <[email protected]>
AuthorDate: Sat May 12 18:14:36 2018 -0400

    Tests.
---
 .../apache/juneau/rest/test/ParamsResource.java    | 233 -----------
 .../org/apache/juneau/rest/test/ParamsTest.java    | 430 ---------------------
 .../juneau/rest/mock/MockServletRequest.java       |  16 +-
 .../org/apache/juneau/rest/util/RestUtils.java     |   3 +-
 .../org/apache/juneau/rest/RestParamsTest.java     | 213 ++++++++++
 .../rest/annotation/FormDataAnnotationTest.java    |  55 +++
 .../rest/annotation/QueryAnnotationTest.java       | 157 ++++++++
 .../apache/juneau/rest/RestParamsTest.properties   |  15 +
 .../juneau/rest/RestParamsTest_ja_JP.properties    |  15 +
 9 files changed, 472 insertions(+), 665 deletions(-)

diff --git 
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ParamsResource.java
 
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ParamsResource.java
index d9d1270..d6097b5 100644
--- 
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ParamsResource.java
+++ 
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ParamsResource.java
@@ -13,27 +13,13 @@
 package org.apache.juneau.rest.test;
 
 import static org.apache.juneau.http.HttpMethodName.*;
-import static org.apache.juneau.internal.IOUtils.*;
 
-import java.io.*;
-import java.util.*;
-
-import javax.servlet.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.config.*;
-import org.apache.juneau.dto.swagger.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.parser.*;
 import org.apache.juneau.plaintext.*;
 import org.apache.juneau.rest.*;
 import org.apache.juneau.rest.annotation.*;
 import org.apache.juneau.rest.testutils.DTOs;
 import org.apache.juneau.transforms.*;
 import org.apache.juneau.urlencoding.*;
-import org.apache.juneau.utils.*;
 
 /**
  * JUnit automated testcase resource.
@@ -49,78 +35,6 @@ public class ParamsResource extends BasicRestServlet {
        private static final long serialVersionUID = 1L;
 
        
//====================================================================================================
-       // @FormData annotation - GET
-       
//====================================================================================================
-       @RestMethod(name=GET, path="/testParamGet/*")
-       public String testParamGet(RestRequest req, @Query("p1") String p1, 
@Query("p2") int p2) throws Exception {
-               RequestQuery q = req.getQuery();
-               return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", 
String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
-       }
-
-       
//====================================================================================================
-       // @FormData annotation - POST
-       
//====================================================================================================
-       @RestMethod(name=POST, path="/testParamPost/*")
-       public String testParamPost(RestRequest req, @FormData("p1") String p1, 
@FormData("p2") int p2) throws Exception {
-               RequestFormData f = req.getFormData();
-               return 
"p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", 
String.class)+"],p2=["+p2+","+req.getFormData().getString("p2")+","+f.get("p2", 
int.class)+"]";
-       }
-
-       
//====================================================================================================
-       // @Query annotation - GET
-       
//====================================================================================================
-       @RestMethod(name=GET, path="/testQParamGet/*")
-       public String testQParamGet(RestRequest req, @Query("p1") String p1, 
@Query("p2") int p2) throws Exception {
-               RequestQuery q = req.getQuery();
-               return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", 
String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
-       }
-
-       
//====================================================================================================
-       // @Query annotation - POST
-       
//====================================================================================================
-       @RestMethod(name=POST, path="/testQParamPost/*")
-       public String testQParamPost(RestRequest req, @Query("p1") String p1, 
@Query("p2") int p2) throws Exception {
-               RequestQuery q = req.getQuery();
-               return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", 
String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
-       }
-
-       
//====================================================================================================
-       // @FormData(format=PLAIN) annotation - GET
-       
//====================================================================================================
-       @RestMethod(name=GET, path="/testPlainParamGet/*")
-       public String testPlainParamGet(RestRequest req, 
@Query(value="p1",parser=SimplePartParser.class) String p1) throws Exception {
-               RequestQuery q = req.getQuery();
-               return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"]";
-       }
-
-       
//====================================================================================================
-       // @FormData(format=PLAIN) annotation - POST
-       
//====================================================================================================
-       @RestMethod(name=POST, path="/testPlainParamPost/*")
-       public String testPlainParamPost(RestRequest req, 
@FormData(value="p1",parser=SimplePartParser.class) String p1) throws Exception 
{
-               RequestFormData f = req.getFormData();
-               return 
"p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", 
String.class)+"]";
-       }
-
-       
//====================================================================================================
-       // @Query(format=PLAIN) annotation - GET
-       
//====================================================================================================
-       @RestMethod(name=GET, path="/testPlainQParamGet/*")
-       public String testPlainQParamGet(RestRequest req, 
@Query(value="p1",parser=SimplePartParser.class) String p1) throws Exception {
-               RequestQuery q = req.getQuery();
-               return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"]";
-       }
-
-       
//====================================================================================================
-       // @Query(format=PLAIN) annotation - POST
-       
//====================================================================================================
-       @RestMethod(name=POST, path="/testPlainQParamPost/*")
-       public String testPlainQParamPost(RestRequest req, 
@Query(value="p1",parser=SimplePartParser.class) String p1) throws Exception {
-               RequestQuery q = req.getQuery();
-               return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"]";
-       }
-
-       
//====================================================================================================
        // @HasQuery annotation - GET
        
//====================================================================================================
        @RestMethod(name=GET, path="/testHasParamGet/*")
@@ -157,45 +71,6 @@ public class ParamsResource extends BasicRestServlet {
        }
 
        
//====================================================================================================
-       // Test @FormData and @Query annotations when using multi-part 
parameters (e.g. &key=val1,&key=val2).
-       
//====================================================================================================
-       @RestMethod(name=GET, path="/testMultiPartParams")
-       public String testMultiPartParams(
-                       @Query(value="p1",multipart=true) String[] p1,
-                       @Query(value="p2",multipart=true) int[] p2,
-                       @Query(value="p3",multipart=true) List<String> p3,
-                       @Query(value="p4",multipart=true) List<Integer> p4,
-                       @Query(value="p5",multipart=true) String[] p5,
-                       @Query(value="p6",multipart=true) int[] p6,
-                       @Query(value="p7",multipart=true) List<String> p7,
-                       @Query(value="p8",multipart=true) List<Integer> p8,
-                       @Query(value="p9",multipart=true) A[] p9,
-                       @Query(value="p10",multipart=true) List<A> p10,
-                       @Query(value="p11",multipart=true) A[] p11,
-                       @Query(value="p12",multipart=true) List<A> p12) throws 
Exception {
-               ObjectMap m = new ObjectMap()
-                       .append("p1", p1)
-                       .append("p2", p2)
-                       .append("p3", p3)
-                       .append("p4", p4)
-                       .append("p5", p5)
-                       .append("p6", p6)
-                       .append("p7", p7)
-                       .append("p8", p8)
-                       .append("p9", p9)
-                       .append("p10", p10)
-                       .append("p11", p11)
-                       .append("p12", p12);
-               return JsonSerializer.DEFAULT_LAX.toString(m);
-       }
-
-       public static class A {
-               public String a;
-               public int b;
-               public boolean c;
-       }
-
-       
//====================================================================================================
        // Test multi-part parameter keys on bean properties of type 
array/Collection (i.e. &key=val1,&key=val2)
        // using URLENC_expandedParams property.
        // A simple round-trip test to verify that both serializing and parsing 
works.
@@ -219,112 +94,4 @@ public class ParamsResource extends BasicRestServlet {
        public DTOs.C testFormPostsWithMultiParamsUsingAnnotation(@Body DTOs.C 
content) throws Exception {
                return content;
        }
-
-       
//====================================================================================================
-       // Test other available object types as parameters.
-       
//====================================================================================================
-
-       @RestMethod(name=GET, path="/otherObjects/ResourceBundle")
-       public String testOtherResourceBundle(ResourceBundle t) {
-               if (t != null)
-                       return t.getString("foo");
-               return null;
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/MessageBundle")
-       public String testOtherMessages(MessageBundle t) {
-               if (t != null)
-                       return t.getString("foo");
-               return null;
-       }
-
-       @RestMethod(name=POST, path="/otherObjects/InputStream")
-       public String testOtherInputStream(InputStream t) throws IOException {
-               return read(t);
-       }
-
-       @RestMethod(name=POST, path="/otherObjects/ServletInputStream")
-       public String testOtherServletInputStream(ServletInputStream t) throws 
IOException {
-               return read(t);
-       }
-
-       @RestMethod(name=POST, path="/otherObjects/Reader")
-       public String testOtherReader(Reader t) throws IOException {
-               return read(t);
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/OutputStream")
-       public void testOtherOutputStream(OutputStream t) throws IOException {
-               t.write("OK".getBytes());
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/ServletOutputStream")
-       public void testOtherServletOutputStream(ServletOutputStream t) throws 
IOException {
-               t.write("OK".getBytes());
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/Writer")
-       public void testOtherWriter(Writer t) throws IOException {
-               t.write("OK");
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/RequestHeaders")
-       public boolean testOtherRequestHeaders(RequestHeaders t) {
-               return t != null;
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/RequestQuery")
-       public boolean testOtherRequestQueryParams(RequestQuery t) {
-               return t != null;
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/RequestFormData")
-       public boolean testOtherRequestFormData(RequestFormData t) {
-               return t != null;
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/HttpMethod")
-       public String testOtherHttpMethod(HttpMethod t) {
-               return t.toString();
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/RestLogger")
-       public boolean testOtherLogger(RestLogger t) {
-               return t != null;
-       }
-       
-       @RestMethod(name=GET, path="/otherObjects/RestContext")
-       public boolean testOtherRestContext(RestContext t) {
-               return t != null;
-       }
-
-       @RestMethod(name=GET, 
path="/otherObjects/Parser",parsers={JsonParser.class})
-       public String testOtherParser(Parser t) {
-               return t.getClass().getName();
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/Locale")
-       public String testOtherLocale(Locale t) {
-               return t.toString();
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/Swagger")
-       public boolean testOtherSwagger(Swagger t) {
-               return t != null;
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/RequestPathMatch")
-       public boolean testOtherRequestPathMatch(RequestPathMatch t) {
-               return t != null;
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/RequestBody")
-       public boolean testOtherRequestBody(RequestBody t) {
-               return t != null;
-       }
-
-       @RestMethod(name=GET, path="/otherObjects/Config")
-       public boolean testOtherConfig(Config t) {
-               return t != null;
-       }
 }
diff --git 
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/ParamsTest.java
 
b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/ParamsTest.java
index 723a5fd..aad3185 100644
--- 
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/ParamsTest.java
+++ 
b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/ParamsTest.java
@@ -14,13 +14,8 @@ package org.apache.juneau.rest.test;
 
 import static org.junit.Assert.*;
 
-import java.io.*;
-import java.util.*;
 
-import org.apache.http.*;
-import org.apache.http.client.entity.*;
 import org.apache.http.entity.*;
-import org.apache.http.message.*;
 import org.apache.juneau.*;
 import org.apache.juneau.rest.client.*;
 import org.junit.*;
@@ -29,215 +24,6 @@ public class ParamsTest extends RestTestcase {
 
        private static String URL = "/testParams";
 
-       private static RestClient CLIENT = TestMicroservice.DEFAULT_CLIENT;
-
-       
//====================================================================================================
-       // @FormData annotation - GET
-       
//====================================================================================================
-       @Test
-       public void testParamGet() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testParamGet";
-
-               r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
-               assertEquals("p1=[p1,p1,p1],p2=[2,2,2]", r);
-
-               r = client.doGet(url + "?p1&p2").getResponseAsString();
-               assertEquals("p1=[,,],p2=[0,,0]", r);
-
-               r = client.doGet(url).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doGet(url + "?p1").getResponseAsString();
-               assertEquals("p1=[,,],p2=[0,null,0]", r);
-
-               r = client.doGet(url + "?p2").getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,,0]", r);
-
-               r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
-               assertEquals("p1=[foo,foo,foo],p2=[0,,0]", r);
-
-               r = client.doGet(url + "?p1&p2=1").getResponseAsString();
-               assertEquals("p1=[,,],p2=[1,1,1]", r);
-
-               String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
-               r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
-               assertEquals("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]", 
r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // @FormData(format=PLAIN) annotation - GET
-       
//====================================================================================================
-       @Test
-       public void testPlainParamGet() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testPlainParamGet";
-
-               r = client.doGet(url + "?p1=p1").getResponseAsString();
-               assertEquals("p1=[p1,p1,p1]", r);
-
-               r = client.doGet(url + "?p1='p1'").getResponseAsString();
-               assertEquals("p1=['p1','p1',p1]", r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // @FormData annotation - POST
-       
//====================================================================================================
-       @Test
-       public void testParamPost() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testParamPost";
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
-               assertEquals("p1=[p1,p1,p1],p2=[2,2,2]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:null,p2:0}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,0,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:null}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p2:0}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,0,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
-               assertEquals("p1=[foo,foo,foo],p2=[0,0,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:null,p2:1}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[1,1,1]", r);
-
-               r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d 
e,f/g%h=i j',p2:1}")).getResponseAsString();
-               assertEquals("p1=[a/b%c=d e,f/g%h=i j,'a/b%c=d e,f/g%h=i 
j',a/b%c=d e,f/g%h=i j],p2=[1,1,1]", r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // @FormData(format=PLAIN) annotation - POST
-       
//====================================================================================================
-       @Test
-       public void testPlainParamPost() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testPlainParamPost";
-
-               List<NameValuePair> nvps = new ArrayList<NameValuePair>();
-               nvps.add(new BasicNameValuePair("p1", "p1"));
-               HttpEntity he = new UrlEncodedFormEntity(nvps);
-
-               r = client.doPost(url, he).getResponseAsString();
-               assertEquals("p1=[p1,p1,p1]", r);
-
-               nvps = new ArrayList<NameValuePair>();
-               nvps.add(new BasicNameValuePair("p1", "'p1'"));
-               he = new UrlEncodedFormEntity(nvps);
-
-               r = client.doFormPost(url, he).getResponseAsString();
-               assertEquals("p1=['p1','p1',p1]", r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // @Query annotation - GET
-       
//====================================================================================================
-       @Test
-       public void testQParamGet() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testQParamGet";
-
-               r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
-               assertEquals("p1=[p1,p1,p1],p2=[2,2,2]", r);
-
-               r = client.doGet(url + "?p1&p2").getResponseAsString();
-               assertEquals("p1=[,,],p2=[0,,0]", r);
-
-               r = client.doGet(url).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doGet(url + "?p1").getResponseAsString();
-               assertEquals("p1=[,,],p2=[0,null,0]", r);
-
-               r = client.doGet(url + "?p2").getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,,0]", r);
-
-               r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
-               assertEquals("p1=[foo,foo,foo],p2=[0,,0]", r);
-
-               r = client.doGet(url + "?p1&p2=1").getResponseAsString();
-               assertEquals("p1=[,,],p2=[1,1,1]", r);
-
-               String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
-               r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
-               assertEquals("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]", 
r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // @Query(format=PLAIN) annotation - GET
-       
//====================================================================================================
-       @Test
-       public void testPlainQParamGet() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testPlainQParamGet";
-
-               r = client.doGet(url + "?p1=p1").getResponseAsString();
-               assertEquals("p1=[p1,p1,p1]", r);
-
-               r = client.doGet(url + "?p1='p1'").getResponseAsString();
-               assertEquals("p1=['p1','p1',p1]", r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // @Query annotation - POST
-       
//====================================================================================================
-       @Test
-       public void testQParamPost() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testQParamPost";
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:null,p2:0}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:null}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p2:0}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new 
ObjectMap("{p1:null,p2:1}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d 
e,f/g%h=i j',p2:1}")).getResponseAsString();
-               assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
-               client.closeQuietly();
-       }
 
        
//====================================================================================================
        // @HasQuery annotation - GET
@@ -385,91 +171,6 @@ public class ParamsTest extends RestTestcase {
                client.closeQuietly();
        }
 
-
-       
//====================================================================================================
-       // Test @FormData and @Query annotations when using multi-part 
parameters (e.g. &key=val1,&key=val2).
-       
//====================================================================================================
-       @Test
-       public void testMultiPartParams() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testMultiPartParams";
-
-               String in = ""
-                       + "?p1=a&p1=b"
-                       + "&p2=1&p2=2"
-                       + "&p3=a&p3=b"
-                       + "&p4=1&p4=2"
-                       + "&p5=a&p5=b"
-                       + "&p6=1&p6=2"
-                       + "&p7=a&p7=b"
-                       + "&p8=1&p8=2"
-                       + "&p9=(a=1,b=2,c=false)&p9=(a=3,b=4,c=true)"
-                       + "&p10=(a=1,b=2,c=false)&p10=(a=3,b=4,c=true)"
-                       + "&p11=(a=1,b=2,c=false)&p11=(a=3,b=4,c=true)"
-                       + "&p12=(a=1,b=2,c=false)&p12=(a=3,b=4,c=true)";
-               r = client.doGet(url + in).getResponseAsString();
-               String e = "{"
-                       + "p1:['a','b'],"
-                       + "p2:[1,2],"
-                       + "p3:['a','b'],"
-                       + "p4:[1,2],"
-                       + "p5:['a','b'],"
-                       + "p6:[1,2],"
-                       + "p7:['a','b'],"
-                       + "p8:[1,2],"
-                       + "p9:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
-                       + "p10:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
-                       + "p11:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
-                       + "p12:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}]"
-               +"}";
-               assertEquals(e, r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // Same as testMultiPartParams(), except make sure single values are 
still interpreted as collections.
-       
//====================================================================================================
-       @Test
-       public void testMultiPartParamsSingleValues() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/plain").build();
-               String r;
-               String url = URL + "/testMultiPartParams";
-
-               String in = ""
-                       + "?p1=a"
-                       + "&p2=1"
-                       + "&p3=a"
-                       + "&p4=1"
-                       + "&p5=a"
-                       + "&p6=1"
-                       + "&p7=a"
-                       + "&p8=1"
-                       + "&p9=(a=1,b=2,c=false)"
-                       + "&p10=(a=1,b=2,c=false)"
-                       + "&p11=(a=1,b=2,c=false)"
-                       + "&p12=(a=1,b=2,c=false)";
-               r = client.doGet(url + in).getResponseAsString();
-               String e = "{"
-                       + "p1:['a'],"
-                       + "p2:[1],"
-                       + "p3:['a'],"
-                       + "p4:[1],"
-                       + "p5:['a'],"
-                       + "p6:[1],"
-                       + "p7:['a'],"
-                       + "p8:[1],"
-                       + "p9:[{a:'1',b:2,c:false}],"
-                       + "p10:[{a:'1',b:2,c:false}],"
-                       + "p11:[{a:'1',b:2,c:false}],"
-                       + "p12:[{a:'1',b:2,c:false}]"
-               +"}";
-               assertEquals(e, r);
-
-               client.closeQuietly();
-       }
-
        
//====================================================================================================
        // Test multi-part parameter keys on bean properties of type 
array/Collection (i.e. &key=val1,&key=val2)
        // using URLENC_expandedParams property.
@@ -551,135 +252,4 @@ public class ParamsTest extends RestTestcase {
 
                client.closeQuietly();
        }
-
-
-       
//====================================================================================================
-       // Test other available object types as parameters.
-       
//====================================================================================================
-
-       @Test
-       public void testOtherResourceBundle() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/ResourceBundle").acceptLanguage("en-US").getResponseAsString();
-               assertEquals("\"bar\"", r);
-               r = CLIENT.doGet(URL + 
"/otherObjects/ResourceBundle").acceptLanguage("ja-JP").getResponseAsString();
-               assertEquals("\"baz\"", r);
-       }
-
-       @Test
-       public void testOtherMessages() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/MessageBundle").acceptLanguage("en-US").getResponseAsString();
-               assertEquals("\"bar\"", r);
-               r = CLIENT.doGet(URL + 
"/otherObjects/MessageBundle").acceptLanguage("ja-JP").getResponseAsString();
-               assertEquals("\"baz\"", r);
-       }
-
-       @Test
-       public void testOtherInputStream() throws IOException {
-               String r = CLIENT.doPost(URL + 
"/otherObjects/InputStream").input(new 
StringReader("foo")).getResponseAsString();
-               assertEquals("\"foo\"", r);
-       }
-
-       @Test
-       public void testOtherServletInputStream() throws Exception {
-               String r = CLIENT.doPost(URL + 
"/otherObjects/ServletInputStream").input(new 
StringReader("foo")).getResponseAsString();
-               assertEquals("\"foo\"", r);
-       }
-
-       @Test
-       public void testOtherReader() throws Exception {
-               String r = CLIENT.doPost(URL + 
"/otherObjects/Reader").input(new StringReader("foo")).getResponseAsString();
-               assertEquals("\"foo\"", r);
-       }
-
-       @Test
-       public void testOtherOutputStream() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/OutputStream").getResponseAsString();
-               assertEquals("OK", r);
-       }
-
-       @Test
-       public void testOtherServletOutputStream() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/ServletOutputStream").getResponseAsString();
-               assertEquals("OK", r);
-       }
-
-       @Test
-       public void testOtherWriter() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/Writer").getResponseAsString();
-               assertEquals("OK", r);
-       }
-
-       @Test
-       public void testOtherRequestHeaders() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/RequestHeaders").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherRequestQuery() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/RequestQuery").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherRequestFormData() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/RequestFormData").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherHttpMethod() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/HttpMethod").getResponseAsString();
-               assertEquals("\"GET\"", r);
-       }
-
-       @Test
-       public void testOtherRestLogger() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/RestLogger").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherRestContext() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/RestContext").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherParser() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/Parser").contentType("application/json").getResponseAsString();
-               assertEquals("\"org.apache.juneau.json.JsonParser\"", r);
-       }
-
-       @Test
-       public void testOtherLocale() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/Locale").acceptLanguage("en-US").getResponseAsString();
-               assertEquals("\"en_US\"", r);
-               r = CLIENT.doGet(URL + 
"/otherObjects/Locale").acceptLanguage("ja-JP").getResponseAsString();
-               assertEquals("\"ja_JP\"", r);
-       }
-
-       @Test
-       public void testOtherSwagger() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/Swagger").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherRequestPathMatch() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/RequestPathMatch").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherRequestBody() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/RequestBody").getResponseAsString();
-               assertEquals("true", r);
-       }
-
-       @Test
-       public void testOtherConfig() throws Exception {
-               String r = CLIENT.doGet(URL + 
"/otherObjects/Config").getResponseAsString();
-               assertEquals("true", r);
-       }
 }
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/mock/MockServletRequest.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/mock/MockServletRequest.java
index a615df7..5be2550 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/mock/MockServletRequest.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/mock/MockServletRequest.java
@@ -668,7 +668,11 @@ public class MockServletRequest implements 
HttpServletRequest {
        public Map<String,String[]> getParameterMap() {
                if (parameterMap == null) {
                        try {
-                               parameterMap = 
RestUtils.parseQuery(getQueryString());
+                               if ("POST".equalsIgnoreCase(method)) {
+                                       parameterMap = 
RestUtils.parseQuery(IOUtils.read(body));
+                               } else {
+                                       parameterMap = 
RestUtils.parseQuery(getQueryString());
+                               }
                        } catch (Exception e) {
                                throw new RuntimeException(e);
                        }
@@ -1003,4 +1007,14 @@ public class MockServletRequest implements 
HttpServletRequest {
        public MockServletRequest accept(String value) {
                return header("Accept", value);
        }
+
+       /**
+        * Specifies the <code>Accept-Language</code> header value on the 
request.
+        * 
+        * @param value The new value.
+        * @return This object (for method chaining).
+        */
+       public MockServletRequest acceptLanguage(String value) {
+               return header("Accept-Language", value);
+       }
 }
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
index 588ff7a..8c07ade 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
@@ -289,7 +289,7 @@ public final class RestUtils {
                        
                        final int S1=1; // Looking for attrName start.
                        final int S2=2; // Found attrName start, looking for = 
or & or end.
-                       final int S3=3; // Found =, looking for valStart.
+                       final int S3=3; // Found =, looking for valStart or &.
                        final int S4=4; // Found valStart, looking for & or end.
 
                        try (UonReader r = new UonReader(p, true)) {
@@ -320,6 +320,7 @@ public final class RestUtils {
                                        } else if (state == S3) {
                                                if (c == -1 || c == '\u0001') {
                                                        add(m, currAttr, "");
+                                                       state = S1;
                                                } else {
                                                        if (c == '\u0002')
                                                                r.replace('=');
diff --git 
a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/RestParamsTest.java
 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/RestParamsTest.java
new file mode 100644
index 0000000..50e6665
--- /dev/null
+++ 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/RestParamsTest.java
@@ -0,0 +1,213 @@
+// 
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                
                                              * 
+// *                                                                           
                                              *
+// *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
+// *                                                                           
                                              *
+// * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the 
License.                                              *
+// 
***************************************************************************************************************************
+package org.apache.juneau.rest;
+
+import static org.apache.juneau.http.HttpMethodName.*;
+import static org.apache.juneau.internal.IOUtils.*;
+
+import java.io.*;
+import java.util.*;
+
+import javax.servlet.*;
+
+import org.apache.juneau.config.*;
+import org.apache.juneau.dto.swagger.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.mock.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Tests various aspects of parameters passed to methods annotated with 
@RestMethod.
+ */
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class RestParamsTest {
+
+       
//=================================================================================================================
+       // Various parameters
+       
//=================================================================================================================
+       
+       @RestResource(messages="RestParamsTest") 
+       public static class A {
+               @RestMethod(name=GET, path="/ResourceBundle")
+               public String a01(ResourceBundle t) {
+                       return t == null ? null : t.getString("foo");
+               }
+               @RestMethod(name=GET, path="/MessageBundle")
+               public String a02(MessageBundle t) {
+                       return t == null ? null : t.getString("foo");
+               }
+               @RestMethod(name=POST, path="/InputStream")
+               public String a03(InputStream t) throws IOException {
+                       return read(t);
+               }
+               @RestMethod(name=POST, path="/ServletInputStream")
+               public String a04(ServletInputStream t) throws IOException {
+                       return read(t);
+               }
+               @RestMethod(name=POST, path="/Reader")
+               public String a05(Reader t) throws IOException {
+                       return read(t);
+               }
+               @RestMethod(name=GET, path="/OutputStream")
+               public void a06(OutputStream t) throws IOException {
+                       t.write("OK".getBytes());
+               }
+               @RestMethod(name=GET, path="/ServletOutputStream")
+               public void a07(ServletOutputStream t) throws IOException {
+                       t.write("OK".getBytes());
+               }
+               @RestMethod(name=GET, path="/Writer")
+               public void a08(Writer t) throws IOException {
+                       t.write("OK");
+               }
+               @RestMethod(name=GET, path="/RequestHeaders")
+               public boolean a09(RequestHeaders t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/RequestQuery")
+               public boolean a10(RequestQuery t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/RequestFormData")
+               public boolean a11(RequestFormData t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/HttpMethod")
+               public String a12(HttpMethod t) {
+                       return t.toString();
+               }
+               @RestMethod(name=GET, path="/RestLogger")
+               public boolean a13(RestLogger t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/RestContext")
+               public boolean a14(RestContext t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/Parser",parsers={JsonParser.class})
+               public String a15(Parser t) {
+                       return t.getClass().getName();
+               }
+               @RestMethod(name=GET, path="/Locale")
+               public String a16(Locale t) {
+                       return t.toString();
+               }
+               @RestMethod(name=GET, path="/Swagger")
+               public boolean a17(Swagger t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/RequestPathMatch")
+               public boolean a18(RequestPathMatch t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/RequestBody")
+               public boolean a19(RequestBody t) {
+                       return t != null;
+               }
+               @RestMethod(name=GET, path="/Config")
+               public boolean a20(Config t) {
+                       return t != null;
+               }
+       }
+       static MockRest a = MockRest.create(A.class);
+
+       @Test
+       public void a01_ResourceBundle() throws Exception {
+               a.request("GET", 
"/ResourceBundle").acceptLanguage("en-US").execute().assertBody("bar");
+               a.request("GET", 
"/ResourceBundle").acceptLanguage("ja-JP").execute().assertBody("baz");
+       }
+       @Test
+       public void a02_MessageBundle() throws Exception {
+               a.request("GET", 
"/MessageBundle").acceptLanguage("en-US").execute().assertBody("bar");
+               a.request("GET", 
"/MessageBundle").acceptLanguage("ja-JP").execute().assertBody("baz");
+       }
+       @Test
+       public void a03_InputStream() throws Exception {
+               a.request("POST", 
"/InputStream").body("foo").execute().assertBody("foo");
+       }
+       @Test
+       public void a04_ServletInputStream() throws Exception {
+               a.request("POST", 
"/ServletInputStream").body("foo").execute().assertBody("foo");
+       }
+       @Test
+       public void a05_Reader() throws Exception {
+               a.request("POST", 
"/Reader").body("foo").execute().assertBody("foo");
+       }
+       @Test
+       public void a06_OutputStream() throws Exception {
+               a.request("GET", "/OutputStream").execute().assertBody("OK");
+       }
+       @Test
+       public void a07_ServletOutputStream() throws Exception {
+               a.request("GET", 
"/ServletOutputStream").execute().assertBody("OK");
+       }
+       @Test
+       public void a08_Writer() throws Exception {
+               a.request("GET", "/Writer").execute().assertBody("OK");
+       }
+       @Test
+       public void a09_RequestHeaders() throws Exception {
+               a.request("GET", 
"/RequestHeaders").execute().assertBody("true");
+       }
+       @Test
+       public void a10_RequestQuery() throws Exception {
+               a.request("GET", "/RequestQuery").execute().assertBody("true");
+       }
+       @Test
+       public void a11_RequestFormData() throws Exception {
+               a.request("GET", 
"/RequestFormData").execute().assertBody("true");
+       }
+       @Test
+       public void a12_HttpMethod() throws Exception {
+               a.request("GET", "/HttpMethod").execute().assertBody("GET");
+       }
+       @Test
+       public void a13_RestLogger() throws Exception {
+               a.request("GET", "/RestLogger").execute().assertBody("true");
+       }
+       @Test
+       public void a14_RestContext() throws Exception {
+               a.request("GET", "/RestContext").execute().assertBody("true");
+       }
+       @Test
+       public void a15_Parser() throws Exception {
+               a.request("GET", 
"/Parser").contentType("application/json").execute().assertBody("org.apache.juneau.json.JsonParser");
+       }
+       @Test
+       public void a16_Locale() throws Exception {
+               a.request("GET", 
"/Locale").acceptLanguage("en-US").execute().assertBody("en_US");
+               a.request("GET", 
"/Locale").acceptLanguage("ja-JP").execute().assertBody("ja_JP");
+       }
+       @Test
+       public void a17_Swagger() throws Exception {
+               a.request("GET", "/Swagger").execute().assertBody("true");
+       }
+       @Test
+       public void a18_RequestPathMatch() throws Exception {
+               a.request("GET", 
"/RequestPathMatch").execute().assertBody("true");
+       }
+       @Test
+       public void a19_RequestBody() throws Exception {
+               a.request("GET", "/RequestBody").execute().assertBody("true");
+       }
+       @Test
+       public void a20_Config() throws Exception {
+               a.request("GET", "/Config").execute().assertBody("true");
+       }
+}
diff --git 
a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java
 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java
index 5eda750..270108a 100644
--- 
a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java
+++ 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java
@@ -12,12 +12,67 @@
 // 
***************************************************************************************************************************
 package org.apache.juneau.rest.annotation;
 
+import static org.apache.juneau.http.HttpMethodName.*;
+
+import org.apache.juneau.httppart.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.mock.*;
+import org.apache.juneau.urlencoding.*;
 import org.junit.*;
 import org.junit.runners.*;
 
 /**
  * Tests related to @FormData annotation.
  */
+@SuppressWarnings("javadoc")
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class FormDataAnnotationTest {
+       
+       
//====================================================================================================
+       // Simple tests
+       
//====================================================================================================
+       @RestResource(parsers=UrlEncodingParser.class)
+       public static class A {
+               @RestMethod(name=POST)
+               public String post(RestRequest req, @FormData("p1") String p1, 
@FormData("p2") int p2) throws Exception {
+                       RequestFormData f = req.getFormData();
+                       return 
"p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", 
String.class)+"],p2=["+p2+","+req.getFormData().getString("p2")+","+f.get("p2", 
int.class)+"]";
+               }
+       }
+       static MockRest a = MockRest.create(A.class);
+       
+       @Test
+       public void a01() throws Exception {
+               a.request("POST", 
"").body("p1=p1&p2=2").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[p1,p1,p1],p2=[2,2,2]");
+               a.request("POST", 
"").body("p1&p2").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"").body("p1=&p2=").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[,,],p2=[0,,0]");
+               a.request("POST", 
"").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"").body("p1").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"").body("p1=").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[,,],p2=[0,null,0]");
+               a.request("POST", 
"").body("p2").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"").body("p2=").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[null,null,null],p2=[0,,0]");
+               a.request("POST", 
"").body("p1=foo&p2").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[foo,foo,foo],p2=[0,null,0]");
+               a.request("POST", 
"").body("p1&p2=1").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[null,null,null],p2=[1,1,1]");
+               String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
+               a.request("POST", 
"").body("p1="+x+"&p2=1").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[a/b%c=d
 e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]");
+       }
+       
+       
//====================================================================================================
+       // Plain parameters
+       
//====================================================================================================
+       @RestResource
+       public static class B {
+               @RestMethod(name=POST)
+               public String post(RestRequest req, 
@FormData(value="p1",parser=SimplePartParser.class) String p1) throws Exception 
{
+                       RequestFormData f = req.getFormData();
+                       return 
"p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", 
String.class)+"]";
+               }
+       }
+       static MockRest b = MockRest.create(B.class);
+       
+       @Test
+       public void b01() throws Exception {
+               b.request("POST", 
"").body("p1=p1").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=[p1,p1,p1]");
+               b.request("POST", 
"").body("p1='p1'").contentType("application/x-www-form-urlencoded").execute().assertBody("p1=['p1','p1',p1]");
+       }
 }
diff --git 
a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java
 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java
index 41bcbd8..260a021 100644
--- 
a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java
+++ 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java
@@ -12,6 +12,14 @@
 // 
***************************************************************************************************************************
 package org.apache.juneau.rest.annotation;
 
+import static org.apache.juneau.http.HttpMethodName.*;
+
+import java.util.*;
+
+import org.apache.juneau.httppart.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.mock.*;
 import org.junit.*;
 import org.junit.runners.*;
 
@@ -19,5 +27,154 @@ import org.junit.runners.*;
  * Tests related to @Query annotation.
  */
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@SuppressWarnings("javadoc")
 public class QueryAnnotationTest {
+       
+       
//====================================================================================================
+       // Simple tests
+       
//====================================================================================================
+       @RestResource
+       public static class A {
+               @RestMethod(name=GET)
+               public String get(RestRequest req, @Query("p1") String p1, 
@Query("p2") int p2) throws Exception {
+                       RequestQuery q = req.getQuery();
+                       return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", 
String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
+               }
+               @RestMethod(name=POST)
+               public String post(RestRequest req, @Query("p1") String p1, 
@Query("p2") int p2) throws Exception {
+                       RequestQuery q = req.getQuery();
+                       return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", 
String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
+               }
+       }
+       static MockRest a = MockRest.create(A.class);
+       
+       @Test
+       public void a01_get() throws Exception {
+               a.request("GET", 
"?p1=p1&p2=2").execute().assertBody("p1=[p1,p1,p1],p2=[2,2,2]");
+               a.request("GET", 
"?p1&p2").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("GET", 
"?p1=&p2=").execute().assertBody("p1=[,,],p2=[0,,0]");
+               a.request("GET", 
"/").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("GET", 
"?p1").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("GET", 
"?p1=").execute().assertBody("p1=[,,],p2=[0,null,0]");
+               a.request("GET", 
"?p2").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("GET", 
"?p2=").execute().assertBody("p1=[null,null,null],p2=[0,,0]");
+               a.request("GET", 
"?p1=foo&p2").execute().assertBody("p1=[foo,foo,foo],p2=[0,null,0]");
+               a.request("GET", 
"?p1&p2=1").execute().assertBody("p1=[null,null,null],p2=[1,1,1]");
+               String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
+               a.request("GET", 
"?p1="+x+"&p2=1").execute().assertBody("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d 
e],p2=[1,1,1]");
+       }
+       @Test
+       public void a02_post() throws Exception {
+               a.request("POST", 
"?p1=p1&p2=2").execute().assertBody("p1=[p1,p1,p1],p2=[2,2,2]");
+               a.request("POST", 
"?p1&p2").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"?p1=&p2=").execute().assertBody("p1=[,,],p2=[0,,0]");
+               a.request("POST", 
"/").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"?p1").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"?p1=").execute().assertBody("p1=[,,],p2=[0,null,0]");
+               a.request("POST", 
"?p2").execute().assertBody("p1=[null,null,null],p2=[0,null,0]");
+               a.request("POST", 
"?p2=").execute().assertBody("p1=[null,null,null],p2=[0,,0]");
+               a.request("POST", 
"?p1=foo&p2").execute().assertBody("p1=[foo,foo,foo],p2=[0,null,0]");
+               a.request("POST", 
"?p1&p2=1").execute().assertBody("p1=[null,null,null],p2=[1,1,1]");
+               String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
+               a.request("POST", 
"?p1="+x+"&p2=1").execute().assertBody("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d 
e],p2=[1,1,1]");
+       }
+       
+       
//====================================================================================================
+       // Plain parameters
+       
//====================================================================================================
+       @RestResource
+       public static class B {
+               @RestMethod(name=GET)
+               public String get(RestRequest req, 
@Query(value="p1",parser=SimplePartParser.class) String p1) throws Exception {
+                       RequestQuery q = req.getQuery();
+                       return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"]";
+               }
+               @RestMethod(name=POST)
+               public String post(RestRequest req, 
@Query(value="p1",parser=SimplePartParser.class) String p1) throws Exception {
+                       RequestQuery q = req.getQuery();
+                       return 
"p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"]";
+               }
+       }
+       static MockRest b = MockRest.create(B.class);
+       
+       @Test
+       public void b01_get() throws Exception {
+               b.request("GET", 
"?p1=p1").execute().assertBody("p1=[p1,p1,p1]");
+               b.request("GET", 
"?p1='p1'").execute().assertBody("p1=['p1','p1',p1]");
+       }
+       @Test
+       public void b02_post() throws Exception {
+               b.request("POST", 
"?p1=p1").execute().assertBody("p1=[p1,p1,p1]");
+               b.request("POST", 
"?p1='p1'").execute().assertBody("p1=['p1','p1',p1]");
+       }
+       
+       
+       
//====================================================================================================
+       // Multipart parameters (e.g. &key=val1,&key=val2).
+       
//====================================================================================================
+       @RestResource(serializers=JsonSerializer.Simple.class)
+       public static class C {
+               public static class C01 {
+                       public String a;
+                       public int b;
+                       public boolean c;
+               }
+               
+               @RestMethod(name=GET, path="/StringArray")
+               public Object c01(@Query(value="x",multipart=true) String[] x) {
+                       return x;
+               }
+               @RestMethod(name=GET, path="/intArray")
+               public Object c02(@Query(value="x",multipart=true) int[] x) {
+                       return x;
+               }
+               @RestMethod(name=GET, path="/ListOfStrings")
+               public Object c03(@Query(value="x",multipart=true) List<String> 
x) {
+                       return x;
+               }
+               @RestMethod(name=GET, path="/ListOfIntegers")
+               public Object c04(@Query(value="x",multipart=true) 
List<Integer> x) {
+                       return x;
+               }
+               @RestMethod(name=GET, path="/BeanArray")
+               public Object c05(@Query(value="x",multipart=true) C01[] x) {
+                       return x;
+               }
+               @RestMethod(name=GET, path="/ListOfBeans")
+               public Object c06(@Query(value="x",multipart=true) List<C01> x) 
{
+                       return x;
+               }
+       }
+       static MockRest c = MockRest.create(C.class);
+
+       @Test
+       public void c01_StringArray() throws Exception {
+               c.request("GET", 
"/StringArray?x=a").execute().assertBody("['a']");
+               c.request("GET", 
"/StringArray?x=a&x=b").execute().assertBody("['a','b']");
+       }
+       @Test
+       public void c02_intArray() throws Exception {
+               c.request("GET", "/intArray?x=1").execute().assertBody("[1]");
+               c.request("GET", 
"/intArray?x=1&x=2").execute().assertBody("[1,2]");
+       }
+       @Test
+       public void c03_ListOfStrings() throws Exception {
+               c.request("GET", 
"/ListOfStrings?x=a").execute().assertBody("['a']");
+               c.request("GET", 
"/ListOfStrings?x=a&x=b").execute().assertBody("['a','b']");
+       }
+       @Test
+       public void c04_ListOfIntegers() throws Exception {
+               c.request("GET", 
"/ListOfIntegers?x=1").execute().assertBody("[1]");
+               c.request("GET", 
"/ListOfIntegers?x=1&x=2").execute().assertBody("[1,2]");
+       }
+       @Test
+       public void c05_BeanArray() throws Exception {
+               c.request("GET", 
"/BeanArray?x=(a=1,b=2,c=false)").execute().assertBody("[{a:'1',b:2,c:false}]");
+               c.request("GET", 
"/BeanArray?x=(a=1,b=2,c=false)&x=(a=3,b=4,c=true)").execute().assertBody("[{a:'1',b:2,c:false},{a:'3',b:4,c:true}]");
+       }
+       @Test
+       public void c06_ListOfBeans() throws Exception {
+               c.request("GET", 
"/ListOfBeans?x=(a=1,b=2,c=false)").execute().assertBody("[{a:'1',b:2,c:false}]");
+               c.request("GET", 
"/ListOfBeans?x=(a=1,b=2,c=false)&x=(a=3,b=4,c=true)").execute().assertBody("[{a:'1',b:2,c:false},{a:'3',b:4,c:true}]");
+       }
 }
diff --git 
a/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/RestParamsTest.properties
 
b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/RestParamsTest.properties
new file mode 100644
index 0000000..a4405f4
--- /dev/null
+++ 
b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/RestParamsTest.properties
@@ -0,0 +1,15 @@
+# 
***************************************************************************************************************************
+# * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
+# * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
+# * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            * 
+# * with the License.  You may obtain a copy of the License at                 
                                             *
+# *                                                                            
                                             *
+# *  http://www.apache.org/licenses/LICENSE-2.0                                
                                             *
+# *                                                                            
                                             *
+# * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an  *
+# * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.  See the License for the        *
+# * specific language governing permissions and limitations under the License. 
                                             *
+# *                                                                            
                                             *
+# 
***************************************************************************************************************************
+
+foo = bar
\ No newline at end of file
diff --git 
a/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/RestParamsTest_ja_JP.properties
 
b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/RestParamsTest_ja_JP.properties
new file mode 100644
index 0000000..2fb5be2
--- /dev/null
+++ 
b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/RestParamsTest_ja_JP.properties
@@ -0,0 +1,15 @@
+# 
***************************************************************************************************************************
+# * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
+# * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
+# * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            * 
+# * with the License.  You may obtain a copy of the License at                 
                                             *
+# *                                                                            
                                             *
+# *  http://www.apache.org/licenses/LICENSE-2.0                                
                                             *
+# *                                                                            
                                             *
+# * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an  *
+# * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.  See the License for the        *
+# * specific language governing permissions and limitations under the License. 
                                             *
+# *                                                                            
                                             *
+# 
***************************************************************************************************************************
+
+foo = baz
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to