Expose REST controller only during testing by using "test profile"

Viewed 314

For better testability of our application I'm adding a REST controller which allows setting certain states, e.g. http://localhost:8090/test-api/customer would allow creating a new customer in the application's database for further tests.

The class would basically look like this:

@RequestScoped
@Path("/test-api/customer")
public class TestController {

  @POST
  public void createCustomer() {}
}

Now I'd like this controller to be available only for testing, i.e. the production system should not expose this endpoint. Is there something like a "testing profile" or "testing annotation" like a Spring Boot profile I can add to this class to hide it from the production system?

0 Answers
Related