com.jayway.restassured.filter.log
Class ErrorLoggingFilter

java.lang.Object
  extended by com.jayway.restassured.filter.log.ErrorLoggingFilter
All Implemented Interfaces:
Filter

public class ErrorLoggingFilter
extends Object

A filter that'll print the response body if an error occurred (status code is between 400 and 500).


Constructor Summary
ErrorLoggingFilter()
          Log to system out
ErrorLoggingFilter(PrintStream stream)
          Instantiate a error logger using a specific print stream
 
Method Summary
static Filter errorLogger()
          Create a new error logging filter without using the "new" operator.
 Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx)
          Filter the incoming request and response specifications and outgoing response.
static Filter logErrorsTo(PrintStream stream)
          Create a new error logging filter without using the "new" operator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorLoggingFilter

public ErrorLoggingFilter()
Log to system out


ErrorLoggingFilter

public ErrorLoggingFilter(PrintStream stream)
Instantiate a error logger using a specific print stream

Parameters:
stream - The stream to log errors to.
Method Detail

errorLogger

public static Filter errorLogger()
Create a new error logging filter without using the "new" operator. Will make the DSL look nicer.

Returns:
a new instance of the filter

logErrorsTo

public static Filter logErrorsTo(PrintStream stream)
Create a new error logging filter without using the "new" operator. Will make the DSL look nicer.

Parameters:
stream - The print stream to log to
Returns:
a new instance of the filter

filter

public Response filter(FilterableRequestSpecification requestSpec,
                       FilterableResponseSpecification responseSpec,
                       FilterContext ctx)
Description copied from interface: Filter
Filter the incoming request and response specifications and outgoing response. You need to call FilterContext.next(com.jayway.restassured.specification.FilterableRequestSpecification, com.jayway.restassured.specification.FilterableResponseSpecification) when you're done otherwise the request will not be delivered. It's of course possible to abort the filter chain execution by returning a Response directly.

Specified by:
filter in interface Filter
Parameters:
requestSpec - The incoming request spec
responseSpec - The incoming response spec
ctx - The filter context. You need to call FilterContext.next(com.jayway.restassured.specification.FilterableRequestSpecification, com.jayway.restassured.specification.FilterableResponseSpecification) when you're done otherwise the request will not be delivered.
Returns:
The response


Copyright © 2010-2011. All Rights Reserved.