public class TimingFilter extends Object implements Filter
FilterContext
in key ""RA_RESPONSE_TIME_MILLIS"".
Note that this is the time it takes for REST Assured to perform the request and consume the response.
It's does not say how fast the server responds. Measurements can be misleading especially if the JVM is not warm. It's highly recommended
to warm up the JVM by running at least one REST Assured test prior to taking any measurements.Modifier and Type | Field and Description |
---|---|
static String |
RESPONSE_TIME_MILLISECONDS |
Constructor and Description |
---|
TimingFilter()
Constructs a new TimingFilter that doesn't consume the response body automatically if consuming an input stream.
|
TimingFilter(boolean consumeIfInputStream)
Constructs a new TimingFilter that optionally consumes the response body if consuming an input stream.
|
Modifier and Type | Method and Description |
---|---|
Response |
filter(FilterableRequestSpecification requestSpec,
FilterableResponseSpecification responseSpec,
FilterContext ctx)
Filter the incoming request and response specifications and outgoing response.
|
static TimingFilter |
measureTime()
Syntactic sugar for creating a new timing filter
|
public static final String RESPONSE_TIME_MILLISECONDS
public TimingFilter()
public TimingFilter(boolean consumeIfInputStream)
consumeIfInputStream
- Consume response body and include how long it takes to consume the input stream in the response time measurement.public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx)
Filter
FilterContext.next(FilterableRequestSpecification, 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.filter
in interface Filter
requestSpec
- The incoming request specresponseSpec
- The incoming response specctx
- The filter context. You need to call FilterContext.next(FilterableRequestSpecification, FilterableResponseSpecification)
when you're done otherwise the request will not be delivered.public static TimingFilter measureTime()
TimingFilter
Copyright © 2010–2019. All rights reserved.