I want to test a REST Resource:
@GET
@Path("/{dbName}")
@Produces(MediaType.APPLICATION_JSON)
public String getRequest(@PathParam("dbName") String dbName)
throws JSONException {
}
I want to do this :
assert(someExpectedOutput,getRequest())
Now How the PAth will be set for @Path annotation ??
If you are going to call
getRequestdirectly for testing, as a Java method, go right ahead and pass it a single string:It is after all, just a Java method with one string parameter.
The JAX-RS annotations only kick in when you are running a server, in which case the framework will match the path parameter to your Java parameter
dbname. I assume for testing you are just going to use mock objects, so no worries. Pass whatever string you like.Now if you are going to test within a server (more like an integration test), consider something like Jetty for the webserver and HSQLDB or Derby for a database. That kind of testing is much more involved.