com.jayway.restassured.filter.log
Class ResponseLoggingFilter

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

public class ResponseLoggingFilter
extends Object

A filter that'll print the response body if the response matches a given status code.


Constructor Summary
ResponseLoggingFilter()
          Log to system out for all status codes
ResponseLoggingFilter(int statusCode)
          Log to system out if response status code matches the given status code.
ResponseLoggingFilter(LogDetail logDetail)
          Instantiate a logger using the supplied log detail.
ResponseLoggingFilter(LogDetail logDetail, PrintStream stream)
          Instantiate a logger using a specific print stream for all status codes
ResponseLoggingFilter(LogDetail logDetail, PrintStream stream, int statusCode)
          Instantiate a logger using a specific print stream for status codes matching the supplied status code.
ResponseLoggingFilter(LogDetail logDetail, PrintStream stream, org.hamcrest.Matcher<Integer> matcher)
          Instantiate a logger using a specific print stream for status codes matching the supplied matcher.
ResponseLoggingFilter(org.hamcrest.Matcher<Integer> matcher)
          Log to system out if response status code matches the given hamcrest matcher.
ResponseLoggingFilter(PrintStream stream)
          Instantiate a logger using a specific print stream for all status codes
ResponseLoggingFilter(PrintStream stream, int statusCode)
          Instantiate a logger using a specific print stream for status codes matching the supplied status code.
ResponseLoggingFilter(PrintStream stream, org.hamcrest.Matcher<Integer> matcher)
          Instantiate a logger using a specific print stream for status codes matching the supplied status code.
 
Method Summary
 Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx)
          Filter the incoming request and response specifications and outgoing response.
static Filter logResponseIfStatusCodeIs(int statusCode)
          Create a new logging filter without using the "new" operator.
static Filter logResponseIfStatusCodeMatches(org.hamcrest.Matcher<Integer> matcher)
          Create a new logging filter without using the "new" operator.
static Filter logResponseTo(PrintStream stream)
          Create a new logging filter without using the "new" operator.
static Filter logResponseTo(PrintStream stream, LogDetail logDetail)
          Create a new logging filter without using the "new" operator.
static Filter logResponseToIfMatches(PrintStream stream, org.hamcrest.Matcher<Integer> matcher)
          Create a new logging filter without using the "new" operator.
static Filter responseLogger()
          Create a new 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

ResponseLoggingFilter

public ResponseLoggingFilter()
Log to system out for all status codes


ResponseLoggingFilter

public ResponseLoggingFilter(int statusCode)
Log to system out if response status code matches the given status code.

Parameters:
statusCode - The status code

ResponseLoggingFilter

public ResponseLoggingFilter(org.hamcrest.Matcher<Integer> matcher)
Log to system out if response status code matches the given hamcrest matcher.

Parameters:
matcher - The hamcrest matcher

ResponseLoggingFilter

public ResponseLoggingFilter(LogDetail logDetail)
Instantiate a logger using the supplied log detail.

Parameters:
logDetail - The log detail

ResponseLoggingFilter

public ResponseLoggingFilter(PrintStream stream)
Instantiate a logger using a specific print stream for all status codes

Parameters:
stream - The stream to log errors to.

ResponseLoggingFilter

public ResponseLoggingFilter(LogDetail logDetail,
                             PrintStream stream)
Instantiate a logger using a specific print stream for all status codes

Parameters:
logDetail - The log detail
stream - The stream to log errors to.

ResponseLoggingFilter

public ResponseLoggingFilter(PrintStream stream,
                             int statusCode)
Instantiate a logger using a specific print stream for status codes matching the supplied status code.

Parameters:
stream - The stream to log errors to.
statusCode - The status code that must be present in the response if the response body is to be printed.

ResponseLoggingFilter

public ResponseLoggingFilter(PrintStream stream,
                             org.hamcrest.Matcher<Integer> matcher)
Instantiate a logger using a specific print stream for status codes matching the supplied status code.

Parameters:
stream - The stream to log errors to.
matcher - The matcher that must be fulfilled if the response body is to be printed.

ResponseLoggingFilter

public ResponseLoggingFilter(LogDetail logDetail,
                             PrintStream stream,
                             int statusCode)
Instantiate a logger using a specific print stream for status codes matching the supplied status code.

Parameters:
logDetail - The log detail
stream - The stream to log errors to.
statusCode - The status code that must be present in the response if the response body is to be printed.

ResponseLoggingFilter

public ResponseLoggingFilter(LogDetail logDetail,
                             PrintStream stream,
                             org.hamcrest.Matcher<Integer> matcher)
Instantiate a logger using a specific print stream for status codes matching the supplied matcher.

Parameters:
logDetail - The log detail
stream - The stream to log errors to.
matcher - The matcher that must be fulfilled if the response body is to be printed.
Method Detail

responseLogger

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

Returns:
a new instance of the filter

logResponseTo

public static Filter logResponseTo(PrintStream stream)
Create a new 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

logResponseTo

public static Filter logResponseTo(PrintStream stream,
                                   LogDetail logDetail)
Create a new logging filter without using the "new" operator. Will make the DSL look nicer.

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

logResponseIfStatusCodeMatches

public static Filter logResponseIfStatusCodeMatches(org.hamcrest.Matcher<Integer> matcher)
Create a new logging filter without using the "new" operator. Will make the DSL look nicer.

Parameters:
matcher - The matcher that must be fulfilled in order for logging to occur
Returns:
a new instance of the filter

logResponseIfStatusCodeIs

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

Parameters:
statusCode - The status code that must be present in order for logging to occur
Returns:
a new instance of the filter

logResponseToIfMatches

public static Filter logResponseToIfMatches(PrintStream stream,
                                            org.hamcrest.Matcher<Integer> matcher)
Create a new logging filter without using the "new" operator. Will make the DSL look nicer.

Parameters:
stream - The print stream to log to
matcher - The matcher that must be fulfilled in order for logging to occur
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.