Reputation: 29806
I have written a Jersey service which I have deployed in Jetty server. Here is a sample:
@Path("/simple-on-off")
public class SimpleOnOffService {
@GET
@Path("/get-state")
@Produces(MediaType.TEXT_PLAIN)
public String getCurrentState(@Context HttpServletRequest request) {
return request.getRemoteAddr();
}
}
If this service is deployed in the Jetty server then I can see my IP address in the browser by following the URL: localhost:8080/rpi/service/simple-on-off/get-state
My question is how can I perform JUnit Test by accessing this service? Any pointer would be very helpful.
Upvotes: 0
Views: 828
Reputation: 3065
You can do that by using some testing frameworks such as: Jersey Test Framework or REST-Assured (https://code.google.com/p/rest-assured). I personally like a lot REST-Assured. See my answer in another question here: Unit testing jersey Restful Services
Upvotes: 1