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 28fff05 Tests.
28fff05 is described below
commit 28fff05e800b4190a2dd2b4c8838d198f07f2dc5
Author: JamesBognar <[email protected]>
AuthorDate: Tue Aug 28 17:55:29 2018 -0400
Tests.
---
.../org/apache/juneau/http/annotation/Request.java | 2 +-
juneau-doc/src/main/javadoc/overview.html | 2 -
.../01.RestProxies/08.Request.html | 2 -
.../org/apache/juneau/rest/client/RestClient.java | 39 +--
.../rest/client/remote/BodyAnnotationTest.java | 104 +++-----
.../rest/client/remote/RequestAnnotationTest.java | 282 +++++++++++++++++++++
.../rest/client/remote/ResponseAnnotationTest.java | 68 +++++
7 files changed, 413 insertions(+), 86 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
index 69c7ec2..ea1c3f8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
@@ -138,7 +138,7 @@ import org.apache.juneau.oapi.*;
* </ul>
*/
@Documented
-@Target(PARAMETER)
+@Target({PARAMETER,TYPE})
@Retention(RUNTIME)
@Inherited
public @interface Request {
diff --git a/juneau-doc/src/main/javadoc/overview.html
b/juneau-doc/src/main/javadoc/overview.html
index 7338bc5..b9a80aa 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -20941,8 +20941,6 @@ TODO(7.2.0)
<li class='ja'>{@link org.apache.juneau.http.annotation.FormData
FormData}
<li class='ja'>{@link org.apache.juneau.http.annotation.Query Query}
<li class='ja'>{@link org.apache.juneau.http.annotation.Path Path}
- <li class='ja'>{@link org.apache.juneau.http.annotation.HasFormData
HasFormData}
- <li class='ja'>{@link org.apache.juneau.http.annotation.HasQuery
HasQuery}
</ul>
<p>
The behavior and functionality of all of the annotations are the same
as if they were used on method arguments directly.
diff --git
a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
index 229a72a..76d6e9c 100644
---
a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
+++
b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
@@ -84,8 +84,6 @@
<li class='ja'>{@link oaj.http.annotation.FormData FormData}
<li class='ja'>{@link oaj.http.annotation.Query Query}
<li class='ja'>{@link oaj.http.annotation.Path Path}
- <li class='ja'>{@link oaj.http.annotation.HasFormData HasFormData}
- <li class='ja'>{@link oaj.http.annotation.HasQuery HasQuery}
</ul>
<p>
The behavior and functionality of all of the annotations are the same
as if they were used on method arguments directly.
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index cf85604..27fded5 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -1071,24 +1071,27 @@ public class RestClient extends BeanContext implements
Closeable {
if
(rmm.getRequestArgs().length > 0) {
for
(RemoteMethodBeanArg rmba : rmm.getRequestArgs()) {
RequestBeanMeta rbm = rmba.getMeta();
- for
(RequestBeanPropertyMeta p : rbm.getProperties()) {
-
Object val = p.getGetter().invoke(args[rmba.getIndex()]);
-
HttpPartType pt = p.getPartType();
-
HttpPartSerializer ps = p.getSerializer(s);
-
String pn = p.getPartName();
-
HttpPartSchema schema = p.getSchema();
-
boolean sie = schema.isSkipIfEmpty();
-
if (pt == PATH)
-
rc.path(pn, val, p.getSerializer(s), schema);
-
else if (val != null) {
-
if (pt == QUERY)
-
rc.query(pn, val, sie, ps, schema);
-
else if (pt == FORMDATA)
-
rc.formData(pn, val, sie, ps, schema);
-
else if (pt == HEADER)
-
rc.header(pn, val, sie, ps, schema);
-
else if (pt == HttpPartType.BODY)
-
rc.requestBodySchema(schema).body(val);
+ Object
bean = args[rmba.getIndex()];
+ if
(bean != null) {
+
for (RequestBeanPropertyMeta p : rbm.getProperties()) {
+
Object val = p.getGetter().invoke(bean);
+
HttpPartType pt = p.getPartType();
+
HttpPartSerializer ps = p.getSerializer(s);
+
String pn = p.getPartName();
+
HttpPartSchema schema = p.getSchema();
+
boolean sie = schema.isSkipIfEmpty();
+
if (pt == PATH)
+
rc.path(pn, val, p.getSerializer(s), schema);
+
else if (val != null) {
+
if (pt == QUERY)
+
rc.query(pn, val, sie, ps, schema);
+
else if (pt == FORMDATA)
+
rc.formData(pn, val, sie, ps, schema);
+
else if (pt == HEADER)
+
rc.header(pn, val, sie, ps, schema);
+
else if (pt == HttpPartType.BODY)
+
rc.requestBodySchema(schema).body(val);
+
}
}
}
}
diff --git
a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java
b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java
index 181c2aa..5c0eda5 100644
---
a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java
+++
b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java
@@ -12,7 +12,6 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest.client.remote;
-import static org.apache.juneau.testutils.TestUtils.*;
import static org.junit.Assert.*;
import java.io.*;
@@ -20,7 +19,6 @@ import java.util.*;
import org.apache.http.*;
import org.apache.http.entity.*;
-import org.apache.juneau.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.http.annotation.Header;
import org.apache.juneau.internal.*;
@@ -55,60 +53,60 @@ public class BodyAnnotationTest {
// Basic tests - JSON
//=================================================================================================================
- @RestResource(serializers=SimpleJsonSerializer.class,
parsers=JsonParser.class)
+ @RestResource(parsers=JsonParser.class)
public static class A {
@RestMethod
- public Object postA01(@Body int b, @Header("Content-Type")
String ct) {
+ public String postA01(@Body int b, @Header("Content-Type")
String ct) {
assertEquals("application/json", ct);
- return b;
+ return String.valueOf(b);
}
@RestMethod
- public Object postA02(@Body float b, @Header("Content-Type")
String ct) {
+ public String postA02(@Body float b, @Header("Content-Type")
String ct) {
assertEquals("application/json", ct);
- return b;
+ return String.valueOf(b);
}
@RestMethod
- public Object postA03(@Body Bean b, @Header("Content-Type")
String ct) {
+ public String postA03(@Body Bean b, @Header("Content-Type")
String ct) {
assertEquals("application/json", ct);
- return b;
+ return SimpleJsonSerializer.DEFAULT.toString(b);
}
@RestMethod
- public Object postA04(@Body Bean[] b, @Header("Content-Type")
String ct) {
+ public String postA04(@Body Bean[] b, @Header("Content-Type")
String ct) {
assertEquals("application/json", ct);
- return b;
+ return SimpleJsonSerializer.DEFAULT.toString(b);
}
@RestMethod
- public Object postA05(@Body List<Bean> b,
@Header("Content-Type") String ct) {
+ public String postA05(@Body List<Bean> b,
@Header("Content-Type") String ct) {
assertEquals("application/json", ct);
- return b;
+ return SimpleJsonSerializer.DEFAULT.toString(b);
}
@RestMethod
- public Object postA06(@Body Map<String,Bean> b,
@Header("Content-Type") String ct) {
+ public String postA06(@Body Map<String,Bean> b,
@Header("Content-Type") String ct) {
assertEquals("application/json", ct);
- return b;
+ return SimpleJsonSerializer.DEFAULT.toString(b);
}
@RestMethod
- public Object postA07(@Body Reader b, @Header("Content-Type")
String ct) {
+ public String postA07(@Body Reader b, @Header("Content-Type")
String ct) throws Exception {
assertEquals("text/plain", ct);
- return b;
+ return IOUtils.read(b);
}
@RestMethod
- public Object postA08(@Body InputStream b,
@Header("Content-Type") String ct) {
+ public String postA08(@Body InputStream b,
@Header("Content-Type") String ct) throws Exception {
assertEquals("application/octet-stream", ct);
- return b;
+ return IOUtils.read(b);
}
@RestMethod
- public Object postA09(@Body Reader b, @Header("Content-Type")
String ct) {
+ public String postA09(@Body Reader b, @Header("Content-Type")
String ct) throws Exception {
assertTrue(ct.startsWith("text/plain"));
- return b;
+ return IOUtils.read(b);
}
@RestMethod
@@ -121,80 +119,60 @@ public class BodyAnnotationTest {
@RemoteResource
public static interface A01 {
- Object postA01(@Body int b);
- Object postA02(@Body float b);
- Object postA03(@Body Bean b);
- Object postA04(@Body Bean[] b);
- Object postA05(@Body List<Bean> b);
- Object postA06(@Body Map<String,Bean> b);
- Object postA07(@Body Reader b);
- Object postA08(@Body InputStream b);
- Object postA09(@Body HttpEntity b);
- Object postA10(@Body NameValuePairs b);
+ String postA01(@Body int b);
+ String postA02(@Body float b);
+ String postA03(@Body Bean b);
+ String postA04(@Body Bean[] b);
+ String postA05(@Body List<Bean> b);
+ String postA06(@Body Map<String,Bean> b);
+ String postA07(@Body Reader b);
+ String postA08(@Body InputStream b);
+ String postA09(@Body HttpEntity b);
+ String postA10(@Body NameValuePairs b);
}
- private static A01 a01 =
RestClient.create().mockHttpConnection(a).json().build().getRemoteResource(A01.class);
+ private static A01 a01 =
RestClient.create().mockHttpConnection(a).serializer(JsonSerializer.class).build().getRemoteResource(A01.class);
@Test
public void a01_int() throws Exception {
- Object o = a01.postA01(1);
- assertObjectEquals("1", o);
- assertClass(Integer.class, o);
+ assertEquals("1", a01.postA01(1));
}
@Test
public void a02_float() throws Exception {
- Object o = a01.postA02(1f);
- assertObjectEquals("1.0", o);
- assertClass(Float.class, o);
+ assertEquals("1.0", a01.postA02(1f));
}
@Test
public void a03_Bean() throws Exception {
- Object o = a01.postA03(Bean.create());
- assertObjectEquals("{f:1}", o);
- assertClass(ObjectMap.class, o);
+ assertEquals("{f:1}", a01.postA03(Bean.create()));
}
@Test
public void a04_BeanArray() throws Exception {
- Object o = a01.postA04(new Bean[]{Bean.create()});
- assertObjectEquals("[{f:1}]", o);
- assertClass(ObjectList.class, o);
+ assertEquals("[{f:1}]", a01.postA04(new Bean[]{Bean.create()}));
}
@Test
public void a05_ListOfBeans() throws Exception {
- Object o = a01.postA05(AList.create(Bean.create()));
- assertObjectEquals("[{f:1}]", o);
- assertClass(ObjectList.class, o);
+ assertEquals("[{f:1}]",
a01.postA05(AList.create(Bean.create())));
}
@Test
public void a06_MapOfBeans() throws Exception {
- Object o = a01.postA06(AMap.create("k1",Bean.create()));
- assertObjectEquals("{k1:{f:1}}", o);
- assertClass(ObjectMap.class, o);
+ assertEquals("{k1:{f:1}}",
a01.postA06(AMap.create("k1",Bean.create())));
}
@Test
public void a07_Reader() throws Exception {
- Object o = a01.postA07(new StringReader("'xxx'"));
- assertObjectEquals("'xxx'", o);
- assertClass(String.class, o);
+ assertEquals("xxx", a01.postA07(new StringReader("xxx")));
}
+ @SuppressWarnings("resource")
@Test
public void a08_InputStream() throws Exception {
- @SuppressWarnings("resource")
- Object o = a01.postA08(new StringInputStream("'xxx'"));
- assertObjectEquals("'xxx'", o);
- assertClass(String.class, o);
+ assertEquals("xxx", a01.postA08(new StringInputStream("xxx")));
}
@Test
public void a09_HttpEntity() throws Exception {
- Object o = a01.postA09(new StringEntity("'xxx'"));
- assertObjectEquals("'xxx'", o);
- assertClass(String.class, o);
+ assertEquals("xxx", a01.postA09(new StringEntity("xxx")));
}
@Test
public void a10_NameValuePairs() throws Exception {
- Object o = a01.postA10(new NameValuePairs().append("foo",
"bar"));
- assertObjectEquals("'foo=bar'", o);
- assertClass(String.class, o);
+ assertEquals("foo=bar", a01.postA10(new
NameValuePairs().append("foo", "bar")));
}
//=================================================================================================================
diff --git
a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RequestAnnotationTest.java
b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RequestAnnotationTest.java
new file mode 100644
index 0000000..629322a
--- /dev/null
+++
b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RequestAnnotationTest.java
@@ -0,0 +1,282 @@
+//
***************************************************************************************************************************
+// * 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.client.remote;
+
+import static org.junit.Assert.*;
+
+import java.io.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.http.annotation.*;
+import org.apache.juneau.http.annotation.Header;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client.*;
+import org.apache.juneau.rest.mock.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Tests the @Request annotation.
+ */
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class RequestAnnotationTest {
+
+ public static class Bean {
+ public int f;
+
+ public static Bean create() {
+ Bean b = new Bean();
+ b.f = 1;
+ return b;
+ }
+ }
+
+
//=================================================================================================================
+ // Basic tests
+
//=================================================================================================================
+
+ @RestResource
+ public static class A {
+ @RestMethod(path="/{x}")
+ public String post(@Body Reader r, @Header("X") String h,
@Query("x") String q, @Path("x") String p) throws Exception {
+ ObjectMap m = new ObjectMap()
+ .append("body", IOUtils.read(r))
+ .append("header", h)
+ .append("query", q)
+ .append("path", p);
+ return m.toString();
+ }
+ }
+ private static MockRest a = MockRest.create(A.class);
+
+ @Request
+ public static class ARequest {
+ @Body
+ public String getBody() {
+ return "foo";
+ }
+ @Header("X")
+ public String getHeader() {
+ return "x";
+ }
+ @Query("x")
+ public String getQuery() {
+ return "x";
+ }
+ @Path("x")
+ public String getPath() {
+ return "x";
+ }
+ }
+
+ @RemoteResource
+ public static interface AR {
+ @RemoteMethod(path="/{x}") String post(ARequest req);
+ }
+
+ private static AR ar =
RestClient.create().mockHttpConnection(a).build().getRemoteResource(AR.class);
+
+ @Test
+ public void a01_basic() throws Exception {
+ assertEquals("{body:'foo',header:'x',query:'x',path:'x'}",
ar.post(new ARequest()));
+ }
+ @Test
+ public void a02_basic_nullValue() throws Exception {
+ assertEquals("{body:'',header:null,query:null,path:'{x}'}",
ar.post(null));
+ }
+
+
//=================================================================================================================
+ // Annotation on parent
+
//=================================================================================================================
+
+ @RestResource
+ public static class B {
+ @RestMethod(path="/{x}")
+ public String post(@Body Reader r, @Header("X") String h,
@Query("x") String q, @Path("x") String p) throws Exception {
+ ObjectMap m = new ObjectMap()
+ .append("body", IOUtils.read(r))
+ .append("header", h)
+ .append("query", q)
+ .append("path", p);
+ return m.toString();
+ }
+ }
+ private static MockRest b = MockRest.create(B.class);
+
+ @Request
+ public abstract static class BRequest {
+ @Body
+ public abstract String getBody();
+ @Header("X")
+ public abstract String getHeader();
+ @Query("x")
+ public abstract String getQuery();
+ @Path("x")
+ public abstract String getPath();
+ }
+
+ public static class BRequestImpl extends BRequest {
+ @Override
+ public String getBody() {
+ return "foo";
+ }
+ @Override
+ public String getHeader() {
+ return "x";
+ }
+ @Override
+ public String getQuery() {
+ return "x";
+ }
+ @Override
+ public String getPath() {
+ return "x";
+ }
+ }
+
+ @RemoteResource
+ public static interface BR {
+ @RemoteMethod(path="/{x}") String post(BRequest req);
+ }
+
+ private static BR br =
RestClient.create().mockHttpConnection(b).build().getRemoteResource(BR.class);
+
+ @Test
+ public void b01_annotationOnParent() throws Exception {
+ assertEquals("{body:'foo',header:'x',query:'x',path:'x'}",
br.post(new BRequestImpl()));
+ }
+ @Test
+ public void b02_annotationOnParent_nullValue() throws Exception {
+ assertEquals("{body:'',header:null,query:null,path:'{x}'}",
br.post(null));
+ }
+
+
//=================================================================================================================
+ // Annotation on interface
+
//=================================================================================================================
+
+ @RestResource
+ public static class C {
+ @RestMethod(path="/{x}")
+ public String post(@Body Reader r, @Header("X") String h,
@Query("x") String q, @Path("x") String p) throws Exception {
+ ObjectMap m = new ObjectMap()
+ .append("body", IOUtils.read(r))
+ .append("header", h)
+ .append("query", q)
+ .append("path", p);
+ return m.toString();
+ }
+ }
+ private static MockRest c = MockRest.create(C.class);
+
+ @Request
+ public interface CRequest {
+ @Body
+ String getBody();
+ @Header("X")
+ String getHeader();
+ @Query("x")
+ String getQuery();
+ @Path("x")
+ String getPath();
+ }
+
+ public static class CRequestImpl implements CRequest {
+ @Override
+ public String getBody() {
+ return "foo";
+ }
+ @Override
+ public String getHeader() {
+ return "x";
+ }
+ @Override
+ public String getQuery() {
+ return "x";
+ }
+ @Override
+ public String getPath() {
+ return "x";
+ }
+ }
+
+ @RemoteResource
+ public static interface CR {
+ @RemoteMethod(path="/{x}") String post(CRequest req);
+ }
+
+ private static CR cr =
RestClient.create().mockHttpConnection(c).build().getRemoteResource(CR.class);
+
+ @Test
+ public void c01_annotationOnInterface() throws Exception {
+ assertEquals("{body:'foo',header:'x',query:'x',path:'x'}",
cr.post(new CRequestImpl()));
+ }
+ @Test
+ public void c02_annotationOnInterface_nullValue() throws Exception {
+ assertEquals("{body:'',header:null,query:null,path:'{x}'}",
cr.post(null));
+ }
+
+
//=================================================================================================================
+ // Annotation on parameter
+
//=================================================================================================================
+
+ @RestResource
+ public static class D {
+ @RestMethod(path="/{x}")
+ public String post(@Body Reader r, @Header("X") String h,
@Query("x") String q, @Path("x") String p) throws Exception {
+ ObjectMap m = new ObjectMap()
+ .append("body", IOUtils.read(r))
+ .append("header", h)
+ .append("query", q)
+ .append("path", p);
+ return m.toString();
+ }
+ }
+ private static MockRest d = MockRest.create(D.class);
+
+ public static class DRequest {
+ @Body
+ public String getBody() {
+ return "foo";
+ }
+ @Header("X")
+ public String getHeader() {
+ return "x";
+ }
+ @Query("x")
+ public String getQuery() {
+ return "x";
+ }
+ @Path("x")
+ public String getPath() {
+ return "x";
+ }
+ }
+
+ @RemoteResource
+ public static interface DR {
+ @RemoteMethod(path="/{x}") String post(@Request DRequest req);
+ }
+
+ private static DR dr =
RestClient.create().mockHttpConnection(d).build().getRemoteResource(DR.class);
+
+ @Test
+ public void d01_annotationOnParameter() throws Exception {
+ assertEquals("{body:'foo',header:'x',query:'x',path:'x'}",
dr.post(new DRequest()));
+ }
+ @Test
+ public void d02_annotationOnParameter_nullValue() throws Exception {
+ assertEquals("{body:'',header:null,query:null,path:'{x}'}",
dr.post(null));
+ }
+}
diff --git
a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/ResponseAnnotationTest.java
b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/ResponseAnnotationTest.java
new file mode 100644
index 0000000..202e269
--- /dev/null
+++
b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/ResponseAnnotationTest.java
@@ -0,0 +1,68 @@
+//
***************************************************************************************************************************
+// * 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.client.remote;
+
+import static org.junit.Assert.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.http.annotation.*;
+import org.apache.juneau.http.annotation.Header;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client.*;
+import org.apache.juneau.rest.mock.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Tests the @Request annotation.
+ */
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ResponseAnnotationTest {
+
+ public static class Bean {
+ public int f;
+
+ public static Bean create() {
+ Bean b = new Bean();
+ b.f = 1;
+ return b;
+ }
+ }
+
+
//=================================================================================================================
+ // Basic tests
+
//=================================================================================================================
+
+ @RestResource
+ public static class A {
+ @RestMethod
+ public String postA(@FormData("*") ObjectMap m,
@Header("Content-Type") String ct) {
+ assertEquals(ct, "application/x-www-form-urlencoded");
+ return m.toString();
+ }
+ }
+ private static MockRest a = MockRest.create(A.class);
+
+ @RemoteResource
+ public static interface AR {
+ @RemoteMethod(path="a") String postA01(@FormData("x") int b);
+ }
+
+ private static AR ar =
RestClient.create().mockHttpConnection(a).build().getRemoteResource(AR.class);
+
+ @Test
+ public void a01_int() throws Exception {
+ assertEquals("{x:'1'}", ar.postA01(1));
+ }
+}