Skip to content

Commit cae9130

Browse files
authored
Relocate WebSocketIntegrationTest from commonTest to jvmTest (#352)
With Ktor 3.2.3, tests don’t work correctly with wasm, so the websocket tests were moved to the jvm target as the most important one ## How Has This Been Tested? local ## Breaking Changes None ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [x] Refactoring ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed
1 parent 33b2f62 commit cae9130

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.modelcontextprotocol.kotlin.sdk.integration
1+
package io.modelcontextprotocol.kotlin.sdk.integration.kotlin.websocket
22

33
import io.ktor.client.HttpClient
44
import io.ktor.server.application.install
@@ -22,7 +22,6 @@ import io.modelcontextprotocol.kotlin.sdk.server.mcpWebSocket
2222
import kotlinx.coroutines.Dispatchers
2323
import kotlinx.coroutines.test.runTest
2424
import kotlinx.coroutines.withContext
25-
import kotlin.test.Ignore
2625
import kotlin.test.Test
2726
import kotlin.test.assertTrue
2827
import kotlin.time.Duration.Companion.seconds
@@ -34,7 +33,6 @@ import io.ktor.server.websocket.WebSockets as ServerWebSockets
3433
class WebSocketIntegrationTest {
3534

3635
@Test
37-
@Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3
3836
fun `client should be able to connect to websocket server 2`() = runTest(timeout = 5.seconds) {
3937
var server: EmbeddedServer<CIOApplicationEngine, CIOApplicationEngine.Configuration>? = null
4038
var client: Client? = null
@@ -47,7 +45,7 @@ class WebSocketIntegrationTest {
4745
}
4846
} finally {
4947
client?.close()
50-
server?.stopSuspend(1000, 2000)
48+
server?.stop(1000, 2000)
5149
}
5250
}
5351

@@ -59,7 +57,6 @@ class WebSocketIntegrationTest {
5957
* 3. Observe that Client A receives a response related to it.
6058
*/
6159
@Test
62-
@Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3
6360
fun `single websocket connection`() = runTest(timeout = 5.seconds) {
6461
var server: EmbeddedServer<CIOApplicationEngine, CIOApplicationEngine.Configuration>? = null
6562
var client: Client? = null
@@ -75,7 +72,7 @@ class WebSocketIntegrationTest {
7572
}
7673
} finally {
7774
client?.close()
78-
server?.stopSuspend(1000, 2000)
75+
server?.stop(1000, 2000)
7976
}
8077
}
8178

@@ -88,7 +85,6 @@ class WebSocketIntegrationTest {
8885
* 4. Observe that Client B (connection #2) receives a response related to sessionId#1.
8986
*/
9087
@Test
91-
@Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3
9288
fun `multiple websocket connections`() = runTest(timeout = 5.seconds) {
9389
var server: EmbeddedServer<CIOApplicationEngine, CIOApplicationEngine.Configuration>? = null
9490
var clientA: Client? = null
@@ -112,7 +108,7 @@ class WebSocketIntegrationTest {
112108
} finally {
113109
clientA?.close()
114110
clientB?.close()
115-
server?.stopSuspend(1000, 2000)
111+
server?.stop(1000, 2000)
116112
}
117113
}
118114

@@ -138,7 +134,7 @@ class WebSocketIntegrationTest {
138134
return client
139135
}
140136

141-
private suspend fun initServer(): EmbeddedServer<CIOApplicationEngine, CIOApplicationEngine.Configuration> {
137+
private fun initServer(): EmbeddedServer<CIOApplicationEngine, CIOApplicationEngine.Configuration> {
142138
val server = Server(
143139
Implementation(name = "websocket-server", version = "1.0.0"),
144140
ServerOptions(
@@ -175,7 +171,7 @@ class WebSocketIntegrationTest {
175171
}
176172
}
177173

178-
return ktorServer.startSuspend(wait = false)
174+
return ktorServer.start(wait = false)
179175
}
180176

181177
/**

0 commit comments

Comments
 (0)