Skip to content

Commit 675b13a

Browse files
committed
re-enable the *ClientStreamableHttpTransportErrorHandlingTest
1 parent 7094a94 commit 675b13a

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/client/transport/WebClientStreamableHttpTransportErrorHandlingTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
* @author Christian Tzolov
4545
*/
4646
@Timeout(15)
47-
@Disabled
4847
public class WebClientStreamableHttpTransportErrorHandlingTest {
4948

5049
private static final int PORT = TestUtil.findAvailablePort();

mcp/src/test/java/io/modelcontextprotocol/client/transport/HttpClientStreamableHttpTransportErrorHandlingTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
* @author Christian Tzolov
4040
*/
4141
@Timeout(15)
42-
@Disabled
4342
public class HttpClientStreamableHttpTransportErrorHandlingTest {
4443

4544
private static final int PORT = TomcatTestUtil.findAvailablePort();

mcp/src/test/java/io/modelcontextprotocol/server/McpCompletionTests.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
import io.modelcontextprotocol.spec.McpSchema;
2828
import io.modelcontextprotocol.spec.McpSchema.CompleteRequest;
2929
import io.modelcontextprotocol.spec.McpSchema.CompleteResult;
30+
import io.modelcontextprotocol.spec.McpSchema.ErrorCodes;
3031
import io.modelcontextprotocol.spec.McpSchema.InitializeResult;
3132
import io.modelcontextprotocol.spec.McpSchema.Prompt;
3233
import io.modelcontextprotocol.spec.McpSchema.PromptArgument;
3334
import io.modelcontextprotocol.spec.McpSchema.ReadResourceResult;
35+
import io.modelcontextprotocol.spec.McpSchema.Resource;
3436
import io.modelcontextprotocol.spec.McpSchema.ResourceReference;
3537
import io.modelcontextprotocol.spec.McpSchema.PromptReference;
3638
import io.modelcontextprotocol.spec.McpSchema.ServerCapabilities;
@@ -84,7 +86,7 @@ public void after() {
8486
tomcat.destroy();
8587
}
8688
catch (LifecycleException e) {
87-
throw new RuntimeException("Failed to stop Tomcat", e);
89+
e.printStackTrace();
8890
}
8991
}
9092
}
@@ -99,8 +101,13 @@ void testCompletionHandlerReceivesContext() {
99101

100102
ResourceReference resourceRef = new ResourceReference("ref/resource", "test://resource/{param}");
101103

102-
McpSchema.Resource resource = new McpSchema.Resource("test://resource/{param}", "Test Resource",
103-
"A resource for testing", "text/plain", 123L, null);
104+
var resource = Resource.builder()
105+
.uri("test://resource/{param}")
106+
.name("Test Resource")
107+
.description("A resource for testing")
108+
.mimeType("text/plain")
109+
.size(123L)
110+
.build();
104111

105112
var mcpServer = McpServer.sync(mcpServerTransportProvider)
106113
.capabilities(ServerCapabilities.builder().completions().build())
@@ -199,8 +206,13 @@ else if ("products_db".equals(db)) {
199206
return new CompleteResult(new CompleteResult.CompleteCompletion(List.of(), 0, false));
200207
};
201208

202-
McpSchema.Resource resource = new McpSchema.Resource("db://{database}/{table}", "Database Table",
203-
"Resource representing a table in a database", "application/json", 456L, null);
209+
McpSchema.Resource resource = Resource.builder()
210+
.uri("db://{database}/{table}")
211+
.name("Database Table")
212+
.description("Resource representing a table in a database")
213+
.mimeType("application/json")
214+
.size(456L)
215+
.build();
204216

205217
var mcpServer = McpServer.sync(mcpServerTransportProvider)
206218
.capabilities(ServerCapabilities.builder().completions().build())
@@ -254,7 +266,10 @@ void testCompletionErrorOnMissingContext() {
254266
// Check if database context is provided
255267
if (request.context() == null || request.context().arguments() == null
256268
|| !request.context().arguments().containsKey("database")) {
257-
throw new McpError("Please select a database first to see available tables");
269+
270+
throw McpError.builder(ErrorCodes.INVALID_REQUEST)
271+
.message("Please select a database first to see available tables")
272+
.build();
258273
}
259274
// Normal completion if context is provided
260275
String db = request.context().arguments().get("database");
@@ -268,8 +283,13 @@ void testCompletionErrorOnMissingContext() {
268283
return new CompleteResult(new CompleteResult.CompleteCompletion(List.of(), 0, false));
269284
};
270285

271-
McpSchema.Resource resource = new McpSchema.Resource("db://{database}/{table}", "Database Table",
272-
"Resource representing a table in a database", "application/json", 456L, null);
286+
McpSchema.Resource resource = Resource.builder()
287+
.uri("db://{database}/{table}")
288+
.name("Database Table")
289+
.description("Resource representing a table in a database")
290+
.mimeType("application/json")
291+
.size(456L)
292+
.build();
273293

274294
var mcpServer = McpServer.sync(mcpServerTransportProvider)
275295
.capabilities(ServerCapabilities.builder().completions().build())

0 commit comments

Comments
 (0)