Class TestResource

java.lang.Object
com.reallifedeveloper.common.resource.BaseResource
com.reallifedeveloper.common.resource.TestResource

@Path("/{path:.*}") public class TestResource extends BaseResource
A JAX-RS resource that can be used for testing REST clients. This resource accepts all requests, and you can specify the responses given using the reset(Response...) method.

See TestResourceTest for an example of how to use this class.

Author:
RealLifeDeveloper
  • Constructor Details

    • TestResource

      public TestResource()
  • Method Details

    • get

      @GET public jakarta.ws.rs.core.Response get(@PathParam("path") String path)
    • post

      @POST public jakarta.ws.rs.core.Response post(@PathParam("path") String path, String postData)
    • put

      @PUT public jakarta.ws.rs.core.Response put(@PathParam("path") String path, String putData)
    • delete

      @DELETE public jakarta.ws.rs.core.Response delete(@PathParam("path") String path)
    • head

      @HEAD public jakarta.ws.rs.core.Response head(@PathParam("path") String path)
    • options

      @OPTIONS public jakarta.ws.rs.core.Response options(@PathParam("path") String path)
    • reset

      public void reset(jakarta.ws.rs.core.Response... newResponses)
      Resets the resource so that it starts to respond with the given responses.
      Parameters:
      newResponses - the responses to give
    • requests

      public List<TestResource.RequestInfo> requests()
      Gives a list of TestResource.RequestInfo objects representing the requests that have reached this resource.
      Returns:
      a list of RequestInfo objects