From 657490a4405c3a98d706f58dff52bc52fbd36e01 Mon Sep 17 00:00:00 2001 From: devcrocod Date: Tue, 28 Oct 2025 13:25:57 +0100 Subject: [PATCH 1/2] Relocate `WebSocketIntegrationTest` from `commonTest` to `jvmTest` --- .../kotlin/websocket}/WebSocketIntegrationTest.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) rename kotlin-sdk-test/src/{commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration => jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket}/WebSocketIntegrationTest.kt (95%) diff --git a/kotlin-sdk-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/WebSocketIntegrationTest.kt b/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt similarity index 95% rename from kotlin-sdk-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/WebSocketIntegrationTest.kt rename to kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt index 2a815dd0..a1f39147 100644 --- a/kotlin-sdk-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/WebSocketIntegrationTest.kt +++ b/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt @@ -1,4 +1,4 @@ -package io.modelcontextprotocol.kotlin.sdk.integration +package io.modelcontextprotocol.kotlin.sdk.integration.kotlin.websocket import io.ktor.client.HttpClient import io.ktor.server.application.install @@ -22,7 +22,6 @@ import io.modelcontextprotocol.kotlin.sdk.server.mcpWebSocket import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.test.runTest import kotlinx.coroutines.withContext -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds @@ -34,7 +33,6 @@ import io.ktor.server.websocket.WebSockets as ServerWebSockets class WebSocketIntegrationTest { @Test - @Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3 fun `client should be able to connect to websocket server 2`() = runTest(timeout = 5.seconds) { var server: EmbeddedServer? = null var client: Client? = null @@ -59,7 +57,6 @@ class WebSocketIntegrationTest { * 3. Observe that Client A receives a response related to it. */ @Test - @Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3 fun `single websocket connection`() = runTest(timeout = 5.seconds) { var server: EmbeddedServer? = null var client: Client? = null @@ -88,7 +85,6 @@ class WebSocketIntegrationTest { * 4. Observe that Client B (connection #2) receives a response related to sessionId#1. */ @Test - @Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3 fun `multiple websocket connections`() = runTest(timeout = 5.seconds) { var server: EmbeddedServer? = null var clientA: Client? = null From d7401d886069ceeefbf6edcb14da40454149973b Mon Sep 17 00:00:00 2001 From: devcrocod Date: Wed, 29 Oct 2025 17:23:08 +0100 Subject: [PATCH 2/2] Replace `stopSuspend` and `startSuspend` with synchronous `stop` and `start` in `WebSocketIntegrationTest`. --- .../kotlin/websocket/WebSocketIntegrationTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt b/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt index a1f39147..6200e083 100644 --- a/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt +++ b/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt @@ -45,7 +45,7 @@ class WebSocketIntegrationTest { } } finally { client?.close() - server?.stopSuspend(1000, 2000) + server?.stop(1000, 2000) } } @@ -72,7 +72,7 @@ class WebSocketIntegrationTest { } } finally { client?.close() - server?.stopSuspend(1000, 2000) + server?.stop(1000, 2000) } } @@ -108,7 +108,7 @@ class WebSocketIntegrationTest { } finally { clientA?.close() clientB?.close() - server?.stopSuspend(1000, 2000) + server?.stop(1000, 2000) } } @@ -134,7 +134,7 @@ class WebSocketIntegrationTest { return client } - private suspend fun initServer(): EmbeddedServer { + private fun initServer(): EmbeddedServer { val server = Server( Implementation(name = "websocket-server", version = "1.0.0"), ServerOptions( @@ -171,7 +171,7 @@ class WebSocketIntegrationTest { } } - return ktorServer.startSuspend(wait = false) + return ktorServer.start(wait = false) } /**