Skip to content

Commit a953f59

Browse files
committed
fix: Test cleanup
1 parent fbf600b commit a953f59

File tree

2 files changed

+9
-48
lines changed

2 files changed

+9
-48
lines changed

tests/server-common/src/test/java/io/a2a/server/apps/common/AbstractA2AServerTest.java

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -383,24 +383,7 @@ public void testGetAgentCard() throws A2AClientException {
383383
assertTrue(agentCard.capabilities().streaming());
384384
assertTrue(agentCard.capabilities().stateTransitionHistory());
385385
assertTrue(agentCard.skills().isEmpty());
386-
}
387-
388-
@Test
389-
public void testGetExtendAgentCardNotSupported() {
390-
GetAuthenticatedExtendedCardRequest request = new GetAuthenticatedExtendedCardRequest("1");
391-
GetAuthenticatedExtendedCardResponse response = given()
392-
.contentType(MediaType.APPLICATION_JSON)
393-
.body(request)
394-
.when()
395-
.post("/")
396-
.then()
397-
.statusCode(200)
398-
.extract()
399-
.as(GetAuthenticatedExtendedCardResponse.class);
400-
assertEquals("1", response.getId());
401-
assertInstanceOf(JSONRPCError.class, response.getError());
402-
assertEquals(new AuthenticatedExtendedCardNotConfiguredError().getCode(), response.getError().getCode());
403-
assertNull(response.getResult());
386+
assertFalse(agentCard.supportsAuthenticatedExtendedCard());
404387
}
405388

406389
@Test
@@ -459,10 +442,7 @@ public void testSendMessageStreamExistingTaskSuccess() throws Exception {
459442
@Test
460443
@Timeout(value = 3, unit = TimeUnit.MINUTES)
461444
public void testResubscribeExistingTaskSuccess() throws Exception {
462-
ExecutorService executorService = Executors.newSingleThreadExecutor();
463445
saveTaskInTaskStore(MINIMAL_TASK);
464-
Client client = null;
465-
466446
try {
467447
// attempting to send a streaming message instead of explicitly calling queueManager#createOrTap
468448
// does not work because after the message is sent, the queue becomes null but task resubscription
@@ -498,17 +478,14 @@ public void testResubscribeExistingTaskSuccess() throws Exception {
498478
eventLatch.countDown();
499479
};
500480

501-
// Get client for resubscription
502-
client = getClient();
503-
504481
// Count down when the streaming subscription is established
505482
CountDownLatch subscriptionLatch = new CountDownLatch(1);
506483
awaitStreamingSubscription()
507484
.whenComplete((unused, throwable) -> subscriptionLatch.countDown());
508485

509486
// Resubscribe to the task with specific consumer and error handler
510487
List<BiConsumer<ClientEvent, AgentCard>> consumers = consumer != null ? List.of(consumer) : List.of();
511-
client.resubscribe(new TaskIdParams(MINIMAL_TASK.getId()), consumers, errorHandler, null);
488+
getClient().resubscribe(new TaskIdParams(MINIMAL_TASK.getId()), consumers, errorHandler, null);
512489

513490
// Wait for subscription to be established
514491
assertTrue(subscriptionLatch.await(15, TimeUnit.SECONDS));
@@ -556,18 +533,7 @@ public void testResubscribeExistingTaskSuccess() throws Exception {
556533
assertEquals(TaskState.COMPLETED, receivedStatusEvent.getStatus().state());
557534
assertNotNull(receivedStatusEvent.getStatus().timestamp());
558535
} finally {
559-
try {
560-
if (client != null) {
561-
client.close();
562-
}
563-
} catch (Exception e) {
564-
// Ignore cleanup errors
565-
}
566536
deleteTaskInTaskStore(MINIMAL_TASK.getId());
567-
executorService.shutdown();
568-
if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) {
569-
executorService.shutdownNow();
570-
}
571537
}
572538
}
573539

@@ -582,11 +548,8 @@ public void testResubscribeNoExistingTaskError() throws Exception {
582548
errorLatch.countDown();
583549
};
584550

585-
// Get client for resubscription
586-
Client client = getClient();
587-
588551
try {
589-
client.resubscribe(new TaskIdParams("non-existent-task"), List.of(), errorHandler, null);
552+
getClient().resubscribe(new TaskIdParams("non-existent-task"), List.of(), errorHandler, null);
590553

591554
// Wait for error to be captured (may come via error handler for streaming)
592555
boolean errorReceived = errorLatch.await(10, TimeUnit.SECONDS);
@@ -617,14 +580,6 @@ public void testResubscribeNoExistingTaskError() throws Exception {
617580
} catch (A2AClientException e) {
618581
// Also acceptable - the client might throw an exception immediately
619582
assertInstanceOf(TaskNotFoundError.class, e.getCause());
620-
} finally {
621-
try {
622-
if (client != null) {
623-
client.close();
624-
}
625-
} catch (Exception e) {
626-
// Ignore cleanup errors
627-
}
628583
}
629584
}
630585

transport/grpc/src/test/java/io/a2a/transport/grpc/handler/GrpcHandlerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import io.grpc.stub.StreamObserver;
5151
import mutiny.zero.ZeroPublisher;
5252
import org.junit.jupiter.api.Assertions;
53+
import org.junit.jupiter.api.Disabled;
5354
import org.junit.jupiter.api.Test;
5455
import org.mockito.MockedConstruction;
5556
import org.mockito.Mockito;
@@ -738,6 +739,11 @@ public void testDeletePushNotificationConfigNoPushConfigStore() {
738739
assertGrpcError(streamRecorder, Status.Code.UNIMPLEMENTED);
739740
}
740741

742+
@Disabled
743+
public void testOnGetAuthenticatedExtendedAgentCard() throws Exception {
744+
// TODO - getting the authenticated extended agent card isn't support for gRPC right now
745+
}
746+
741747
private StreamRecorder<SendMessageResponse> sendMessageRequest(GrpcHandler handler) throws Exception {
742748
SendMessageRequest request = SendMessageRequest.newBuilder()
743749
.setRequest(GRPC_MESSAGE)

0 commit comments

Comments
 (0)