public class InterceptorManager extends Object implements AutoCloseable
testName.json"
testMode is TestMode.PLAYBACK, the manager tries to find an existing test session
record to read network calls from.testMode is TestMode.RECORD, the manager creates a new test session record and saves
all the network calls to it.InterceptorManager is disposed, if the testMode is TestMode.RECORD, the network
calls that were recorded are persisted to: "session-records/testName.json"| Constructor and Description |
|---|
InterceptorManager(String testName,
Map<String,String> textReplacementRules)
Creates a new InterceptorManager that replays test session records.
|
InterceptorManager(String testName,
TestMode testMode)
Creates a new InterceptorManager that either replays test-session records or saves them.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTextReplacementRule(String regex,
String replacement)
Add text replacement rule (regex as key, the replacement text as value) into
InterceptorManager.textReplacementRules |
void |
close()
Disposes of resources used by this InterceptorManager.
|
HttpClient |
getPlaybackClient()
Gets a new HTTP client that plays back test session records managed by
InterceptorManager. |
RecordedData |
getRecordedData()
Gets the recorded data InterceptorManager is keeping track of.
|
HttpPipelinePolicy |
getRecordPolicy()
Gets a new HTTP pipeline policy that records network calls and its data is managed by
InterceptorManager. |
boolean |
isPlaybackMode()
Gets whether this InterceptorManager is in playback mode.
|
public InterceptorManager(String testName, TestMode testMode) throws IOException
testMode is TestMode.PLAYBACK, the manager tries to find an existing test session
record to read network calls from.testMode is TestMode.RECORD, the manager creates a new test session record and saves
all the network calls to it.testName.json"testName - Name of the test session record.testMode - The TestMode for this interceptor.IOException - If testMode is TestMode.PLAYBACK and an existing test session record could
not be located or the data could not be deserialized into an instance of RecordedData.NullPointerException - If testName is null.public InterceptorManager(String testName, Map<String,String> textReplacementRules) throws IOException
textReplacementRules, that can be used by PlaybackClient to replace values in a
NetworkCallRecord.response().
The test session records are read from: "session-records/testName.json"testName - Name of the test session record.textReplacementRules - A set of rules to replace text in NetworkCallRecord.response() when playing
back network calls.IOException - An existing test session record could not be located or the data could not be deserialized
into an instance of RecordedData.NullPointerException - If testName or textReplacementRules is null.public boolean isPlaybackMode()
public RecordedData getRecordedData()
public HttpPipelinePolicy getRecordPolicy()
InterceptorManager.public HttpClient getPlaybackClient()
InterceptorManager.public void close()
testMode is TestMode.RECORD, all the network calls are persisted to:
"session-records/testName.json"close in interface AutoCloseablepublic void addTextReplacementRule(String regex, String replacement)
InterceptorManager.textReplacementRulesregex - the pattern to locate the position of replacementreplacement - the replacement textCopyright © 2019 Microsoft Corporation. All rights reserved.