Hi,
I'm trying to unit test resources containing the following field:
@Context
private UriInfo uri;
The problem is that @Context is never injected under the unit test (because
there is no servlet layer) so uri ends up being null. All my tests end up
failing with NullPointerExceptions as a result.
I'm wondering what one is supposed to do in such a case. I read one could
mock-up such objects but I've never done this sort of thing before. I'm also
not sure when/how to inject the mocked-up UriInfo into the class. I don't
think I can add it to the constructor because I don't want to impact how
this class runs in production mode. I guess I could add setUriInfo() and
call it only from my unit tests but that seems a bit fragile.
Please advise.
Thanks,
Gili
--
View this message in context: http://n2.nabble.com/Unit-tests-and-UriInfo-tp1378335p1378335.html
Sent from the Jersey mailing list archive at Nabble.com.