-
Notifications
You must be signed in to change notification settings - Fork 715
Open
Description
Description:
Several test cases in mcp-test and other src/test rely on external HTTP endpoints, which cause test failures in offline CI/CD environments.
For example, test case testToolCallSuccess of AbstractStatelessIntegrationTest.java throws an AssertionError if a GET request to raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md has null or empty response.
Goal:
- Support running maven test lifecycle for offline environments.
- Specifically, all test cases shall pass when
-ooption is appended to mvn test command, provided that all required docker images have already been imported (the default container pull policy will allow this to work offline).
Proposed changes:
Instead of sending GET request using an HTTP client, use a mock client that reads README.md from local file.
HttpClient mockClient = mock(HttpClient.class);
HttpResponse<String> mockResponse = mock(HttpResponse.class);
// Relative path of README.md depending on project directory
when(mockResponse.body()).thenReturn(Files.readString(Path.of("../README.md").toAbsolutePath()));
when(mockResponse.statusCode()).thenReturn(200);
when(mockClient.send(any(HttpRequest.class), any(HttpResponse.BodyHandler.class))).thenReturn(mockResponse);Environment:
- MCP Java SDK: current
mainbranch - JDK: 21
- OS: Linux
Metadata
Metadata
Assignees
Labels
No labels