Skip to content

Commit

Permalink
Test for tynamo#8
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrygusev committed Apr 1, 2017
1 parent 3fad978 commit c800336
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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
{

Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<Long> params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<Long> params)
{
Long first = params.get(0); // java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
return Response.ok(first).build();
}

}

0 comments on commit c800336

Please # to comment.