99import java .util .Map ;
1010import java .util .stream .Stream ;
1111
12- import io .modelcontextprotocol .AbstractMcpClientServerIntegrationTests ;
1312import io .modelcontextprotocol .client .McpClient ;
1413import io .modelcontextprotocol .client .transport .HttpClientStreamableHttpTransport ;
1514import io .modelcontextprotocol .common .McpTransportContext ;
4241 * @author Andrei Shakirin
4342 */
4443@ Timeout (15 )
45- class ToolInputValidationIntegrationTests extends AbstractMcpClientServerIntegrationTests {
44+ class ToolInputValidationIntegrationTests {
4645
4746 private static final int PORT = TomcatTestUtil .findAvailablePort ();
4847
@@ -61,10 +60,6 @@ class ToolInputValidationIntegrationTests extends AbstractMcpClientServerIntegra
6160
6261 private Tomcat tomcat ;
6362
64- static Stream <Arguments > clientsForTesting () {
65- return Stream .of (Arguments .of ("httpclient" ));
66- }
67-
6863 static Stream <Arguments > validInputTestCases () {
6964 return Stream .of (
7065 // serverType, validationEnabled, inputArgs, expectedOutput
@@ -82,6 +77,10 @@ static Stream<Arguments> invalidInputTestCases() {
8277 // value
8378 }
8479
80+ private final McpClient .SyncSpec clientBuilder = McpClient
81+ .sync (HttpClientStreamableHttpTransport .builder ("http://localhost:" + PORT ).endpoint (MESSAGE_ENDPOINT ).build ())
82+ .requestTimeout (Duration .ofSeconds (10 ));
83+
8584 @ BeforeEach
8685 public void before () {
8786 mcpServerTransportProvider = HttpServletStreamableServerTransportProvider .builder ()
@@ -97,20 +96,12 @@ public void before() {
9796 catch (Exception e ) {
9897 throw new RuntimeException ("Failed to start Tomcat" , e );
9998 }
100-
101- clientBuilders
102- .put ("httpclient" ,
103- McpClient .sync (HttpClientStreamableHttpTransport .builder ("http://localhost:" + PORT )
104- .endpoint (MESSAGE_ENDPOINT )
105- .build ()).requestTimeout (Duration .ofSeconds (10 )));
10699 }
107100
108- @ Override
109101 protected McpServer .AsyncSpecification <?> prepareAsyncServerBuilder () {
110102 return McpServer .async (this .mcpServerTransportProvider );
111103 }
112104
113- @ Override
114105 protected McpServer .SyncSpecification <?> prepareSyncServerBuilder () {
115106 return McpServer .sync (this .mcpServerTransportProvider );
116107 }
@@ -131,10 +122,6 @@ public void after() {
131122 }
132123 }
133124
134- @ Override
135- protected void prepareClients (int port , String mcpEndpoint ) {
136- }
137-
138125 private McpServerFeatures .SyncToolSpecification createSyncTool () {
139126 Tool tool = Tool .builder ()
140127 .name (TOOL_NAME )
@@ -173,7 +160,6 @@ private McpServerFeatures.AsyncToolSpecification createAsyncTool() {
173160 @ MethodSource ("validInputTestCases" )
174161 void validInput_shouldSucceed (String serverType , boolean validationEnabled , Map <String , Object > input ,
175162 String expectedOutput ) {
176- var clientBuilder = clientBuilders .get ("httpclient" );
177163 Object server = createServer (serverType , validationEnabled );
178164
179165 try (var client = clientBuilder .clientInfo (new McpSchema .Implementation ("test-client" , "1.0.0" )).build ()) {
@@ -192,7 +178,6 @@ void validInput_shouldSucceed(String serverType, boolean validationEnabled, Map<
192178 @ MethodSource ("invalidInputTestCases" )
193179 void invalidInput_withDefaultValidation_shouldReturnToolError (String serverType , Map <String , Object > input ,
194180 String expectedErrorSubstring ) {
195- var clientBuilder = clientBuilders .get ("httpclient" );
196181 Object server = createServerWithDefaultValidation (serverType );
197182
198183 try (var client = clientBuilder .clientInfo (new McpSchema .Implementation ("test-client" , "1.0.0" )).build ()) {
@@ -212,7 +197,6 @@ void invalidInput_withDefaultValidation_shouldReturnToolError(String serverType,
212197 @ MethodSource ("invalidInputTestCases" )
213198 void invalidInput_withValidationDisabled_shouldSucceed (String serverType , Map <String , Object > input ,
214199 String ignored ) {
215- var clientBuilder = clientBuilders .get ("httpclient" );
216200 Object server = createServer (serverType , false );
217201
218202 try (var client = clientBuilder .clientInfo (new McpSchema .Implementation ("test-client" , "1.0.0" )).build ()) {
0 commit comments