modelcontextprotocol / modelcontextprotocol/java-sdk
Support running test cases in offline environments
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Java
- Star
- 3.7k
- Fork
- 1.1k
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 9
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với testToolCallSuccess trong AbstractStatelessIntegrationTest.java và kiểm tra các test liên quan trong mcp-test và src/test để tìm các endpoint HTTP bên ngoài. Chạy vòng đời test của Maven với -o sau khi các image Docker cần thiết đã sẵn sàng. Hoàn tất khi bộ test chạy thành công trong môi trường offline mà không liên hệ với các endpoint bên ngoài.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, java
- Lĩnh vực
- build-system, testing-qa
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100