2

I created an object of javax.ws.rs.core.Response.ResponseBuilder and pass to the method this is working fine in the project but when i created object in junit test cases then at run time after that creation of object next statement its not executing.

This is my test case code.

@Test
public void testGetCountryDetails() {
    ResponseBuilder builder = Response.ok();
    CountryDetails countryDetails=new CountryDetails();
    boolean status=countryDetails.getCountryDetails(builder);
    log.debug("the status is"+status);
    log.debug("the body is:"+builder.build().getEntity());
    assertTrue(status);
}
Narendra Pathai
  • 41,187
  • 18
  • 82
  • 120
user2549122
  • 203
  • 1
  • 5
  • 18
  • How are you running the junit test case? Using IDE or ant? – Narendra Pathai Oct 16 '13 at 07:39
  • place your code in a try catch block and in the catch block print the exception trace. And share that exception trace, for us to reach at the RCA for this. – Narendra Pathai Oct 16 '13 at 08:27
  • this is link:http://www.docdroid.net/58dj/error.txt.html – user2549122 Oct 16 '13 at 08:40
  • if i run from maven then i getting testGetCountryDetails(com.test.CountryDetailsTest): Absent Code attr ibute in method that is not native or abstract in class file javax/ws/rs/core/Re sponse error – user2549122 Oct 16 '13 at 08:50
  • Seems like you need the container initialized before being able to unit test what ever you are trying to test. See this link about unit testing JAX-RS webservice http://stackoverflow.com/questions/121266/unit-testing-a-jax-rs-web-service – Narendra Pathai Oct 16 '13 at 09:31
  • so how can i initialize jax-rs?. – user2549122 Oct 16 '13 at 09:45
  • see the link i have provided in my comment. – Narendra Pathai Oct 16 '13 at 09:50
  • i checked but for that i need to used jersey library? – user2549122 Oct 16 '13 at 09:55
  • i change org.apache.cxf.jaxrs.impl.ResponseBuilderImpl then its woking fine. do u tell me why? – user2549122 Oct 16 '13 at 09:55
  • I am not that aware with Jersey but I can tell you the reason that probably the Impl class might not be using the container specific settings but ResponseBuilder.getInstance() method might be using. So due to that it might be working. Again I am not sure, this is just a speculation. – Narendra Pathai Oct 16 '13 at 12:04

0 Answers0