46
46
import io .modelcontextprotocol .util .Utils ;
47
47
import net .javacrumbs .jsonunit .core .Option ;
48
48
import org .junit .jupiter .params .ParameterizedTest ;
49
+ import org .junit .jupiter .params .provider .MethodSource ;
49
50
import org .junit .jupiter .params .provider .ValueSource ;
50
51
import reactor .core .publisher .Mono ;
51
52
import reactor .test .StepVerifier ;
@@ -70,15 +71,14 @@ public abstract class AbstractMcpClientServerIntegrationTests {
70
71
abstract protected McpServer .SyncSpecification <?> prepareSyncServerBuilder ();
71
72
72
73
@ ParameterizedTest (name = "{0} : {displayName} " )
73
- @ ValueSource ( strings = { "httpclient" } )
74
+ @ MethodSource ( "clientsForTesting" )
74
75
void simple (String clientType ) {
75
76
76
77
var clientBuilder = clientBuilders .get (clientType );
77
78
78
79
var server = prepareAsyncServerBuilder ().serverInfo ("test-server" , "1.0.0" )
79
80
.requestTimeout (Duration .ofSeconds (1000 ))
80
81
.build ();
81
-
82
82
try (
83
83
// Create client without sampling capabilities
84
84
var client = clientBuilder .clientInfo (new McpSchema .Implementation ("Sample " + "client" , "0.0.0" ))
@@ -97,7 +97,7 @@ void simple(String clientType) {
97
97
// Sampling Tests
98
98
// ---------------------------------------
99
99
@ ParameterizedTest (name = "{0} : {displayName} " )
100
- @ ValueSource ( strings = { "httpclient" } )
100
+ @ MethodSource ( "clientsForTesting" )
101
101
void testCreateMessageWithoutSamplingCapabilities (String clientType ) {
102
102
103
103
var clientBuilder = clientBuilders .get (clientType );
@@ -133,7 +133,7 @@ void testCreateMessageWithoutSamplingCapabilities(String clientType) {
133
133
}
134
134
135
135
@ ParameterizedTest (name = "{0} : {displayName} " )
136
- @ ValueSource ( strings = { "httpclient" } )
136
+ @ MethodSource ( "clientsForTesting" )
137
137
void testCreateMessageSuccess (String clientType ) {
138
138
139
139
var clientBuilder = clientBuilders .get (clientType );
@@ -202,7 +202,7 @@ void testCreateMessageSuccess(String clientType) {
202
202
}
203
203
204
204
@ ParameterizedTest (name = "{0} : {displayName} " )
205
- @ ValueSource ( strings = { "httpclient" } )
205
+ @ MethodSource ( "clientsForTesting" )
206
206
void testCreateMessageWithRequestTimeoutSuccess (String clientType ) throws InterruptedException {
207
207
208
208
// Client
@@ -282,7 +282,7 @@ void testCreateMessageWithRequestTimeoutSuccess(String clientType) throws Interr
282
282
}
283
283
284
284
@ ParameterizedTest (name = "{0} : {displayName} " )
285
- @ ValueSource ( strings = { "httpclient" } )
285
+ @ MethodSource ( "clientsForTesting" )
286
286
void testCreateMessageWithRequestTimeoutFail (String clientType ) throws InterruptedException {
287
287
288
288
var clientBuilder = clientBuilders .get (clientType );
@@ -348,7 +348,7 @@ void testCreateMessageWithRequestTimeoutFail(String clientType) throws Interrupt
348
348
// Elicitation Tests
349
349
// ---------------------------------------
350
350
@ ParameterizedTest (name = "{0} : {displayName} " )
351
- @ ValueSource ( strings = { "httpclient" } )
351
+ @ MethodSource ( "clientsForTesting" )
352
352
void testCreateElicitationWithoutElicitationCapabilities (String clientType ) {
353
353
354
354
var clientBuilder = clientBuilders .get (clientType );
@@ -380,7 +380,7 @@ void testCreateElicitationWithoutElicitationCapabilities(String clientType) {
380
380
}
381
381
382
382
@ ParameterizedTest (name = "{0} : {displayName} " )
383
- @ ValueSource ( strings = { "httpclient" } )
383
+ @ MethodSource ( "clientsForTesting" )
384
384
void testCreateElicitationSuccess (String clientType ) {
385
385
386
386
var clientBuilder = clientBuilders .get (clientType );
@@ -437,7 +437,7 @@ void testCreateElicitationSuccess(String clientType) {
437
437
}
438
438
439
439
@ ParameterizedTest (name = "{0} : {displayName} " )
440
- @ ValueSource ( strings = { "httpclient" } )
440
+ @ MethodSource ( "clientsForTesting" )
441
441
void testCreateElicitationWithRequestTimeoutSuccess (String clientType ) {
442
442
443
443
var clientBuilder = clientBuilders .get (clientType );
@@ -498,7 +498,7 @@ void testCreateElicitationWithRequestTimeoutSuccess(String clientType) {
498
498
}
499
499
500
500
@ ParameterizedTest (name = "{0} : {displayName} " )
501
- @ ValueSource ( strings = { "httpclient" } )
501
+ @ MethodSource ( "clientsForTesting" )
502
502
void testCreateElicitationWithRequestTimeoutFail (String clientType ) {
503
503
504
504
var latch = new CountDownLatch (1 );
@@ -569,7 +569,7 @@ void testCreateElicitationWithRequestTimeoutFail(String clientType) {
569
569
// Roots Tests
570
570
// ---------------------------------------
571
571
@ ParameterizedTest (name = "{0} : {displayName} " )
572
- @ ValueSource ( strings = { "httpclient" } )
572
+ @ MethodSource ( "clientsForTesting" )
573
573
void testRootsSuccess (String clientType ) {
574
574
var clientBuilder = clientBuilders .get (clientType );
575
575
@@ -617,7 +617,7 @@ void testRootsSuccess(String clientType) {
617
617
}
618
618
619
619
@ ParameterizedTest (name = "{0} : {displayName} " )
620
- @ ValueSource ( strings = { "httpclient" } )
620
+ @ MethodSource ( "clientsForTesting" )
621
621
void testRootsWithoutCapability (String clientType ) {
622
622
623
623
var clientBuilder = clientBuilders .get (clientType );
@@ -656,7 +656,7 @@ void testRootsWithoutCapability(String clientType) {
656
656
}
657
657
658
658
@ ParameterizedTest (name = "{0} : {displayName} " )
659
- @ ValueSource ( strings = { "httpclient" } )
659
+ @ MethodSource ( "clientsForTesting" )
660
660
void testRootsNotificationWithEmptyRootsList (String clientType ) {
661
661
662
662
var clientBuilder = clientBuilders .get (clientType );
@@ -686,7 +686,7 @@ void testRootsNotificationWithEmptyRootsList(String clientType) {
686
686
}
687
687
688
688
@ ParameterizedTest (name = "{0} : {displayName} " )
689
- @ ValueSource ( strings = { "httpclient" } )
689
+ @ MethodSource ( "clientsForTesting" )
690
690
void testRootsWithMultipleHandlers (String clientType ) {
691
691
692
692
var clientBuilder = clientBuilders .get (clientType );
@@ -720,7 +720,7 @@ void testRootsWithMultipleHandlers(String clientType) {
720
720
}
721
721
722
722
@ ParameterizedTest (name = "{0} : {displayName} " )
723
- @ ValueSource ( strings = { "httpclient" } )
723
+ @ MethodSource ( "clientsForTesting" )
724
724
void testRootsServerCloseWithActiveSubscription (String clientType ) {
725
725
726
726
var clientBuilder = clientBuilders .get (clientType );
@@ -755,7 +755,7 @@ void testRootsServerCloseWithActiveSubscription(String clientType) {
755
755
// Tools Tests
756
756
// ---------------------------------------
757
757
@ ParameterizedTest (name = "{0} : {displayName} " )
758
- @ ValueSource ( strings = { "httpclient" } )
758
+ @ MethodSource ( "clientsForTesting" )
759
759
void testToolCallSuccess (String clientType ) {
760
760
761
761
var clientBuilder = clientBuilders .get (clientType );
@@ -806,7 +806,7 @@ void testToolCallSuccess(String clientType) {
806
806
}
807
807
808
808
@ ParameterizedTest (name = "{0} : {displayName} " )
809
- @ ValueSource ( strings = { "httpclient" } )
809
+ @ MethodSource ( "clientsForTesting" )
810
810
void testThrowingToolCallIsCaughtBeforeTimeout (String clientType ) {
811
811
812
812
var clientBuilder = clientBuilders .get (clientType );
@@ -844,7 +844,7 @@ void testThrowingToolCallIsCaughtBeforeTimeout(String clientType) {
844
844
}
845
845
846
846
@ ParameterizedTest (name = "{0} : {displayName} " )
847
- @ ValueSource ( strings = { "httpclient" } )
847
+ @ MethodSource ( "clientsForTesting" )
848
848
void testToolCallSuccessWithTranportContextExtraction (String clientType ) {
849
849
850
850
var clientBuilder = clientBuilders .get (clientType );
@@ -901,7 +901,7 @@ void testToolCallSuccessWithTranportContextExtraction(String clientType) {
901
901
}
902
902
903
903
@ ParameterizedTest (name = "{0} : {displayName} " )
904
- @ ValueSource ( strings = { "httpclient" } )
904
+ @ MethodSource ( "clientsForTesting" )
905
905
void testToolListChangeHandlingSuccess (String clientType ) {
906
906
907
907
var clientBuilder = clientBuilders .get (clientType );
@@ -994,7 +994,7 @@ void testToolListChangeHandlingSuccess(String clientType) {
994
994
}
995
995
996
996
@ ParameterizedTest (name = "{0} : {displayName} " )
997
- @ ValueSource ( strings = { "httpclient" } )
997
+ @ MethodSource ( "clientsForTesting" )
998
998
void testInitialize (String clientType ) {
999
999
1000
1000
var clientBuilder = clientBuilders .get (clientType );
@@ -1015,7 +1015,7 @@ void testInitialize(String clientType) {
1015
1015
// Logging Tests
1016
1016
// ---------------------------------------
1017
1017
@ ParameterizedTest (name = "{0} : {displayName} " )
1018
- @ ValueSource ( strings = { "httpclient" } )
1018
+ @ MethodSource ( "clientsForTesting" )
1019
1019
void testLoggingNotification (String clientType ) throws InterruptedException {
1020
1020
int expectedNotificationsCount = 3 ;
1021
1021
CountDownLatch latch = new CountDownLatch (expectedNotificationsCount );
@@ -1128,7 +1128,7 @@ void testLoggingNotification(String clientType) throws InterruptedException {
1128
1128
// Progress Tests
1129
1129
// ---------------------------------------
1130
1130
@ ParameterizedTest (name = "{0} : {displayName} " )
1131
- @ ValueSource ( strings = { "httpclient" } )
1131
+ @ MethodSource ( "clientsForTesting" )
1132
1132
void testProgressNotification (String clientType ) throws InterruptedException {
1133
1133
int expectedNotificationsCount = 4 ; // 3 notifications + 1 for another progress
1134
1134
// token
@@ -1234,7 +1234,7 @@ void testProgressNotification(String clientType) throws InterruptedException {
1234
1234
// Completion Tests
1235
1235
// ---------------------------------------
1236
1236
@ ParameterizedTest (name = "{0} : Completion call" )
1237
- @ ValueSource ( strings = { "httpclient" } )
1237
+ @ MethodSource ( "clientsForTesting" )
1238
1238
void testCompletionShouldReturnExpectedSuggestions (String clientType ) {
1239
1239
var clientBuilder = clientBuilders .get (clientType );
1240
1240
@@ -1256,7 +1256,7 @@ void testCompletionShouldReturnExpectedSuggestions(String clientType) {
1256
1256
List .of (new PromptArgument ("language" , "Language" , "string" , false ))),
1257
1257
(mcpSyncServerExchange , getPromptRequest ) -> null ))
1258
1258
.completions (new McpServerFeatures .SyncCompletionSpecification (
1259
- new PromptReference ("ref/prompt" , "code_review" , "Code review" ), completionHandler ))
1259
+ new McpSchema . PromptReference ("ref/prompt" , "code_review" , "Code review" ), completionHandler ))
1260
1260
.build ();
1261
1261
1262
1262
try (var mcpClient = clientBuilder .build ()) {
@@ -1285,7 +1285,7 @@ void testCompletionShouldReturnExpectedSuggestions(String clientType) {
1285
1285
// Ping Tests
1286
1286
// ---------------------------------------
1287
1287
@ ParameterizedTest (name = "{0} : {displayName} " )
1288
- @ ValueSource ( strings = { "httpclient" } )
1288
+ @ MethodSource ( "clientsForTesting" )
1289
1289
void testPingSuccess (String clientType ) {
1290
1290
1291
1291
var clientBuilder = clientBuilders .get (clientType );
@@ -1348,7 +1348,7 @@ void testPingSuccess(String clientType) {
1348
1348
// Tool Structured Output Schema Tests
1349
1349
// ---------------------------------------
1350
1350
@ ParameterizedTest (name = "{0} : {displayName} " )
1351
- @ ValueSource ( strings = { "httpclient" } )
1351
+ @ MethodSource ( "clientsForTesting" )
1352
1352
void testStructuredOutputValidationSuccess (String clientType ) {
1353
1353
var clientBuilder = clientBuilders .get (clientType );
1354
1354
@@ -1593,7 +1593,7 @@ void testStructuredOutputValidationFailure(String clientType) {
1593
1593
}
1594
1594
1595
1595
@ ParameterizedTest (name = "{0} : {displayName} " )
1596
- @ ValueSource ( strings = { "httpclient" } )
1596
+ @ MethodSource ( "clientsForTesting" )
1597
1597
void testStructuredOutputMissingStructuredContent (String clientType ) {
1598
1598
1599
1599
var clientBuilder = clientBuilders .get (clientType );
@@ -1644,7 +1644,7 @@ void testStructuredOutputMissingStructuredContent(String clientType) {
1644
1644
}
1645
1645
1646
1646
@ ParameterizedTest (name = "{0} : {displayName} " )
1647
- @ ValueSource ( strings = { "httpclient" } )
1647
+ @ MethodSource ( "clientsForTesting" )
1648
1648
void testStructuredOutputRuntimeToolAddition (String clientType ) {
1649
1649
1650
1650
var clientBuilder = clientBuilders .get (clientType );
0 commit comments