-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathWebSocketTransportTest.kt
51 lines (41 loc) · 1.37 KB
/
WebSocketTransportTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package client
import io.ktor.server.testing.*
import io.ktor.server.websocket.*
import kotlinx.coroutines.CompletableDeferred
import io.modelcontextprotocol.kotlin.sdk.client.mcpWebSocketTransport
import org.junit.jupiter.api.Test
import io.modelcontextprotocol.kotlin.sdk.server.mcpWebSocket
import io.modelcontextprotocol.kotlin.sdk.server.mcpWebSocketTransport
import org.junit.jupiter.api.Disabled
class WebSocketTransportTest : BaseTransportTest() {
@Test
@Disabled("Test disabled for investigation #17")
fun `should start then close cleanly`() = testApplication {
install(WebSockets)
routing {
mcpWebSocket()
}
val client = createClient {
install(io.ktor.client.plugins.websocket.WebSockets)
}.mcpWebSocketTransport()
testClientOpenClose(client)
}
@Test
fun `should read messages`() = testApplication {
val clientFinished = CompletableDeferred<Unit>()
install(WebSockets)
routing {
mcpWebSocketTransport {
onMessage = {
send(it)
}
clientFinished.await()
}
}
val client = createClient {
install(io.ktor.client.plugins.websocket.WebSockets)
}.mcpWebSocketTransport()
testClientRead(client)
clientFinished.complete(Unit)
}
}