com.github.kristofa.test.http
Class DefaultHttpResponseProvider

java.lang.Object
  extended by com.github.kristofa.test.http.DefaultHttpResponseProvider
All Implemented Interfaces:
HttpResponseProvider

public class DefaultHttpResponseProvider
extends Object
implements HttpResponseProvider

A HttpResponseProvider that supports http request with all properties. It supports any http header you define as opposed to SimpleHttpResponseProvider which only supports Content-Type.

Author:
kristof

Constructor Summary
DefaultHttpResponseProvider(boolean ignoreAdditionalHeaders)
          Creates a new instance.
 
Method Summary
 HttpResponse getResponse(HttpRequest request)
          Gets expected response for given request.
 void set(HttpRequest request, HttpResponse response)
          Sets a new request/response.
 void verify()
          Should be executed when all requests have been submitted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHttpResponseProvider

public DefaultHttpResponseProvider(boolean ignoreAdditionalHeaders)
Creates a new instance.

Parameters:
ignoreAdditionalHeaders - In some cases you might want to ignore additional http headers and only want to check some headers. For example sometimes a HTTP client adds custom identification headers you might not be interested in. If this is the case and you don't necessary want a full match then specific true. In case you specify false all http headers will be matched.
Method Detail

set

public void set(HttpRequest request,
                HttpResponse response)
Sets a new request/response.

Parameters:
request - HttpRequest.
response - Response that should be returned for given request.

getResponse

public HttpResponse getResponse(HttpRequest request)
Gets expected response for given request.

Specified by:
getResponse in interface HttpResponseProvider
Parameters:
request - HttpRequest.
Returns:
Response or null in case we don't know given request.

verify

public void verify()
            throws UnsatisfiedExpectationException
Should be executed when all requests have been submitted. Checks if all expected requests have been requested.

Specified by:
verify in interface HttpResponseProvider
Throws:
UnsatisfiedExpectationException - In case expectation were not as expected. See UnsatisfiedExpectationException.getMissingHttpRequests() and UnsatisfiedExpectationException.getUnexpectedHttpRequests() to get missing and unexpected requests.


Copyright © 2014. All Rights Reserved.