From e7c0c39cd68e707d2c77831c4706f867119b96bc Mon Sep 17 00:00:00 2001 From: hannahrogers-google <52459909+hannahrogers-google@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:15:20 -0800 Subject: [PATCH] Update PublisherImplTest.java --- .../cloud/pubsub/v1/PublisherImplTest.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 0799cd5b4..841d63c25 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 @@ -99,7 +99,7 @@ public void setUp() throws Exception { @After public void tearDown() throws Exception { - testServer.shutdownNow().awaitTermination(); + testServer.shutdownNow().awaitTermination(10, TimeUnit.SECONDS); testChannel.shutdown(); } @@ -238,7 +238,7 @@ public void testPublishByShutdown() throws Exception { assertEquals("2", publishFuture2.get()); fakeExecutor.advanceTime(Duration.ofSeconds(100)); - publisher.awaitTermination(1, TimeUnit.MINUTES); + publisher.awaitTermination(10, TimeUnit.SECONDS); } @Test @@ -499,7 +499,7 @@ public void testEnableMessageOrdering_overwritesMaxAttempts() throws Exception { assertEquals(4, testPublisherServiceImpl.getCapturedRequests().size()); publisher.shutdown(); - assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS)); } @Test @@ -770,7 +770,7 @@ public void testPublishFailureRetries_maxRetriesSetUnlimited() throws Exception assertEquals(3, testPublisherServiceImpl.getCapturedRequests().size()); publisher.shutdown(); - assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS)); } @Test(expected = ExecutionException.class) @@ -799,7 +799,7 @@ public void testPublishFailureRetries_nonRetryableFailsImmediately() throws Exce } finally { assertTrue(testPublisherServiceImpl.getCapturedRequests().size() >= 1); publisher.shutdown(); - assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS)); } } @@ -823,7 +823,7 @@ public void testPublisherGetters() throws Exception { assertEquals(Duration.ofMillis(11), publisher.getBatchingSettings().getDelayThreshold()); assertEquals(12, (long) publisher.getBatchingSettings().getElementCountThreshold()); publisher.shutdown(); - assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS)); } @Test @@ -1024,7 +1024,7 @@ public void testAwaitTermination() throws Exception { .build(); ApiFuture publishFuture1 = sendTestMessage(publisher, "A"); publisher.shutdown(); - assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS)); } @Test @@ -1035,13 +1035,13 @@ public void testShutDown() throws Exception { publisher.publish( PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("A")).build())) .andReturn(apiFuture); - EasyMock.expect(publisher.awaitTermination(1, TimeUnit.MINUTES)).andReturn(true); + EasyMock.expect(publisher.awaitTermination(10, TimeUnit.SECONDS)).andReturn(true); publisher.shutdown(); EasyMock.expectLastCall().once(); EasyMock.replay(publisher); sendTestMessage(publisher, "A"); publisher.shutdown(); - assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS)); } @Test @@ -1313,6 +1313,6 @@ private Builder getTestPublisherBuilder() { private void shutdownTestPublisher(Publisher publisher) throws InterruptedException { publisher.shutdown(); fakeExecutor.advanceTime(Duration.ofSeconds(10)); - assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS)); } }