Hi!
i have runned into some issue, i have this simple get endpoint that returns a large bytearray:
package com.example.plugins
import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
fun Application.configureRouting() {
routing {
get("/") {
val byteArray = ByteArray(400000000)
call.respondBytes(byteArray)
}
}
}
This works fine, but when i try to create a unit test based on this like so:
package com.example.plugins
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.server.testing.*
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
internal class RoutingTest {
@Test
internal fun `Returns ok on big bytearray`() {
testApplication {
application {
routing {
get("/") {
val byteArray = ByteArray(400000000)
call.respondBytes(byteArray)
}
}
}
val response = client.get("/")
assertEquals(HttpStatusCode.OK, response.status)
}
}
}
Then i get this exception:
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "DefaultDispatcher-worker-1"
Is it my test that are incorrect?