Skip to content

Commit 8c39d98

Browse files
committed
fixup! Introduce Kotlin integration tests
Signed-off-by: Sergey Karpov <[email protected]>
1 parent 2586e56 commit 8c39d98

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/KotlinClientTypeScriptServerEdgeCasesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class KotlinClientTypeScriptServerEdgeCasesTest : TypeScriptTestBase() {
5151
if (::tsServerProcess.isInitialized) {
5252
try {
5353
println("Stopping TypeScript server")
54-
stopProcess(tsServerProcess, 3, "TypeScript server")
54+
stopProcess(tsServerProcess)
5555
} catch (e: Exception) {
5656
println("Warning: Error during TypeScript server stop: ${e.message}")
5757
}

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/KotlinClientTypeScriptServerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class KotlinClientTypeScriptServerTest : TypeScriptTestBase() {
5656
if (::tsServerProcess.isInitialized) {
5757
try {
5858
println("Stopping TypeScript server")
59-
stopProcess(tsServerProcess, 3, "TypeScript server")
59+
stopProcess(tsServerProcess)
6060
} catch (e: Exception) {
6161
println("Warning: Error during TypeScript server stop: ${e.message}")
6262
}

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptClientKotlinServerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
2222
killProcessOnPort(port)
2323
httpServer = KotlinServerForTypeScriptClient()
2424
httpServer?.start(port)
25-
if (!waitForPort("localhost", port, 10)) {
25+
if (!waitForPort(port = port)) {
2626
throw IllegalStateException("Kotlin test server did not become ready on localhost:$port within timeout")
2727
}
2828
println("Kotlin server started on port $port")

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptEdgeCasesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TypeScriptEdgeCasesTest : TypeScriptTestBase() {
2323
killProcessOnPort(port)
2424
httpServer = KotlinServerForTypeScriptClient()
2525
httpServer?.start(port)
26-
if (!waitForPort("localhost", port, 10)) {
26+
if (!waitForPort(port = port)) {
2727
throw IllegalStateException("Kotlin test server did not become ready on localhost:$port within timeout")
2828
}
2929
println("Kotlin server started on port $port")

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptTestBase.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ abstract class TypeScriptTestBase {
107107
return true
108108
}
109109

110-
protected fun createProcessOutputReader(process: Process, prefix: String): Thread {
110+
protected fun createProcessOutputReader(process: Process, prefix: String = "TS-SERVER"): Thread {
111111
val outputReader = Thread {
112112
try {
113113
process.inputStream.bufferedReader().useLines { lines ->
@@ -123,7 +123,7 @@ abstract class TypeScriptTestBase {
123123
return outputReader
124124
}
125125

126-
protected fun waitForPort(host: String, port: Int, timeoutSeconds: Long = 10): Boolean {
126+
protected fun waitForPort(host: String = "localhost", port: Int, timeoutSeconds: Long = 10): Boolean {
127127
val deadline = System.currentTimeMillis() + timeoutSeconds * 1000
128128
while (System.currentTimeMillis() < deadline) {
129129
try {
@@ -145,14 +145,14 @@ abstract class TypeScriptTestBase {
145145
.directory(sdkDir)
146146
.redirectErrorStream(true)
147147
val process = processBuilder.start()
148-
if (!waitForPort("localhost", port, 10)) {
148+
if (!waitForPort(port = port)) {
149149
throw IllegalStateException("TypeScript server did not become ready on localhost:$port within timeout")
150150
}
151-
createProcessOutputReader(process, "TS-SERVER").start()
151+
createProcessOutputReader(process).start()
152152
return process
153153
}
154154

155-
protected fun stopProcess(process: Process, waitSeconds: Long = 3, name: String = "process") {
155+
protected fun stopProcess(process: Process, waitSeconds: Long = 3, name: String = "TypeScript server") {
156156
process.destroy()
157157
if (waitForProcessTermination(process, waitSeconds)) {
158158
println("$name stopped gracefully")

0 commit comments

Comments
 (0)