1818
1919import java .time .Duration ;
2020import java .util .Map ;
21- import java .util .stream .Stream ;
2221
2322import io .modelcontextprotocol .AbstractMcpClientServerIntegrationTests ;
2423import io .modelcontextprotocol .client .McpClient ;
2524import io .modelcontextprotocol .client .transport .HttpClientSseClientTransport ;
2625import io .modelcontextprotocol .common .McpTransportContext ;
2726import io .modelcontextprotocol .server .McpServer ;
2827import io .modelcontextprotocol .server .McpServer .AsyncSpecification ;
29- import io .modelcontextprotocol .server .McpServer .SingleSessionSyncSpecification ;
28+ import io .modelcontextprotocol .server .McpServer .SyncSpecification ;
3029import io .modelcontextprotocol .server .McpTransportContextExtractor ;
3130import org .apache .catalina .LifecycleException ;
3231import org .apache .catalina .LifecycleState ;
3332import org .junit .jupiter .api .AfterEach ;
3433import org .junit .jupiter .api .BeforeEach ;
3534import org .junit .jupiter .api .Timeout ;
36- import org .junit .jupiter .params .provider .Arguments ;
3735
38- import org .springframework .ai .mcp .client .webflux .transport .WebFluxSseClientTransport ;
3936import org .springframework .ai .mcp .server .webmvc .transport .WebMvcSseServerTransportProvider ;
4037import org .springframework .context .annotation .Bean ;
4138import org .springframework .context .annotation .Configuration ;
42- import org .springframework .web .reactive .function .client .WebClient ;
4339import org .springframework .web .servlet .config .annotation .EnableWebMvc ;
4440import org .springframework .web .servlet .function .RouterFunction ;
4541import org .springframework .web .servlet .function .ServerRequest ;
@@ -57,24 +53,15 @@ class WebMvcSseIT extends AbstractMcpClientServerIntegrationTests {
5753 static McpTransportContextExtractor <ServerRequest > TEST_CONTEXT_EXTRACTOR = r -> McpTransportContext
5854 .create (Map .of ("important" , "value" ));
5955
60- static Stream <Arguments > clientsForTesting () {
61- return Stream .of (Arguments .of ("httpclient" ), Arguments .of ("webflux" ));
62- }
56+ private TomcatTestUtil .TomcatServer tomcatServer ;
6357
6458 @ Override
65- protected void prepareClients (int port , String mcpEndpoint ) {
66-
67- clientBuilders .put ("httpclient" ,
68- McpClient .sync (HttpClientSseClientTransport .builder ("http://127.0.0.1:" + port ).build ())
69- .initializationTimeout (Duration .ofSeconds (10 )));
70-
71- clientBuilders .put ("webflux" , McpClient
72- .sync (WebFluxSseClientTransport .builder (WebClient .builder ().baseUrl ("http://127.0.0.1:" + port )).build ())
73- .initializationTimeout (Duration .ofSeconds (10 )));
59+ protected McpClient .SyncSpec getMcpClientBuilder () {
60+ int port = this .tomcatServer .tomcat ().getConnector ().getLocalPort ();
61+ return McpClient .sync (HttpClientSseClientTransport .builder ("http://127.0.0.1:" + port ).build ())
62+ .initializationTimeout (Duration .ofSeconds (10 ));
7463 }
7564
76- private TomcatTestUtil .TomcatServer tomcatServer ;
77-
7865 @ BeforeEach
7966 public void before () {
8067
@@ -88,9 +75,6 @@ public void before() {
8875 throw new RuntimeException ("Failed to start Tomcat" , e );
8976 }
9077
91- int port = this .tomcatServer .tomcat ().getConnector ().getLocalPort ();
92- prepareClients (port , MESSAGE_ENDPOINT );
93-
9478 // Get the transport from Spring context
9579 this .mcpServerTransportProvider = this .tomcatServer .appContext ()
9680 .getBean (WebMvcSseServerTransportProvider .class );
@@ -122,7 +106,7 @@ protected AsyncSpecification<?> prepareAsyncServerBuilder() {
122106 }
123107
124108 @ Override
125- protected SingleSessionSyncSpecification prepareSyncServerBuilder () {
109+ protected SyncSpecification <?> prepareSyncServerBuilder () {
126110 return McpServer .sync (this .mcpServerTransportProvider );
127111 }
128112
0 commit comments