Skip to content

Commit

Permalink
Update PublisherImplTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahrogers-google authored Jan 12, 2024
1 parent 01401ac commit e7c0c39
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}
}

Expand All @@ -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
Expand Down Expand Up @@ -1024,7 +1024,7 @@ public void testAwaitTermination() throws Exception {
.build();
ApiFuture<String> publishFuture1 = sendTestMessage(publisher, "A");
publisher.shutdown();
assertTrue(publisher.awaitTermination(1, TimeUnit.MINUTES));
assertTrue(publisher.awaitTermination(10, TimeUnit.SECONDS));
}

@Test
Expand All @@ -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
Expand Down Expand Up @@ -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));
}
}

0 comments on commit e7c0c39

Please sign in to comment.