@@ -432,12 +432,6 @@ void testCreateElicitationWithRequestTimeoutSuccess(String clientType) {
432432 Function <ElicitRequest , ElicitResult > elicitationHandler = request -> {
433433 assertThat (request .message ()).isNotEmpty ();
434434 assertThat (request .requestedSchema ()).isNotNull ();
435- try {
436- TimeUnit .SECONDS .sleep (2 );
437- }
438- catch (InterruptedException e ) {
439- throw new RuntimeException (e );
440- }
441435 return new ElicitResult (ElicitResult .Action .ACCEPT , Map .of ("message" , request .message ()));
442436 };
443437
@@ -491,14 +485,18 @@ void testCreateElicitationWithRequestTimeoutSuccess(String clientType) {
491485 @ ValueSource (strings = { "httpclient" , "webflux" })
492486 void testCreateElicitationWithRequestTimeoutFail (String clientType ) {
493487
488+ var latch = new CountDownLatch (1 );
494489 // Client
495490 var clientBuilder = clientBuilders .get (clientType );
496491
497492 Function <ElicitRequest , ElicitResult > elicitationHandler = request -> {
498493 assertThat (request .message ()).isNotEmpty ();
499494 assertThat (request .requestedSchema ()).isNotNull ();
495+
500496 try {
501- TimeUnit .SECONDS .sleep (2 );
497+ if (!latch .await (2 , TimeUnit .SECONDS )) {
498+ throw new RuntimeException ("Timeout waiting for elicitation processing" );
499+ }
502500 }
503501 catch (InterruptedException e ) {
504502 throw new RuntimeException (e );
@@ -536,7 +534,7 @@ void testCreateElicitationWithRequestTimeoutFail(String clientType) {
536534
537535 var mcpServer = McpServer .async (mcpServerTransportProvider )
538536 .serverInfo ("test-server" , "1.0.0" )
539- .requestTimeout (Duration .ofSeconds (1 ))
537+ .requestTimeout (Duration .ofSeconds (1 )) // 1 second.
540538 .tools (tool )
541539 .build ();
542540
0 commit comments