Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

StaticResourceCalloutMock Class

Utility class used to specify a fake response for testing HTTP callouts.

Namespace

System

Usage

Use the methods in this class to set the response properties for testing HTTP callouts.

StaticResourceCalloutMock Constructors

The following are constructors for StaticResourceCalloutMock.

StaticResourceCalloutMock()

Creates a new instance of the StaticResourceCalloutMock class.

Signature

public StaticResourceCalloutMock()

StaticResourceCalloutMock Methods

The following are methods for StaticResourceCalloutMock. All are instance methods.

setHeader(headerName, headerValue)

Sets the specified header name and value for the fake response.

Signature

public Void setHeader(String headerName, String headerValue)

Parameters

Return Value

Type: Void

setStaticResource(resourceName)

Sets the specified static resource, which contains the response body.

Signature

public Void setStaticResource(String resourceName)

Parameters

Return Value

Type: Void

setStatus(httpStatus)

Sets the specified HTTP status for the response.

Signature

public Void setStatus(String httpStatus)

Parameters

Return Value

Type: Void

setStatusCode(httpStatusCode)

Sets the specified HTTP status for the response.

Signature

public Void setStatusCode(Integer httpStatusCode)

Parameters

Return Value

Type: Void