diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/PublisherImplTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/PublisherImplTest.java index 45f66b536..474572691 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/PublisherImplTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/PublisherImplTest.java @@ -524,11 +524,18 @@ public void testResumePublish() throws Exception { .setEnableMessageOrdering(true) .build(); - // This exception should stop future publishing to the same key - testPublisherServiceImpl.addPublishError(new StatusException(Status.INVALID_ARGUMENT)); ApiFuture future1 = sendTestMessageWithOrderingKey(publisher, "m1", "orderA"); ApiFuture future2 = sendTestMessageWithOrderingKey(publisher, "m2", "orderA"); + fakeExecutor.advanceTime(Duration.ZERO); + assertFalse(future1.isDone()); + assertFalse(future2.isDone()); + + // This exception should stop future publishing to the same key + testPublisherServiceImpl.addPublishError(new StatusException(Status.INVALID_ARGUMENT)); + + fakeExecutor.advanceTime(Duration.ZERO); + try { future1.get(); Assert.fail("This should fail."); @@ -633,6 +640,8 @@ public void testPublishThrowExceptionForUnsubmittedOrderingKeyMessage() throws E } catch (ExecutionException e) { assertEquals(SequentialExecutorService.CallbackExecutor.CANCELLATION_EXCEPTION, e.getCause()); } + + shutdownTestPublisher(publisher); } private ApiFuture sendTestMessageWithOrderingKey(