public class SessionFilter extends Object implements Filter
SessionFilter sessionFilter = new SessionFilter(); given(). auth().form("John", "Doe"). filter(sessionFilter). expect(). statusCode(200). when(). get("/x"); given(). filter(sessionFilter). // Reuse the same session filter instance to automatically apply the session id from the previous response expect(). statusCode(200). when(). get("/y");
Constructor and Description |
---|
SessionFilter() |
Modifier and Type | Method and Description |
---|---|
Response |
filter(FilterableRequestSpecification requestSpec,
FilterableResponseSpecification responseSpec,
FilterContext ctx)
Filter the incoming request and response specifications and outgoing response.
|
String |
getSessionId() |
boolean |
hasSessionId() |
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 String getSessionId()
public boolean hasSessionId()
true
if a session id has been returned from the server and caught by the filter, false
otherwise.Copyright © 2010–2019. All rights reserved.