I get a null pointer exception
when trying to test a web service
My code:
@Path("/")
public class SubscriptionService {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/status/{subsId}")
public Response getSubscriptionStatus(@PathParam("subsId") int subsId) {
return Response.status(200).entity("subscription status for id: " + subsId).build();
}
}
Test class:
public class TestService {
private SubscriptionService service;
@Test
public void testGetSubscriptionStatus() {
final Response response = service.getSubscriptionStatus(5);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("subscription status for id: 5", response.getEntity());
}
}
The error appears here: final Response response = service.getSubscriptionStatus(5);
Does anyone have any idea why I get this error? Please help with a solution.
Aucun commentaire:
Enregistrer un commentaire