You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptClientKotlinServerTest.kt
+7-19Lines changed: 7 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -41,13 +41,10 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
41
41
@Test
42
42
@Timeout(20, unit =TimeUnit.SECONDS)
43
43
funtestToolCall() {
44
-
val projectRoot =File(System.getProperty("user.dir"))
45
-
val clientDir =File(projectRoot, "src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/utils")
46
-
47
44
// call the "greet" tool
48
45
val testName ="TestUser"
49
46
val command ="npx tsx myClient.ts $serverUrl greet $testName"
50
-
val output = executeCommand(command, clientDir)
47
+
val output = executeCommand(command, tsClientDir)
51
48
52
49
assertTrue(
53
50
output.contains("Hello, $testName!"),
@@ -65,12 +62,9 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
65
62
@Test
66
63
@Timeout(20, unit =TimeUnit.SECONDS)
67
64
funtestToolCallWithSessionManagement() {
68
-
val projectRoot =File(System.getProperty("user.dir"))
69
-
val clientDir =File(projectRoot, "src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/utils")
70
-
71
65
val testName ="SessionTest"
72
66
val command ="npx tsx myClient.ts $serverUrl greet $testName"
73
-
val output = executeCommand(command, clientDir)
67
+
val output = executeCommand(command, tsClientDir)
74
68
75
69
assertTrue(output.contains("Connected to server"), "Client should connect to server")
76
70
assertTrue(
@@ -82,7 +76,7 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
82
76
83
77
val multiGreetName ="NotificationTest"
84
78
val multiGreetCommand ="npx tsx myClient.ts $serverUrl multi-greet $multiGreetName"
85
-
val multiGreetOutput = executeCommand(multiGreetCommand, clientDir)
79
+
val multiGreetOutput = executeCommand(multiGreetCommand, tsClientDir)
86
80
87
81
assertTrue(multiGreetOutput.contains("Connected to server"), "Client should connect to server")
88
82
assertTrue(
@@ -95,20 +89,17 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
95
89
@Test
96
90
@Timeout(30, unit =TimeUnit.SECONDS)
97
91
funtestMultipleClientSequence() {
98
-
val projectRoot =File(System.getProperty("user.dir"))
99
-
val clientDir =File(projectRoot, "src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/utils")
100
-
101
92
val testName1 ="FirstClient"
102
93
val command1 ="npx tsx myClient.ts $serverUrl greet $testName1"
103
-
val output1 = executeCommand(command1, clientDir)
94
+
val output1 = executeCommand(command1, tsClientDir)
104
95
105
96
assertTrue(output1.contains("Connected to server"), "First client should connect to server")
106
97
assertTrue(output1.contains("Hello, $testName1!"), "Tool response should contain the greeting for first client")
107
98
assertTrue(output1.contains("Disconnected from server"), "First client should disconnect cleanly")
108
99
109
100
val testName2 ="SecondClient"
110
101
val command2 ="npx tsx myClient.ts $serverUrl multi-greet $testName2"
111
-
val output2 = executeCommand(command2, clientDir)
102
+
val output2 = executeCommand(command2, tsClientDir)
112
103
113
104
assertTrue(output2.contains("Connected to server"), "Second client should connect to server")
114
105
assertTrue(
@@ -118,7 +109,7 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
118
109
assertTrue(output2.contains("Disconnected from server"), "Second client should disconnect cleanly")
119
110
120
111
val command3 ="npx tsx myClient.ts $serverUrl"
121
-
val output3 = executeCommand(command3, clientDir)
112
+
val output3 = executeCommand(command3, tsClientDir)
122
113
123
114
assertTrue(output3.contains("Connected to server"), "Third client should connect to server")
124
115
assertTrue(output3.contains("Available utils:"), "Third client should list available utils")
@@ -130,9 +121,6 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
130
121
@Test
131
122
@Timeout(30, unit =TimeUnit.SECONDS)
132
123
funtestMultipleClientParallel() {
133
-
val projectRoot =File(System.getProperty("user.dir"))
134
-
val clientDir =File(projectRoot, "src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/utils")
135
-
136
124
val clientCount =3
137
125
val clients =listOf(
138
126
"FirstClient" to "greet",
@@ -154,7 +142,7 @@ class TypeScriptClientKotlinServerTest : TypeScriptTestBase() {
Copy file name to clipboardExpand all lines: kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptEdgeCasesTest.kt
+8-42Lines changed: 8 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -42,19 +42,16 @@ class TypeScriptEdgeCasesTest : TypeScriptTestBase() {
42
42
@Test
43
43
@Timeout(20, unit =TimeUnit.SECONDS)
44
44
funtestErrorHandling() {
45
-
val projectRoot =File(System.getProperty("user.dir"))
46
-
val clientDir =File(projectRoot, "src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/utils")
47
-
48
45
val nonExistentToolCommand ="npx tsx myClient.ts $serverUrl non-existent-tool"
49
-
val nonExistentToolOutput = executeCommandAllowingFailure(nonExistentToolCommand, clientDir)
46
+
val nonExistentToolOutput = executeCommandAllowingFailure(nonExistentToolCommand, tsClientDir)
50
47
51
48
assertTrue(
52
49
nonExistentToolOutput.contains("Tool \"non-existent-tool\" not found"),
53
50
"Client should handle non-existent tool gracefully"
54
51
)
55
52
56
53
val invalidUrlCommand ="npx tsx myClient.ts http://localhost:${port +1000}/mcp greet TestUser"
57
-
val invalidUrlOutput = executeCommandAllowingFailure(invalidUrlCommand, clientDir)
54
+
val invalidUrlOutput = executeCommandAllowingFailure(invalidUrlCommand, tsClientDir)
Copy file name to clipboardExpand all lines: kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptTestBase.kt
0 commit comments