Cherrio LLC
01/24/2023, 10:46 AMio.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteBufferChannel (Kotlin reflection is not available) -> class io.ktor.client.plugins.websocket.DefaultClientWebSocketSession (Kotlin reflection is not available)
MockEngine
for websockets?kotlinx.serialization.SerializationException: Serializer for class 'DefaultClientWebSocketSession' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
DefaultClientWebSocketSession
as Serializable. Is there a workaround?Aleksei Tirman [JB]
01/24/2023, 11:01 AMCherrio LLC
01/24/2023, 11:01 AMprivate val mockEngine = MockEngine { _ ->
respond(
content = """{"status":"successful", "message":"success", "data":"Yes"}""",
status = HttpStatusCode.SwitchingProtocols,
headers = headersOf(HttpHeaders.ContentType, "application/text")
)
}
@Test
fun connect_success_ForConnection() = runTest {
data.configure("url","user","path")
val connectResponse = data.connectToServer().unBox()
assertEquals("Connected", connectResponse)
}
Aleksei Tirman [JB]
01/24/2023, 11:02 AMCherrio LLC
01/24/2023, 11:03 AMconnectToServer()
emits a message when a connection is established.
while (true) {
emit("Connected")
val frame = incoming.receive()
if (frame is Frame.Text) {
emit(frame.readText())
}
}
Aleksei Tirman [JB]
01/24/2023, 11:06 AMCherrio LLC
01/24/2023, 11:06 AMAleksei Tirman [JB]
01/24/2023, 11:11 AMMockEngine
doesn’t have such capabilities and making DefaultClientWebSocketSession
serializable won’t help. You may try to test your client from the other end by using the testApplication.Cherrio LLC
01/24/2023, 11:14 AM