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 .assertEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertFalse ;
22+ import static org .junit .jupiter .api .Assertions .assertSame ;
23+ import static org .junit .jupiter .api .Assertions .assertThrows ;
24+ import static org .junit .jupiter .api .Assertions .assertTrue ;
25+ import static org .junit .jupiter .api .Assertions .fail ;
2526
2627import com .google .api .core .ApiFuture ;
2728import com .google .api .gax .batching .BatchingSettings ;
6263import java .util .concurrent .Executors ;
6364import java .util .concurrent .TimeUnit ;
6465import 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 ;
66+ import org .junit .jupiter .api .AfterEach ;
67+ import org .junit .jupiter .api .BeforeEach ;
68+ import org .junit .jupiter .api .Test ;
7069
71- @ RunWith (JUnit4 .class )
7270public class PublisherImplTest {
7371
7472 private static final ProjectTopicName TEST_TOPIC =
@@ -93,7 +91,7 @@ public class PublisherImplTest {
9391
9492 private Server testServer ;
9593
96- @ Before
94+ @ BeforeEach
9795 public void setUp () throws Exception {
9896 testPublisherServiceImpl = new FakePublisherServiceImpl ();
9997
@@ -106,7 +104,7 @@ public void setUp() throws Exception {
106104 fakeExecutor = new FakeScheduledExecutorService ();
107105 }
108106
109- @ After
107+ @ AfterEach
110108 public void tearDown () throws Exception {
111109 testServer .shutdownNow ().awaitTermination ();
112110 testChannel .shutdown ();
@@ -698,7 +696,7 @@ public void testPublishFailureRetries() throws Exception {
698696 shutdownTestPublisher (publisher );
699697 }
700698
701- @ Test ( expected = ExecutionException . class )
699+ @ Test
702700 public void testPublishFailureRetries_retriesDisabled () throws Exception {
703701 Publisher publisher =
704702 getTestPublisherBuilder ()
@@ -715,7 +713,7 @@ public void testPublishFailureRetries_retriesDisabled() throws Exception {
715713 ApiFuture <String > publishFuture1 = sendTestMessage (publisher , "A" );
716714
717715 try {
718- publishFuture1 .get ();
716+ assertThrows ( ExecutionException . class , () -> publishFuture1 .get () );
719717 } finally {
720718 assertSame (testPublisherServiceImpl .getCapturedRequests ().size (), 1 );
721719 shutdownTestPublisher (publisher );
@@ -771,7 +769,7 @@ public void testPublishFailureRetries_maxRetriesSetUnlimited() throws Exception
771769 assertTrue (publisher .awaitTermination (1 , TimeUnit .MINUTES ));
772770 }
773771
774- @ Test ( expected = ExecutionException . class )
772+ @ Test
775773 public void testPublishFailureRetries_nonRetryableFailsImmediately () throws Exception {
776774 Publisher publisher =
777775 getTestPublisherBuilder ()
@@ -791,7 +789,7 @@ public void testPublishFailureRetries_nonRetryableFailsImmediately() throws Exce
791789 ApiFuture <String > publishFuture1 = sendTestMessage (publisher , "A" );
792790
793791 try {
794- publishFuture1 .get ();
792+ assertThrows ( ExecutionException . class , () -> publishFuture1 .get () );
795793 } finally {
796794 assertTrue (testPublisherServiceImpl .getCapturedRequests ().size () >= 1 );
797795 publisher .shutdown ();
0 commit comments