public class FileHttpResponseProvider extends AbstractHttpResponseProvider
HttpResponseProvider that is able to serve responses for requests/responses previously saved by
HttpRequestResponseFileLogger.
It supports submitting same request multiple times with different return result.
It reads all http requests on construction and keeps them in memory. It does not keep responses in memory. They are read from disk on request and not cached.
HttpRequestResponseFileLogger,
LoggingHttpProxy| Constructor and Description |
|---|
FileHttpResponseProvider(String directory,
String fileName)
Creates a new instance.
|
FileHttpResponseProvider(String directory,
String fileName,
com.github.kristofa.test.http.file.HttpRequestFileReader requestFileReader,
HttpResponseFileReader responseFileReader)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
lazyInitializeExpectedRequestsAndResponses()
Override this method if you want to lazily initialize requests/responses.
|
addExpected, addHttpRequestMatchingFilter, getResponse, resetState, verifypublic FileHttpResponseProvider(String directory, String fileName)
directory - Directory from which to read files.fileName - Base file name. Should not contain extension. Will be suffixed with sequence number and .txt
extension. Should be same as used in HttpRequestResponseFileLogger.public FileHttpResponseProvider(String directory, String fileName, com.github.kristofa.test.http.file.HttpRequestFileReader requestFileReader, HttpResponseFileReader responseFileReader)
directory - Directory from which to read files.fileName - Base file name. Should not contain extension. Will be suffixed with sequence number and .txt
extension. Should be same as used in HttpRequestResponseFileLogger.requestFileReader - HTTP request file reader.responseFileReader - HTTP response file reader.protected void lazyInitializeExpectedRequestsAndResponses()
AbstractHttpResponseProvider.getResponse(HttpRequest).
You can initialize expected requests and responses by calling
AbstractHttpResponseProvider.addExpected(HttpRequest, HttpResponseProxy).lazyInitializeExpectedRequestsAndResponses in class AbstractHttpResponseProviderCopyright © 2014. All Rights Reserved.