Skip to content

Commit 61145f5

Browse files
committed
keep tests in sync
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
1 parent e3b999a commit 61145f5

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed

mcp-test/src/main/java/io/modelcontextprotocol/client/AbstractMcpAsyncClientTests.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,4 +830,35 @@ void testProgressConsumer() {
830830
});
831831
}
832832

833+
// Tests for ignorable JSON-RPC methods feature
834+
835+
@Test
836+
void testIgnorableJsonRpcMethodsBuilderList() {
837+
List<String> customIgnorables = List.of("custom/method1", "custom/method2");
838+
839+
withClient(createMcpTransport(), builder -> builder.ignorableJsonRpcMethods(customIgnorables), client -> {
840+
StepVerifier.create(client.initialize()).expectNextMatches(Objects::nonNull).verifyComplete();
841+
});
842+
}
843+
844+
@Test
845+
void testIgnorableJsonRpcMethodsBuilderVarargs() {
846+
withClient(createMcpTransport(),
847+
builder -> builder.ignorableJsonRpcMethods("custom/method1", "custom/method2", "custom/method3"),
848+
client -> {
849+
StepVerifier.create(client.initialize()).expectNextMatches(Objects::nonNull).verifyComplete();
850+
});
851+
}
852+
853+
@Test
854+
void testIgnorableMethodsBuilderNullValidation() {
855+
assertThatThrownBy(() -> McpClient.async(createMcpTransport()).ignorableJsonRpcMethods((List<String>) null))
856+
.isInstanceOf(IllegalArgumentException.class)
857+
.hasMessage("Ignorable JSON-RPC methods must not be null");
858+
859+
assertThatThrownBy(() -> McpClient.async(createMcpTransport()).ignorableJsonRpcMethods((String[]) null))
860+
.isInstanceOf(IllegalArgumentException.class)
861+
.hasMessage("Ignorable JSON-RPC methods must not be null");
862+
}
863+
833864
}

mcp-test/src/main/java/io/modelcontextprotocol/client/AbstractMcpSyncClientTests.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,4 +695,35 @@ void testProgressConsumer() {
695695
});
696696
}
697697

698+
// Tests for ignorable JSON-RPC methods feature
699+
700+
@Test
701+
void testIgnorableJsonRpcMethodsBuilderList() {
702+
List<String> customIgnorables = List.of("custom/method1", "custom/method2");
703+
704+
withClient(createMcpTransport(), builder -> builder.ignorableJsonRpcMethods(customIgnorables), client -> {
705+
assertThatCode(() -> client.initialize()).doesNotThrowAnyException();
706+
});
707+
}
708+
709+
@Test
710+
void testIgnorableJsonRpcMethodsBuilderVarargs() {
711+
withClient(createMcpTransport(),
712+
builder -> builder.ignorableJsonRpcMethods("custom/method1", "custom/method2", "custom/method3"),
713+
client -> {
714+
assertThatCode(() -> client.initialize()).doesNotThrowAnyException();
715+
});
716+
}
717+
718+
@Test
719+
void testIgnorableMethodsBuilderNullValidation() {
720+
assertThatThrownBy(() -> McpClient.sync(createMcpTransport()).ignorableJsonRpcMethods((List<String>) null))
721+
.isInstanceOf(IllegalArgumentException.class)
722+
.hasMessage("Ignorable JSON-RPC methods must not be null");
723+
724+
assertThatThrownBy(() -> McpClient.sync(createMcpTransport()).ignorableJsonRpcMethods((String[]) null))
725+
.isInstanceOf(IllegalArgumentException.class)
726+
.hasMessage("Ignorable JSON-RPC methods must not be null");
727+
}
728+
698729
}

mcp-test/src/main/java/io/modelcontextprotocol/server/AbstractMcpAsyncServerTests.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,4 +522,44 @@ void testRootsChangeHandlers() {
522522
.doesNotThrowAnyException();
523523
}
524524

525+
// ---------------------------------------
526+
// Ignorable JSON-RPC Methods Tests
527+
// ---------------------------------------
528+
529+
@Test
530+
void testIgnorableJsonRpcMethodsBuilderList() {
531+
List<String> customIgnorables = List.of("custom/method1", "custom/method2");
532+
533+
var server = McpServer.async(createMcpTransportProvider())
534+
.serverInfo("test-server", "1.0.0")
535+
.ignorableJsonRpcMethods(customIgnorables)
536+
.build();
537+
538+
assertThat(server).isNotNull();
539+
assertThatCode(() -> server.closeGracefully().block(Duration.ofSeconds(10))).doesNotThrowAnyException();
540+
}
541+
542+
@Test
543+
void testIgnorableJsonRpcMethodsBuilderVarargs() {
544+
var server = McpServer.async(createMcpTransportProvider())
545+
.serverInfo("test-server", "1.0.0")
546+
.ignorableJsonRpcMethods("custom/method1", "custom/method2", "custom/method3")
547+
.build();
548+
549+
assertThat(server).isNotNull();
550+
assertThatCode(() -> server.closeGracefully().block(Duration.ofSeconds(10))).doesNotThrowAnyException();
551+
}
552+
553+
@Test
554+
void testIgnorableMethodsBuilderNullValidation() {
555+
assertThatThrownBy(
556+
() -> McpServer.async(createMcpTransportProvider()).ignorableJsonRpcMethods((List<String>) null))
557+
.isInstanceOf(IllegalArgumentException.class)
558+
.hasMessage("Ignorable JSON-RPC methods must not be null");
559+
560+
assertThatThrownBy(() -> McpServer.async(createMcpTransportProvider()).ignorableJsonRpcMethods((String[]) null))
561+
.isInstanceOf(IllegalArgumentException.class)
562+
.hasMessage("Ignorable JSON-RPC methods must not be null");
563+
}
564+
525565
}

mcp-test/src/main/java/io/modelcontextprotocol/server/AbstractMcpSyncServerTests.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,4 +492,44 @@ void testRootsChangeHandlers() {
492492
assertThatCode(() -> noConsumersServer.closeGracefully()).doesNotThrowAnyException();
493493
}
494494

495+
// ---------------------------------------
496+
// Ignorable JSON-RPC Methods Tests
497+
// ---------------------------------------
498+
499+
@Test
500+
void testIgnorableJsonRpcMethodsBuilderList() {
501+
List<String> customIgnorables = List.of("custom/method1", "custom/method2");
502+
503+
var server = McpServer.sync(createMcpTransportProvider())
504+
.serverInfo("test-server", "1.0.0")
505+
.ignorableJsonRpcMethods(customIgnorables)
506+
.build();
507+
508+
assertThat(server).isNotNull();
509+
assertThatCode(() -> server.closeGracefully()).doesNotThrowAnyException();
510+
}
511+
512+
@Test
513+
void testIgnorableJsonRpcMethodsBuilderVarargs() {
514+
var server = McpServer.sync(createMcpTransportProvider())
515+
.serverInfo("test-server", "1.0.0")
516+
.ignorableJsonRpcMethods("custom/method1", "custom/method2", "custom/method3")
517+
.build();
518+
519+
assertThat(server).isNotNull();
520+
assertThatCode(() -> server.closeGracefully()).doesNotThrowAnyException();
521+
}
522+
523+
@Test
524+
void testIgnorableMethodsBuilderNullValidation() {
525+
assertThatThrownBy(
526+
() -> McpServer.sync(createMcpTransportProvider()).ignorableJsonRpcMethods((List<String>) null))
527+
.isInstanceOf(IllegalArgumentException.class)
528+
.hasMessage("Ignorable JSON-RPC methods must not be null");
529+
530+
assertThatThrownBy(() -> McpServer.sync(createMcpTransportProvider()).ignorableJsonRpcMethods((String[]) null))
531+
.isInstanceOf(IllegalArgumentException.class)
532+
.hasMessage("Ignorable JSON-RPC methods must not be null");
533+
}
534+
495535
}

0 commit comments

Comments
 (0)