MockServer

actual class MockServer : MockServerInterface
expect class MockServer : MockServerInterface
actual class MockServer : MockServerInterface
actual class MockServer : MockServerInterface

Parameters

acceptDelayMillis

: an artificial delay introduced before each accept() call. Can be used to simulate slow connections.

Constructors

Link copied to clipboard
fun MockServer(acceptDelayMillis: Long, mockServerHandler: MockServerHandler = QueueMockServerHandler())
Link copied to clipboard
actual fun MockServer(mockServerHandler: MockServerHandler)
expect fun MockServer(mockServerHandler: MockServerHandler = QueueMockServerHandler())
actual fun MockServer(mockServerHandler: MockServerHandler)
actual fun MockServer(mockServerHandler: MockServerHandler)

Functions

Link copied to clipboard
open override fun enqueue(mockResponse: MockResponse)

Enqueue a response

abstract fun enqueue(mockResponse: MockResponse)

Enqueue a response

open override fun enqueue(mockResponse: MockResponse)

Enqueue a response

open override fun enqueue(mockResponse: MockResponse)

Enqueue a response

Link copied to clipboard
open suspend override fun stop()

MockServer can only stop in between complete request/responses pairs If stop() is called while we're reading a request, this might wait forever Revisit once okio has native Timeout

abstract suspend fun stop()

Stops the server

open suspend override fun stop()

Stops the server

open suspend override fun stop()

Stops the server

Link copied to clipboard
open override fun takeRequest(): MockRequest

Returns a request from the recorded requests or throws if no request has been received

abstract fun takeRequest(): MockRequest

Returns a request from the recorded requests or throws if no request has been received

open override fun takeRequest(): MockRequest

Returns a request from the recorded requests or throws if no request has been received

open override fun takeRequest(): MockRequest

Returns a request from the recorded requests or throws if no request has been received

Link copied to clipboard
open suspend override fun url(): String

Returns the root url for this server

abstract suspend fun url(): String

Returns the root url for this server

open suspend override fun url(): String

Returns the root url for this server

open suspend override fun url(): String

Returns the root url for this server

Properties

Link copied to clipboard
open override val mockServerHandler: MockServerHandler

The mock server handler used to respond to requests.

abstract val mockServerHandler: MockServerHandler

The mock server handler used to respond to requests.

open override val mockServerHandler: MockServerHandler

The mock server handler used to respond to requests.

open override val mockServerHandler: MockServerHandler

The mock server handler used to respond to requests.

Extensions

Link copied to clipboard
fun MockServer.enqueue(    string: String = "",     delayMs: Long = 0,     statusCode: Int = 200)
Link copied to clipboard
fun MockServer.enqueueMultipart(    parts: List<String>,     statusCode: Int = 200,     partsContentType: String = "application/json; charset=utf-8",     headers: Map<String, String> = emptyMap(),     responseDelayMillis: Long = 0,     chunksDelayMillis: Long = 0,     boundary: String = "-")