@@ -135,51 +135,6 @@ void shouldHandleIncomingMessages() throws Exception {
135135 }).verifyComplete ();
136136 }
137137
138- @ Test
139- @ SuppressWarnings ("unchecked" )
140- void shouldHandleUtf8EncodedMessages () throws Exception {
141-
142- String utf8Content = "한글 漢字 café 🎉" ;
143- String jsonMessage = "{\" jsonrpc\" :\" 2.0\" ,\" method\" :\" test\" ," + "\" params\" :{\" message\" :\" " + utf8Content
144- + "\" },\" id\" :1}\n " ;
145- InputStream stream = new ByteArrayInputStream (jsonMessage .getBytes (StandardCharsets .UTF_8 ));
146-
147- transportProvider = new StdioServerTransportProvider (McpJsonDefaults .getMapper (), stream , System .out );
148- // Set up a real session to capture the message
149- AtomicReference <McpSchema .JSONRPCMessage > capturedMessage = new AtomicReference <>();
150- CountDownLatch messageLatch = new CountDownLatch (1 );
151-
152- McpServerSession .Factory realSessionFactory = transport -> {
153- McpServerSession session = mock (McpServerSession .class );
154- when (session .handle (any ())).thenAnswer (invocation -> {
155- capturedMessage .set (invocation .getArgument (0 ));
156- messageLatch .countDown ();
157- return Mono .empty ();
158- });
159- when (session .closeGracefully ()).thenReturn (Mono .empty ());
160- return session ;
161- };
162-
163- // Set session factory
164- transportProvider .setSessionFactory (realSessionFactory );
165-
166- // Wait for the message to be processed using the latch
167- StepVerifier .create (Mono .fromCallable (() -> messageLatch .await (100 , TimeUnit .SECONDS )).flatMap (success -> {
168- if (!success ) {
169- return Mono .error (new AssertionError ("Timeout waiting for message processing" ));
170- }
171- return Mono .just (capturedMessage .get ());
172- })).assertNext (message -> {
173- assertThat (message ).isNotNull ();
174- assertThat (message ).isInstanceOf (McpSchema .JSONRPCRequest .class );
175- McpSchema .JSONRPCRequest request = (McpSchema .JSONRPCRequest ) message ;
176- assertThat (request .method ()).isEqualTo ("test" );
177- assertThat (request .id ()).isEqualTo (1 );
178- Map <String , Object > params = (Map <String , Object >) request .params ();
179- assertThat (params ).containsEntry ("message" , utf8Content );
180- }).verifyComplete ();
181- }
182-
183138 @ Test
184139 void shouldNotifyClients () {
185140 // Set session factory
0 commit comments