1717package com .google .cloud .pubsub .v1 ;
1818
1919import static com .google .common .truth .Truth .assertThat ;
20- import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertFalse ;
22- import static org .junit .Assert .assertSame ;
23- import static org .junit .Assert .assertTrue ;
24- import static org .junit .Assert .fail ;
20+ import static org .junit .jupiter .api .Assertions .*;
2521
2622import com .google .api .core .ApiFuture ;
2723import com .google .api .gax .batching .BatchingSettings ;
6258import java .util .concurrent .Executors ;
6359import java .util .concurrent .TimeUnit ;
6460import org .easymock .EasyMock ;
65- import org .junit .After ;
66- import org .junit .Before ;
67- import org .junit .Test ;
68- import org .junit .runner .RunWith ;
69- import org .junit .runners .JUnit4 ;
61+ import org .junit .jupiter .api .AfterEach ;
62+ import org .junit .jupiter .api .BeforeEach ;
63+ import org .junit .jupiter .api .Test ;
7064
71- @ RunWith (JUnit4 .class )
7265public class PublisherImplTest {
7366
7467 private static final ProjectTopicName TEST_TOPIC =
@@ -93,7 +86,7 @@ public class PublisherImplTest {
9386
9487 private Server testServer ;
9588
96- @ Before
89+ @ BeforeEach
9790 public void setUp () throws Exception {
9891 testPublisherServiceImpl = new FakePublisherServiceImpl ();
9992
@@ -106,7 +99,7 @@ public void setUp() throws Exception {
10699 fakeExecutor = new FakeScheduledExecutorService ();
107100 }
108101
109- @ After
102+ @ AfterEach
110103 public void tearDown () throws Exception {
111104 testServer .shutdownNow ().awaitTermination ();
112105 testChannel .shutdown ();
@@ -698,7 +691,7 @@ public void testPublishFailureRetries() throws Exception {
698691 shutdownTestPublisher (publisher );
699692 }
700693
701- @ Test ( expected = ExecutionException . class )
694+ @ Test
702695 public void testPublishFailureRetries_retriesDisabled () throws Exception {
703696 Publisher publisher =
704697 getTestPublisherBuilder ()
@@ -715,7 +708,7 @@ public void testPublishFailureRetries_retriesDisabled() throws Exception {
715708 ApiFuture <String > publishFuture1 = sendTestMessage (publisher , "A" );
716709
717710 try {
718- publishFuture1 .get ();
711+ assertThrows ( ExecutionException . class , () -> publishFuture1 .get () );
719712 } finally {
720713 assertSame (testPublisherServiceImpl .getCapturedRequests ().size (), 1 );
721714 shutdownTestPublisher (publisher );
@@ -771,7 +764,7 @@ public void testPublishFailureRetries_maxRetriesSetUnlimited() throws Exception
771764 assertTrue (publisher .awaitTermination (1 , TimeUnit .MINUTES ));
772765 }
773766
774- @ Test ( expected = ExecutionException . class )
767+ @ Test
775768 public void testPublishFailureRetries_nonRetryableFailsImmediately () throws Exception {
776769 Publisher publisher =
777770 getTestPublisherBuilder ()
@@ -791,7 +784,7 @@ public void testPublishFailureRetries_nonRetryableFailsImmediately() throws Exce
791784 ApiFuture <String > publishFuture1 = sendTestMessage (publisher , "A" );
792785
793786 try {
794- publishFuture1 .get ();
787+ assertThrows ( ExecutionException . class , () -> publishFuture1 .get () );
795788 } finally {
796789 assertTrue (testPublisherServiceImpl .getCapturedRequests ().size () >= 1 );
797790 publisher .shutdown ();
0 commit comments