Package org.elypia.webservertestbed
Class Mock
- java.lang.Object
-
- org.elypia.webservertestbed.Mock
-
public final class Mock extends Object
Provides static methods for constructingMockResponseobjects.- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static okhttp3.mockwebserver.MockResponseof(String body)static okhttp3.mockwebserver.MockResponseof(String body, int responseCode)static okhttp3.mockwebserver.MockResponseof(String value, int responseCode, Class<? extends ContentLoader> loaderType)static okhttp3.mockwebserver.MockResponseof(String value, int responseCode, ContentLoader loader)static okhttp3.mockwebserver.MockResponseof(String value, ContentLoader loader)static List<okhttp3.mockwebserver.MockResponse>ofAll(String... responseBodies)
-
-
-
Method Detail
-
ofAll
public static List<okhttp3.mockwebserver.MockResponse> ofAll(String... responseBodies)
- Parameters:
responseBodies- All response bodies to create MockResponses for.- Returns:
- Multiple MockResponses that can be provided to the MockWebServer.
-
of
public static okhttp3.mockwebserver.MockResponse of(String body)
- Parameters:
body- The literal content to add to the response.- Returns:
- The MockResponse that can be provided to the MockWebServer.
-
of
public static okhttp3.mockwebserver.MockResponse of(String value, ContentLoader loader) throws IOException
- Parameters:
value- The string to load via the providedContentLoader.loader- An implementation to load the body from the given value.- Returns:
- The MockResponse that can be provided to the MockWebServer.
- Throws:
IOException- If an exception occurs while loading the content.
-
of
public static okhttp3.mockwebserver.MockResponse of(String value, int responseCode, Class<? extends ContentLoader> loaderType) throws IllegalAccessException, InvocationTargetException, InstantiationException, IOException
- Parameters:
value- The string to load via the providedContentLoader.responseCode- The response code of the response.loaderType- The type ofContentLoaderimplementation, this must have a default constructor.- Returns:
- The MockResponse that can be provided to the MockWebServer.
- Throws:
IllegalAccessException- If the default constructor isn't accesible by this method.InvocationTargetException- If an error occurs trying to construct theContentLoader.InstantiationException- If theContentLoaderpassed is an abstract class.IOException- If an exception occurs while loading the content.
-
of
public static okhttp3.mockwebserver.MockResponse of(String value, int responseCode, ContentLoader loader) throws IOException
- Parameters:
value- The string to load via the providedContentLoader.responseCode- The response code of the response.loader- An implementation to load the body from the given value.- Returns:
- The MockResponse that can be provided to the MockWebServer.
- Throws:
IOException- If an exception occurs while loading the content.
-
of
public static okhttp3.mockwebserver.MockResponse of(String body, int responseCode)
- Parameters:
body- The literal content to add to the response.responseCode- The response code of the response.- Returns:
- The MockResponse that can be provided to the MockWebServer.
-
-