DataSourceContractTest.TestResource


public final class DataSourceContractTest.TestResource


Information about a resource that can be used to test the DataSource instance.

Summary

Nested types

Builder for TestResource instances.

Public fields

final byte[]

Returns the expected contents of this resource.

final int

The HTTP method that should be used to request the resource.

final @Nullable String

Returns a human-readable name for the resource, for use in test failure messages.

final byte[]

The body that should be included in a request for the resource.

final ImmutableMap<String, String>

The headers that should be included in a request for the resource.

final Uri

Returns the URI where the resource is served from.

final Map<String, List<String>>

Returns the headers associated with this resource that are expected to be present in getResponseHeaders.

final Set<String>

Returns the keys that must not be present in getResponseHeaders when reading this resource.

final Uri

Returns the URI where the resource should be requested from.

Public methods

DataSourceContractTest.TestResource.Builder

Returns a Builder initialized with the values of this instance.

byte[]

Returns the expected contents of this resource.

int

The HTTP method that should be used to request the resource.

@Nullable String

Returns a human-readable name for the resource, for use in test failure messages.

byte[]

The body that should be included in a request for the resource.

ImmutableMap<String, String>

The headers that should be included in a request for the resource.

Uri

Returns the URI where the resource is served from.

Map<String, List<String>>

Returns the headers associated with this resource that are expected to be present in getResponseHeaders.

Set<String>

Returns the keys that must not be present in getResponseHeaders when reading this resource.

Uri

Returns the URI where the resource should be requested from.

boolean

Returns whether this resource may not report a length.

Public fields

expectedBytes

public final byte[] expectedBytes

Returns the expected contents of this resource.

httpMethod

@DataSpec.HttpMethod
public final int httpMethod

The HTTP method that should be used to request the resource.

name

public final @Nullable String name

Returns a human-readable name for the resource, for use in test failure messages.

requestBody

public final byte[] requestBody

The body that should be included in a request for the resource.

This will be empty if getHttpMethod is HTTP_METHOD_GET.

requestHeaders

public final ImmutableMap<String, String> requestHeaders

The headers that should be included in a request for the resource.

This is not an exhaustive list, extra headers may be included.

resolvedUri

public final Uri resolvedUri

Returns the URI where the resource is served from. This is equal to getUri unless redirection occurred when opening the resource.

responseHeaders

public final Map<String, List<String>> responseHeaders

Returns the headers associated with this resource that are expected to be present in getResponseHeaders.

This doesn't have to be an exhaustive list, extra headers in getResponseHeaders are ignored.

unexpectedResponseHeaderKeys

public final Set<String> unexpectedResponseHeaderKeys

Returns the keys that must not be present in getResponseHeaders when reading this resource.

uri

public final Uri uri

Returns the URI where the resource should be requested from.

Public methods

buildUpon

public DataSourceContractTest.TestResource.Builder buildUpon()

Returns a Builder initialized with the values of this instance.

getExpectedBytes

public byte[] getExpectedBytes()

Returns the expected contents of this resource.

getHttpMethod

@DataSpec.HttpMethod
public int getHttpMethod()

The HTTP method that should be used to request the resource.

getName

public @Nullable String getName()

Returns a human-readable name for the resource, for use in test failure messages.

getRequestBody

public byte[] getRequestBody()

The body that should be included in a request for the resource.

This will be empty if getHttpMethod is HTTP_METHOD_GET.

getRequestHeaders

public ImmutableMap<String, String> getRequestHeaders()

The headers that should be included in a request for the resource.

This is not an exhaustive list, extra headers may be included.

getResolvedUri

public Uri getResolvedUri()

Returns the URI where the resource is served from. This is equal to getUri unless redirection occurred when opening the resource.

getResponseHeaders

public Map<String, List<String>> getResponseHeaders()

Returns the headers associated with this resource that are expected to be present in getResponseHeaders.

This doesn't have to be an exhaustive list, extra headers in getResponseHeaders are ignored.

getUnexpectedResponseHeaderKeys

public Set<String> getUnexpectedResponseHeaderKeys()

Returns the keys that must not be present in getResponseHeaders when reading this resource.

getUri

public Uri getUri()

Returns the URI where the resource should be requested from.

mayResolveToUnknownLength

public boolean mayResolveToUnknownLength()

Returns whether this resource may not report a length.