3

Can the Jersey Test Framework be configured to output the raw HTTP responses when a test case fails? I'd like to be able to see the detailed error information returned by the server.

HolySamosa
  • 9,011
  • 14
  • 69
  • 102

2 Answers2

5

You can enable HTTP logging like so

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.

Einar Bjerve
  • 524
  • 2
  • 12
Paul D. Eden
  • 19,939
  • 18
  • 59
  • 63
1

You can always enable the normal Jersey logging for Request and Responses and see what is shows 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");
Giorgio
  • 13,129
  • 12
  • 48
  • 75