diff --git a/src/test/java/org/tynamo/resteasy/integration/ResteasyIntegrationTest.java b/src/test/java/org/tynamo/resteasy/integration/ResteasyIntegrationTest.java index 726a1a6..3c7c145 100644 --- a/src/test/java/org/tynamo/resteasy/integration/ResteasyIntegrationTest.java +++ b/src/test/java/org/tynamo/resteasy/integration/ResteasyIntegrationTest.java @@ -1,14 +1,16 @@ package org.tynamo.resteasy.integration; import com.gargoylesoftware.htmlunit.html.HtmlPage; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.ClientBuilder; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.tynamo.test.AbstractContainerTest; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; + public class ResteasyIntegrationTest extends AbstractContainerTest { @@ -41,7 +43,15 @@ public void testEchoResource() throws Exception String response = builder.get(String.class); Assert.assertEquals(response, "{\"message\":\"Hellow World!\"}"); client.close(); - } + @Test + public void testEchoGenericListOfLongs() throws Exception + { + Client client = ClientBuilder.newClient(); + Invocation.Builder builder = client.target(BASEURI + "mycustomresteasyprefix/echo/generic_longs").request(); + String response = builder.post(Entity.json("[1, 2, 3]"), String.class); + Assert.assertEquals(response, "1"); + client.close(); + } } diff --git a/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResource.java b/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResource.java index e447533..6828eba 100644 --- a/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResource.java +++ b/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResource.java @@ -3,11 +3,14 @@ import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiOperation; +import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; +import java.util.List; @Api(value = "/echo", description = "the ECHO api") @Path("/echo") @@ -18,4 +21,10 @@ public interface ReloadableEchoResource @Produces("application/json") @ApiOperation("echoes a message") Response echo(@PathParam("message") String message); + + @POST + @Path("/generic_longs") + @Consumes("application/json") + @Produces("application/json") + Response genericLongs(List params); } diff --git a/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResourceImpl.java b/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResourceImpl.java index 3848643..40d02fc 100644 --- a/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResourceImpl.java +++ b/src/test/java/org/tynamo/resteasy/ws/ReloadableEchoResourceImpl.java @@ -3,6 +3,7 @@ import org.apache.tapestry5.json.JSONObject; import javax.ws.rs.core.Response; +import java.util.List; public class ReloadableEchoResourceImpl implements ReloadableEchoResource { @@ -13,4 +14,11 @@ public Response echo(String message) return Response.status(200).entity(new JSONObject("message", message).toCompactString()).build(); } + @Override + public Response genericLongs(List params) + { + Long first = params.get(0); // java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long + return Response.ok(first).build(); + } + } \ No newline at end of file