Use static container in all client and transport tests (#531)

- This allows reusing the containerized MCP server for all tests in a
  single class, significantly speeding up the tests, roughly 10x.

Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
Daniel Garnier-Moiroux 2025-09-03 16:36:46 +02:00 • committed by GitHub
commit a5fd1ebff5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 69 additions and 119 deletions

View file

@ -67,12 +67,6 @@ public abstract class AbstractMcpAsyncClientTests {
abstract protected McpClientTransport createMcpTransport();
protected void onStart() {
}
protected void onClose() {
}
protected Duration getRequestTimeout() {
return Duration.ofSeconds(14);
}
@ -117,16 +111,6 @@ public abstract class AbstractMcpAsyncClientTests {
}
}
@BeforeEach
void setUp() {
onStart();
}
@AfterEach
void tearDown() {
onClose();
}
<T> void verifyNotificationSucceedsWithImplicitInitialization(Function<McpAsyncClient, Mono<T>> operation,
String action) {
withClient(createMcpTransport(), mcpAsyncClient -> {

View file

@ -66,12 +66,6 @@ public abstract class AbstractMcpSyncClientTests {
abstract protected McpClientTransport createMcpTransport();
protected void onStart() {
}
protected void onClose() {
}
protected Duration getRequestTimeout() {
return Duration.ofSeconds(14);
}
@ -114,17 +108,6 @@ public abstract class AbstractMcpSyncClientTests {
}
}
@BeforeEach
void setUp() {
onStart();
}
@AfterEach
void tearDown() {
onClose();
}
static final Object DUMMY_RETURN_VALUE = new Object();
<T> void verifyNotificationSucceedsWithImplicitInitialization(Consumer<McpSyncClient> operation, String action) {