lundi 30 mai 2016

Testing the Response code of a WebService without a running server

I would like to test my WebService with JUnit (EasyMock and Hamcrest) without having to start my server (Wildfly)

private RegisterUserWebService testeee = new RegisterUserWebService();

@Test
  public void test() {


    Response response = testee.registerUser();
    verifyAll();
    assertThat(response.getStatusInfo().getStatusCode(), equalTo(Status.CONFLICT));

  }

I am getting a ClassNotFoundException:

java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl
            at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:152)
            at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
            at javax.ws.rs.core.Response$ResponseBuilder.newInstance(Response.java:848)
            at javax.ws.rs.core.Response.status(Response.java:590)
            at javax.ws.rs.core.Response.status(Response.java:601)
            at my.package.webservices.RegisterUserWebService.registerUser(RegisterUserWebService.java:50)

As I understand it, no implementation could be found for javax.ws.rs.core.Response, and the default one seems to be the glassfish one which I don't have, hence the ClassNotFoundException.

How could I tell my test to use the Response from Wildfly ? Or is there another way ?

Aucun commentaire:

Enregistrer un commentaire