@@ -959,14 +959,64 @@ public void testStreamingMethodWithAcceptHeader() throws Exception {
959959 }
960960
961961 @ Test
962- public void testSendMessageStreamNewMessageSuccess () throws Exception {
962+ public void testStreamingMethodWithoutAcceptHeader () throws Exception {
963963 // skip this test for non-JSONRPC transports
964964 assumeTrue (TransportProtocol .JSONRPC .asString ().equals (getTransportProtocol ()),
965965 "JSONRPC-specific test" );
966-
966+
967967 testSendStreamingMessage (null );
968968 }
969969
970+ @ Test
971+ public void testSendMessageStreamNewMessageSuccess () throws Exception {
972+ try {
973+ Message message = new Message .Builder (MESSAGE )
974+ .taskId (MINIMAL_TASK .getId ())
975+ .contextId (MINIMAL_TASK .getContextId ())
976+ .build ();
977+
978+ CountDownLatch latch = new CountDownLatch (1 );
979+ AtomicReference <Message > receivedMessage = new AtomicReference <>();
980+ AtomicBoolean wasUnexpectedEvent = new AtomicBoolean (false );
981+ AtomicReference <Throwable > errorRef = new AtomicReference <>();
982+
983+ BiConsumer <ClientEvent , AgentCard > consumer = (event , agentCard ) -> {
984+ if (event instanceof MessageEvent messageEvent ) {
985+ if (latch .getCount () > 0 ) {
986+ receivedMessage .set (messageEvent .getMessage ());
987+ latch .countDown ();
988+ } else {
989+ wasUnexpectedEvent .set (true );
990+ }
991+ } else {
992+ wasUnexpectedEvent .set (true );
993+ }
994+ };
995+
996+ Consumer <Throwable > errorHandler = error -> {
997+ errorRef .set (error );
998+ latch .countDown ();
999+ };
1000+
1001+ // testing the streaming send message
1002+ getClient ().sendMessage (message , List .of (consumer ), errorHandler );
1003+
1004+ assertTrue (latch .await (10 , TimeUnit .SECONDS ));
1005+ assertFalse (wasUnexpectedEvent .get ());
1006+ assertNull (errorRef .get ());
1007+
1008+ Message messageResponse = receivedMessage .get ();
1009+ assertNotNull (messageResponse );
1010+ assertEquals (MESSAGE .getMessageId (), messageResponse .getMessageId ());
1011+ assertEquals (MESSAGE .getRole (), messageResponse .getRole ());
1012+ Part <?> part = messageResponse .getParts ().get (0 );
1013+ assertEquals (Part .Kind .TEXT , part .getKind ());
1014+ assertEquals ("test message" , ((TextPart ) part ).getText ());
1015+ } catch (A2AClientException e ) {
1016+ fail ("Unexpected exception during sendMessage: " + e .getMessage (), e );
1017+ }
1018+ }
1019+
9701020 private void testSendStreamingMessage (String mediaType ) throws Exception {
9711021 Message message = new Message .Builder (MESSAGE )
9721022 .taskId (MINIMAL_TASK .getId ())
0 commit comments