Skip to content

Commit e70da86

Browse files
committed
refactor: standardize test parameterization and fix package naming
- Replace @valuesource with @MethodSource for parameterized tests - Add getTestParameters() methods to provide test arguments consistently - Remove hardcoded Spring-related labels from framework-agnostic mcp-test module - Move mcp-test's utility classes from io.modelcontextprotocol.utils to io.modelcontextprotocol.util This change improves test consistency and fixes package naming convention across the MCP Java SDK test suite. It also removes hardcoded spring transport types. Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
1 parent 80d0ad8 commit e70da86

18 files changed

+136
-74
lines changed

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/WebFluxSseIntegrationTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
import java.time.Duration;
88
import java.util.Map;
9+
import java.util.stream.Stream;
910

1011
import org.junit.jupiter.api.AfterEach;
1112
import org.junit.jupiter.api.BeforeEach;
1213
import org.junit.jupiter.api.Timeout;
14+
import org.junit.jupiter.params.provider.Arguments;
15+
1316
import org.springframework.http.server.reactive.HttpHandler;
1417
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
1518
import org.springframework.web.reactive.function.client.WebClient;
@@ -45,6 +48,10 @@ class WebFluxSseIntegrationTests extends AbstractMcpClientServerIntegrationTests
4548
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = (r) -> McpTransportContext
4649
.create(Map.of("important", "value"));
4750

51+
static Stream<Arguments> getTestParameters() {
52+
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
53+
}
54+
4855
@Override
4956
protected void prepareClients(int port, String mcpEndpoint) {
5057

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/WebFluxStatelessIntegrationTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
package io.modelcontextprotocol;
66

77
import java.time.Duration;
8+
import java.util.stream.Stream;
89

910
import org.junit.jupiter.api.AfterEach;
1011
import org.junit.jupiter.api.BeforeEach;
1112
import org.junit.jupiter.api.Timeout;
13+
import org.junit.jupiter.params.provider.Arguments;
14+
1215
import org.springframework.http.server.reactive.HttpHandler;
1316
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
1417
import org.springframework.web.reactive.function.client.WebClient;
@@ -35,6 +38,10 @@ class WebFluxStatelessIntegrationTests extends AbstractStatelessIntegrationTests
3538

3639
private WebFluxStatelessServerTransport mcpStreamableServerTransport;
3740

41+
static Stream<Arguments> getTestParameters() {
42+
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
43+
}
44+
3845
@Override
3946
protected void prepareClients(int port, String mcpEndpoint) {
4047
clientBuilders

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/WebFluxStreamableIntegrationTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
import java.time.Duration;
88
import java.util.Map;
9+
import java.util.stream.Stream;
910

1011
import org.junit.jupiter.api.AfterEach;
1112
import org.junit.jupiter.api.BeforeEach;
1213
import org.junit.jupiter.api.Timeout;
14+
import org.junit.jupiter.params.provider.Arguments;
15+
1316
import org.springframework.http.server.reactive.HttpHandler;
1417
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
1518
import org.springframework.web.reactive.function.client.WebClient;
@@ -43,6 +46,10 @@ class WebFluxStreamableIntegrationTests extends AbstractMcpClientServerIntegrati
4346
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = (r) -> McpTransportContext
4447
.create(Map.of("important", "value"));
4548

49+
static Stream<Arguments> getTestParameters() {
50+
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
51+
}
52+
4653
@Override
4754
protected void prepareClients(int port, String mcpEndpoint) {
4855

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/client/transport/WebFluxSseClientTransportTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.springframework.http.codec.ServerSentEvent;
3232
import org.springframework.web.reactive.function.client.WebClient;
3333

34-
import static io.modelcontextprotocol.utils.McpJsonMapperUtils.JSON_MAPPER;
34+
import static io.modelcontextprotocol.util.McpJsonMapperUtils.JSON_MAPPER;
3535
import static org.assertj.core.api.Assertions.assertThat;
3636
import static org.assertj.core.api.Assertions.assertThatCode;
3737
import static org.assertj.core.api.Assertions.assertThatThrownBy;

mcp-spring/mcp-spring-webmvc/src/test/java/io/modelcontextprotocol/server/WebMcpStreamableAsyncServerTransportTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import org.apache.catalina.LifecycleException;
99
import org.apache.catalina.startup.Tomcat;
1010
import org.junit.jupiter.api.Timeout;
11+
import org.junit.jupiter.params.provider.Arguments;
12+
1113
import org.springframework.context.annotation.Bean;
1214
import org.springframework.context.annotation.Configuration;
1315
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@@ -16,6 +18,9 @@
1618
import org.springframework.web.servlet.function.RouterFunction;
1719
import org.springframework.web.servlet.function.ServerResponse;
1820

21+
import java.util.stream.Stream;
22+
23+
import io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider;
1924
import io.modelcontextprotocol.server.transport.WebMvcStreamableServerTransportProvider;
2025
import io.modelcontextprotocol.spec.McpStreamableServerTransportProvider;
2126
import reactor.netty.DisposableServer;

mcp-spring/mcp-spring-webmvc/src/test/java/io/modelcontextprotocol/server/WebMvcSseIntegrationTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
import java.time.Duration;
99
import java.util.Map;
10+
import java.util.stream.Stream;
1011

1112
import org.apache.catalina.LifecycleException;
1213
import org.apache.catalina.LifecycleState;
1314
import org.junit.jupiter.api.AfterEach;
1415
import org.junit.jupiter.api.BeforeEach;
1516
import org.junit.jupiter.api.Timeout;
17+
import org.junit.jupiter.params.provider.Arguments;
18+
1619
import org.springframework.context.annotation.Bean;
1720
import org.springframework.context.annotation.Configuration;
1821
import org.springframework.web.reactive.function.client.WebClient;
@@ -43,6 +46,10 @@ class WebMvcSseIntegrationTests extends AbstractMcpClientServerIntegrationTests
4346
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = r -> McpTransportContext
4447
.create(Map.of("important", "value"));
4548

49+
static Stream<Arguments> getTestParameters() {
50+
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
51+
}
52+
4653
@Override
4754
protected void prepareClients(int port, String mcpEndpoint) {
4855

mcp-spring/mcp-spring-webmvc/src/test/java/io/modelcontextprotocol/server/WebMvcStatelessIntegrationTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
import static org.assertj.core.api.Assertions.assertThat;
77

88
import java.time.Duration;
9+
import java.util.stream.Stream;
910

1011
import org.apache.catalina.LifecycleException;
1112
import org.apache.catalina.LifecycleState;
1213
import org.junit.jupiter.api.AfterEach;
1314
import org.junit.jupiter.api.BeforeEach;
1415
import org.junit.jupiter.api.Timeout;
16+
import org.junit.jupiter.params.provider.Arguments;
17+
1518
import org.springframework.context.annotation.Bean;
1619
import org.springframework.context.annotation.Configuration;
1720
import org.springframework.web.reactive.function.client.WebClient;
@@ -37,6 +40,10 @@ class WebMvcStatelessIntegrationTests extends AbstractStatelessIntegrationTests
3740

3841
private WebMvcStatelessServerTransport mcpServerTransport;
3942

43+
static Stream<Arguments> getTestParameters() {
44+
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
45+
}
46+
4047
@Configuration
4148
@EnableWebMvc
4249
static class TestConfig {

mcp-spring/mcp-spring-webmvc/src/test/java/io/modelcontextprotocol/server/WebMvcStreamableIntegrationTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
import java.time.Duration;
99
import java.util.Map;
10+
import java.util.stream.Stream;
1011

1112
import org.apache.catalina.LifecycleException;
1213
import org.apache.catalina.LifecycleState;
1314
import org.junit.jupiter.api.AfterEach;
1415
import org.junit.jupiter.api.BeforeEach;
1516
import org.junit.jupiter.api.Timeout;
17+
import org.junit.jupiter.params.provider.Arguments;
18+
1619
import org.springframework.context.annotation.Bean;
1720
import org.springframework.context.annotation.Configuration;
1821
import org.springframework.web.reactive.function.client.WebClient;
@@ -43,6 +46,10 @@ class WebMvcStreamableIntegrationTests extends AbstractMcpClientServerIntegratio
4346
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = r -> McpTransportContext
4447
.create(Map.of("important", "value"));
4548

49+
static Stream<Arguments> getTestParameters() {
50+
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
51+
}
52+
4653
@Configuration
4754
@EnableWebMvc
4855
static class TestConfig {

0 commit comments

Comments
 (0)