@@ -229,6 +229,37 @@ void testSkipPropertiesFilterWarnings() {
229229 }
230230 }
231231
232+ @ Test
233+ void testPrimaryURLMatchesPreferredTransport () {
234+ // Create a simple AgentCard (with preferred HTTP_JSON transport even though primary URL points to JSONRPC transport)
235+ AgentCard agentCard = createTestAgentCardBuilder ()
236+ .preferredTransport (TransportProtocol .HTTP_JSON .asString ())
237+ .additionalInterfaces (List .of (
238+ new AgentInterface (TransportProtocol .JSONRPC .asString (), "http://localhost:9999" ),
239+ new AgentInterface (TransportProtocol .GRPC .asString (), "http://localhost:9000" ),
240+ new AgentInterface (TransportProtocol .HTTP_JSON .asString (), "http://localhost:8000" )
241+ ))
242+ .build ();
243+
244+ // Define available transports
245+ Set <String > availableTransports = Set .of (TransportProtocol .JSONRPC .asString (), TransportProtocol .GRPC .asString (), TransportProtocol .HTTP_JSON .asString ());
246+
247+ // Capture logs
248+ Logger logger = Logger .getLogger (AgentCardValidator .class .getName ());
249+ TestLogHandler testLogHandler = new TestLogHandler ();
250+ logger .addHandler (testLogHandler );
251+
252+ try {
253+ AgentCardValidator .validateTransportConfiguration (agentCard , availableTransports );
254+ } finally {
255+ logger .removeHandler (testLogHandler );
256+ }
257+
258+ // Test that the warning was logged
259+ assertTrue (testLogHandler .getLogMessages ().stream ()
260+ .anyMatch (msg -> msg .contains ("AgentCard's URL=http://localhost:9999 does not correspond to the URL of the preferred transport=http://localhost:8000." )));
261+ }
262+
232263 // A simple log handler for testing
233264 private static class TestLogHandler extends Handler {
234265 private final List <String > logMessages = new java .util .ArrayList <>();
0 commit comments