Display HTTP responses using Jersey Testing Framework?

Can the Jersey test framework be configured to output raw HTTP responses when the test case fails? I would like to see detailed error information returned by the server.

+3


source to share


2 answers


You can enable HTTP logging this way

public class SimpleTest extends JerseyTest {
    // ...

    @Override
    protected Application configure() {
        enable(TestProperties.LOG_TRAFFIC);
        enable(TestProperties.DUMP_ENTITY);
        // ...
    }
}

      



More details here .

This is for the latest version of the framework, currently 2.3.1.

+4


source


You can always turn on normal logging for requests and responses and see what is displayed in the console:

<init-param>
  <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
  <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
<init-param>
  <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
  <param-value>com.sun.jersey.api.container.filter.LoggingFilter<</param-value>
</init-param>
      



Enable logging programmatically:

servletHolder.setInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters"    , "com.sun.jersey.api.container.filter.LoggingFilter");
servletHolder.setInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters"  , "com.sun.jersey.api.container.filter.LoggingFilter");
      

+1


source







All Articles