共用方式為


TestProxyPlaybackClient Class

  • java.lang.Object
    • com.azure.core.test.http.TestProxyPlaybackClient

Implements

public class TestProxyPlaybackClient
implements HttpClient

A HttpClient that plays back test recordings from the external test proxy.

Constructor Summary

Constructor Description
TestProxyPlaybackClient(HttpClient httpClient, boolean skipRecordingRequestBody)

Create an instance of TestProxyPlaybackClient with a list of custom sanitizers.

Method Summary

Modifier and Type Method and Description
void addMatcherRequests(List<TestProxyRequestMatcher> matchers)

Add a list of TestProxyRequestMatcher to the current playback session.

void addProxySanitization(List<TestProxySanitizer> sanitizers)

Add a list of TestProxySanitizer to the current playback session.

String getRecordingFileLocation()

Get the recording file location in assets repo.

void removeProxySanitization(List<String> sanitizers)

Removes the list of sanitizers from the current playback session.

Mono<HttpResponse> send(HttpRequest request)

Redirects the request to the test-proxy to retrieve the playback response.

HttpResponse sendSync(HttpRequest request, Context context)

Redirects the request to the test-proxy to retrieve the playback response synchronously.

Queue<String> startPlayback(File recordFile, Path testClassPath)

Starts playback of a test recording.

void stopPlayback()

Stops playback of a test recording.

Methods inherited from java.lang.Object

Constructor Details

TestProxyPlaybackClient

public TestProxyPlaybackClient(HttpClient httpClient, boolean skipRecordingRequestBody)

Create an instance of TestProxyPlaybackClient with a list of custom sanitizers.

Parameters:

httpClient - The HttpClient to use. If none is passed HttpURLConnectionHttpClient is the default.
skipRecordingRequestBody - Flag indicating to skip recording request bodies, so to set a custom matcher to skip comparing bodies when run in playback.

Method Details

addMatcherRequests

public void addMatcherRequests(List matchers)

Add a list of TestProxyRequestMatcher to the current playback session.

Parameters:

matchers - The matchers to add.

addProxySanitization

public void addProxySanitization(List sanitizers)

Add a list of TestProxySanitizer to the current playback session.

Parameters:

sanitizers - The sanitizers to add.

getRecordingFileLocation

public String getRecordingFileLocation()

Get the recording file location in assets repo.

Returns:

the assets repo location of the recording file.

removeProxySanitization

public void removeProxySanitization(List sanitizers)

Removes the list of sanitizers from the current playback session.

Parameters:

sanitizers - The sanitizers to remove.

send

public Mono send(HttpRequest request)

Redirects the request to the test-proxy to retrieve the playback response.

Parameters:

request - The HTTP request to send.

Returns:

The HTTP response.

sendSync

public HttpResponse sendSync(HttpRequest request, Context context)

Redirects the request to the test-proxy to retrieve the playback response synchronously.

Parameters:

request - The HTTP request to send.
context

Returns:

The HTTP response.

startPlayback

public Queue startPlayback(File recordFile, Path testClassPath)

Starts playback of a test recording.

Parameters:

recordFile - The name of the file to read.
testClassPath - the test class path

Returns:

A Queue representing the variables in the recording.

stopPlayback

public void stopPlayback()

Stops playback of a test recording.

Applies to