Skip to content

Commit ab63752

Browse files
committed
fixup! Introduce Kotlin integration tests
1 parent c30ddfc commit ab63752

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/jvmTest/kotlin/integration/typescript/TypeScriptClientKotlinServerTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
2222
killProcessOnPort(port)
2323
httpServer = KotlinServerForTypeScriptClient()
2424
httpServer?.start(port)
25-
Thread.sleep(1000)
25+
if (!waitForPort("localhost", port, 10)) {
26+
throw IllegalStateException("Kotlin test server did not become ready on localhost:$port within timeout")
27+
}
2628
println("Kotlin server started on port $port")
2729
}
2830

src/jvmTest/kotlin/integration/utils/KotlinServerForTypeScriptClient.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ class KotlinServerForTypeScriptClient {
197197
val name = (request.arguments["name"] as? JsonPrimitive)?.content ?: "World"
198198

199199
repeat(3) { index ->
200-
server.sendLoggingMessage(
201-
LoggingMessageNotification(
202-
level = LoggingLevel.info,
203-
data = buildJsonObject {
204-
put("message", JsonPrimitive("Greeting notification #${index + 1} for $name"))
205-
}
206-
)
207-
)
200+
val notifJson = buildJsonObject {
201+
put("level", JsonPrimitive("info"))
202+
put("data", buildJsonObject {
203+
put("message", JsonPrimitive("Greeting notification #${index + 1} for $name"))
204+
})
205+
}
206+
val notif = McpJson.decodeFromJsonElement<LoggingMessageNotification>(notifJson)
207+
server.sendLoggingMessage(notif)
208208
}
209209

210210
CallToolResult(
@@ -232,7 +232,7 @@ class KotlinServerForTypeScriptClient {
232232
messages = listOf(
233233
PromptMessage(
234234
role = Role.user,
235-
content = TextContent("Please greet ${(request.arguments?.get("name") as? JsonPrimitive)?.content ?: "someone"} in a friendly manner.")
235+
content = TextContent("Please greet ${request.arguments?.get("name") ?: "someone"} in a friendly manner.")
236236
)
237237
)
238238
)

0 commit comments

Comments
 (0)