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 ();
@@ -162,7 +160,6 @@ public void testPublishByNumBatchedMessages() throws Exception {
162160 ApiFuture <String > publishFuture3 = sendTestMessage (publisher , "C" );
163161
164162 // Note we are not advancing time but message should still get published
165-
166163 assertEquals ("1" , publishFuture1 .get ());
167164 assertEquals ("2" , publishFuture2 .get ());
168165
@@ -698,7 +695,7 @@ public void testPublishFailureRetries() throws Exception {
698695 shutdownTestPublisher (publisher );
699696 }
700697
701- @ Test ( expected = ExecutionException . class )
698+ @ Test
702699 public void testPublishFailureRetries_retriesDisabled () throws Exception {
703700 Publisher publisher =
704701 getTestPublisherBuilder ()
@@ -715,7 +712,7 @@ public void testPublishFailureRetries_retriesDisabled() throws Exception {
715712 ApiFuture <String > publishFuture1 = sendTestMessage (publisher , "A" );
716713
717714 try {
718- publishFuture1 .get ();
715+ assertThrows ( ExecutionException . class , () -> publishFuture1 .get () );
719716 } finally {
720717 assertSame (testPublisherServiceImpl .getCapturedRequests ().size (), 1 );
721718 shutdownTestPublisher (publisher );
@@ -771,7 +768,7 @@ public void testPublishFailureRetries_maxRetriesSetUnlimited() throws Exception
771768 assertTrue (publisher .awaitTermination (1 , TimeUnit .MINUTES ));
772769 }
773770
774- @ Test ( expected = ExecutionException . class )
771+ @ Test
775772 public void testPublishFailureRetries_nonRetryableFailsImmediately () throws Exception {
776773 Publisher publisher =
777774 getTestPublisherBuilder ()
@@ -791,7 +788,7 @@ public void testPublishFailureRetries_nonRetryableFailsImmediately() throws Exce
791788 ApiFuture <String > publishFuture1 = sendTestMessage (publisher , "A" );
792789
793790 try {
794- publishFuture1 .get ();
791+ assertThrows ( ExecutionException . class , () -> publishFuture1 .get () );
795792 } finally {
796793 assertTrue (testPublisherServiceImpl .getCapturedRequests ().size () >= 1 );
797794 publisher .shutdown ();
0 commit comments