TestApplicationEngine
class TestApplicationEngine :
BaseApplicationEngine,
CoroutineScope
ktor test engine that provides way to simulate application calls to existing application module(s) without actual HTTP connection
Types
class Configuration : Configuration Test application engine configuration |
Constructors
TestApplicationEngine( ktor test engine that provides way to simulate application calls to existing application module(s) without actual HTTP connection |
Properties
var callInterceptor: PipelineInterceptor<Unit, ApplicationCall> interceptor for engine calls. can be modified to emulate certain engine behaviour (e.g. error handling) |
|
val client: HttpClient A client instance connected to this test server instance. Only works until engine stop invocation. |
|
val coroutineContext: <ERROR CLASS> |
|
val engine: HttpClientEngine An instance of client engine user to be used in client. |
Inherited Properties
val environment: ApplicationEngineEnvironment instance of ApplicationEngineEnvironment for this engine |
|
val pipeline: EnginePipeline pipeline to use with this engine |
Functions
fun createCall( Creates an instance of test call but doesn’t start request processing |
|
fun handleRequest( Make a test request |
|
fun handleWebSocket( Make a test request that setup a websocket session and wait for completion |
|
fun handleWebSocketConversation( Make a test request that setup a websocket session and invoke callback function that does conversation with server |
|
fun hookRequests( Install a hook for test requests |
|
fun start(wait: Boolean): ApplicationEngine Starts this ApplicationEngine |
|
Stops this ApplicationEngine |
Extension Functions
fun ApplicationEngine.addShutdownHook(stop: () -> Unit): Unit Adds automatic JVM shutdown hooks management. Should be used before starting the engine. Once JVM termination noticed, stop block will be executed. Please note that a shutdown hook only registered when the application is running. If the application is already stopped then there will be no hook and no stop function invocation possible. So stop block will be called once or never. |
|
fun TestApplicationEngine.cookiesSession( Keep cookies between requests inside the callback. |
|
fun CoroutineScope. fun CoroutineScope.decodeChunked( Start a chunked stream decoder coroutine |
|
fun <TEngine : ApplicationEngine, TConfiguration : Configuration> CoroutineScope.embeddedServer( Creates an embedded server with the given factory, listening on host:port |
|
fun TestApplicationEngine.handleRequest( Make a test request |
|
fun CoroutineScope.httpServer( Start an http server with settings invoking handler for every request |
|
fun CoroutineScope. Start an http server with settings invoking handler for every request |
|
fun CoroutineScope.mapEngineExceptions( Returns ByteReadChannel with ByteChannel.close handler that returns SocketTimeoutException instead of SocketTimeoutException. fun CoroutineScope.mapEngineExceptions( Returns ByteWriteChannel with ByteChannel.close handler that returns SocketTimeoutException instead of SocketTimeoutException. |
|
fun CoroutineScope.parseMultipart( fun CoroutineScope.parseMultipart( fun CoroutineScope. Starts a multipart parser coroutine producing multipart events |
|
fun CoroutineScope.pinger( Launch pinger coroutine on CoroutineScope that is sending ping every specified period to outgoing channel, waiting for and verifying client’s pong frames. It is also handling timeout and sending timeout close frame fun CoroutineScope.pinger( Launch pinger coroutine on CoroutineScope that is sending ping every specified periodMillis to outgoing channel, waiting for and verifying client’s pong frames. It is also handling timeoutMillis and sending timeout close frame |
|
fun CoroutineScope.pinger( Launch pinger coroutine on CoroutineScope that is sending ping every specified period to outgoing channel, waiting for and verifying client’s pong frames. It is also handling timeout and sending timeout close frame |
|
fun CoroutineScope.ponger( Launch a ponger actor job on the CoroutineScope sending pongs to outgoing channel. It is acting for every client’s ping frame and replying with corresponding pong |
|
fun CoroutineScope.reader( fun CoroutineScope.reader( |
|
fun CoroutineScope. Start connection HTTP pipeline invoking handler for every request. Note that handler could be invoked multiple times concurrently due to HTTP pipeline nature |
|
fun CoroutineScope.startServerConnectionPipeline( Start connection HTTP pipeline invoking handler for every request. Note that handler could be invoked multiple times concurrently due to HTTP pipeline nature |
|
fun ApplicationEngine.stop( Stops this ApplicationEngine |
|
fun ApplicationEngine.stopServerOnCancellation(): CompletableJob Stop server on job cancellation. The returned deferred need to be completed or cancelled. |
|
fun CoroutineScope. Start multirange response writer coroutine |
|
fun CoroutineScope.writer( fun CoroutineScope.writer( |