1 Reply Latest reply on Feb 15, 2016 11:38 AM by Matthieu Brouillard

    Testing REST interfaces

    Nicklas Karlsson Master

      So I have an Model-API jar that contain the core classes and interfaces of the applicaton like

       

      public interface LoginService 
      {
        public LoginResponse login(LoginRequest loginRequest);
        ...
      }
      

       

      and for the server end I have the implementation for it

       

      public class LoginServiceImpl implements LoginService 
      {
         ... does the actual stuff
      }
      

       

      and then a REST endpoint as a concrete class

       

      @Inject
      private LoginService loginService;
      
      @Path("login")
      public class RESTLoginService
      {
        @Path("login")
        @Post
        // login method that passes along parameters to the implementation
      }
      

       

      The problem is that apparently you can't use the concrete REST-class as a @ArquillianResteasyResource and you should use an interface. I don't want to annotate the LoginService with JAX-RS annotations (the Model-API jar is used on non-EE environments such as Android anyway). Is there any other option that sort of duplicate the LoginService to another, similar interface on the server side? I'd hate to change architecture just in order to do testing and it appears a bit loose-coupled just to sync the interfaces manually. Arguably, the REST endpoint methods are currently not coupled anyway since it's a concrete class, but... Any experiences on how to handle this? Is the "JAX-RS annotated interfaces" the recommended approach, even without the testing-perspective?

       

      Thanks in advance,

        Nik