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.testMode is TestMode.LIVE, the manager won't attempt to read or create a test session
record.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)
Deprecated.
|
InterceptorManager(String testName,
Map<String,String> textReplacementRules,
boolean doNotRecord)
Creates a new InterceptorManager that replays test session records.
|
InterceptorManager(String testName,
TestMode testMode)
Deprecated.
|
InterceptorManager(TestContextManager testContextManager)
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.
|
com.azure.core.http.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.
|
com.azure.core.http.policy.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.
|
@Deprecated public InterceptorManager(String testName, TestMode testMode)
InterceptorManager.InterceptorManager(TestContextManager) instead.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.UncheckedIOException - 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(TestContextManager testContextManager)
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.testMode is TestMode.LIVE, the manager won't attempt to read or create a test session
record.testName.json"testContextManager - Contextual information about the test being ran, such as test name, TestMode,
and others.UncheckedIOException - 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.@Deprecated public InterceptorManager(String testName, Map<String,String> textReplacementRules)
InterceptorManager.InterceptorManager(String, Map, boolean) instead.textReplacementRules, that can be used by PlaybackClient to replace values in a NetworkCallRecord.getResponse().
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.getResponse() when
playing back network calls.UncheckedIOException - 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 InterceptorManager(String testName, Map<String,String> textReplacementRules, boolean doNotRecord)
textReplacementRules, that can be used by PlaybackClient to replace values in a NetworkCallRecord.getResponse().
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.getResponse() when
playing back network calls.doNotRecord - Flag indicating whether network calls should be record or played back.UncheckedIOException - 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 com.azure.core.http.policy.HttpPipelinePolicy getRecordPolicy()
InterceptorManager.public com.azure.core.http.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 © 2020 Microsoft Corporation. All rights reserved.