Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Support running test cases in offline environments

未關閉
#636 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
docker, java

研究方向

從 AbstractStatelessIntegrationTest.java 中的 testToolCallSuccess 開始,並檢查 mcp-test 和 src/test 下與外部 HTTP 端點相關的測試。在必要的 Docker 映像可用後,使用 -o 執行 Maven 測試生命週期。測試套件能在離線環境中通過且不聯絡外部端點,即表示完成。

由索引模型根據 Issue 內容生成。

描述

enhancement P3 tests

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 -o option 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 main branch
  • JDK: 21
  • OS: Linux
主要語言
Java
星號
3.7k
分支
1.1k
平均合併
1 天 15 小時
30 天內合併 PR
9

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

modelcontextprotocol/java-sdk 的其他 Issue

查看 modelcontextprotocol/java-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。