6969import java .util .concurrent .ScheduledFuture ;
7070import java .util .concurrent .TimeUnit ;
7171import java .util .concurrent .atomic .AtomicInteger ;
72- import org .junit .After ;
73- import org .junit .Assert ;
74- import org .junit .Test ;
75- import org .junit .runner .RunWith ;
76- import org .junit .runners .JUnit4 ;
72+ import org .junit .jupiter .api .AfterEach ;
73+ import org .junit .jupiter .api .Assertions ;
74+ import org .junit .jupiter .api .Test ;
7775import org .mockito .ArgumentCaptor ;
7876import org .mockito .Mockito ;
7977import org .mockito .stubbing .Answer ;
8078
81- @ RunWith (JUnit4 .class )
82- public class ChannelPoolTest {
79+ class ChannelPoolTest {
8380 private static final int DEFAULT_AWAIT_TERMINATION_SEC = 10 ;
8481 private ChannelPool pool ;
8582
86- @ After
87- public void cleanup () throws InterruptedException {
83+ @ AfterEach
84+ void cleanup () throws InterruptedException {
8885 Preconditions .checkNotNull (pool , "Channel pool was never created" );
8986 pool .shutdown ();
9087 pool .awaitTermination (DEFAULT_AWAIT_TERMINATION_SEC , TimeUnit .SECONDS );
9188 }
9289
9390 @ Test
94- public void testAuthority () throws IOException {
91+ void testAuthority () throws IOException {
9592 ManagedChannel sub1 = Mockito .mock (ManagedChannel .class );
9693 ManagedChannel sub2 = Mockito .mock (ManagedChannel .class );
9794
@@ -105,7 +102,7 @@ public void testAuthority() throws IOException {
105102 }
106103
107104 @ Test
108- public void testRoundRobin () throws IOException {
105+ void testRoundRobin () throws IOException {
109106 ManagedChannel sub1 = Mockito .mock (ManagedChannel .class );
110107 ManagedChannel sub2 = Mockito .mock (ManagedChannel .class );
111108
@@ -144,7 +141,7 @@ private void verifyTargetChannel(
144141 }
145142
146143 @ Test
147- public void ensureEvenDistribution () throws InterruptedException , IOException {
144+ void ensureEvenDistribution () throws InterruptedException , IOException {
148145 int numChannels = 10 ;
149146 final ManagedChannel [] channels = new ManagedChannel [numChannels ];
150147 final AtomicInteger [] counts = new AtomicInteger [numChannels ];
@@ -197,7 +194,7 @@ public void ensureEvenDistribution() throws InterruptedException, IOException {
197194
198195 // Test channelPrimer is called same number of times as poolSize if executorService is set to null
199196 @ Test
200- public void channelPrimerShouldCallPoolConstruction () throws IOException {
197+ void channelPrimerShouldCallPoolConstruction () throws IOException {
201198 ChannelPrimer mockChannelPrimer = Mockito .mock (ChannelPrimer .class );
202199 ManagedChannel channel1 = Mockito .mock (ManagedChannel .class );
203200 ManagedChannel channel2 = Mockito .mock (ManagedChannel .class );
@@ -215,7 +212,7 @@ public void channelPrimerShouldCallPoolConstruction() throws IOException {
215212
216213 // Test channelPrimer is called periodically, if there's an executorService
217214 @ Test
218- public void channelPrimerIsCalledPeriodically () throws IOException {
215+ void channelPrimerIsCalledPeriodically () throws IOException {
219216 ChannelPrimer mockChannelPrimer = Mockito .mock (ChannelPrimer .class );
220217 ManagedChannel channel1 = Mockito .mock (ManagedChannel .class );
221218 ManagedChannel channel2 = Mockito .mock (ManagedChannel .class );
@@ -266,7 +263,7 @@ public void channelPrimerIsCalledPeriodically() throws IOException {
266263 // ----
267264 // call should be allowed to complete and the channel should not be shutdown
268265 @ Test
269- public void callShouldCompleteAfterCreation () throws IOException {
266+ void callShouldCompleteAfterCreation () throws IOException {
270267 ManagedChannel underlyingChannel = Mockito .mock (ManagedChannel .class );
271268 ManagedChannel replacementChannel = Mockito .mock (ManagedChannel .class );
272269 FakeChannelFactory channelFactory =
@@ -314,7 +311,7 @@ public void callShouldCompleteAfterCreation() throws IOException {
314311
315312 // call should be allowed to complete and the channel should not be shutdown
316313 @ Test
317- public void callShouldCompleteAfterStarted () throws IOException {
314+ void callShouldCompleteAfterStarted () throws IOException {
318315 final ManagedChannel underlyingChannel = Mockito .mock (ManagedChannel .class );
319316 ManagedChannel replacementChannel = Mockito .mock (ManagedChannel .class );
320317
@@ -359,7 +356,7 @@ public void callShouldCompleteAfterStarted() throws IOException {
359356
360357 // Channel should be shutdown after a refresh all the calls have completed
361358 @ Test
362- public void channelShouldShutdown () throws IOException {
359+ void channelShouldShutdown () throws IOException {
363360 ManagedChannel underlyingChannel = Mockito .mock (ManagedChannel .class );
364361 ManagedChannel replacementChannel = Mockito .mock (ManagedChannel .class );
365362
@@ -402,7 +399,7 @@ public void channelShouldShutdown() throws IOException {
402399 }
403400
404401 @ Test
405- public void channelRefreshShouldSwapChannels () throws IOException {
402+ void channelRefreshShouldSwapChannels () throws IOException {
406403 ManagedChannel underlyingChannel1 = Mockito .mock (ManagedChannel .class );
407404 ManagedChannel underlyingChannel2 = Mockito .mock (ManagedChannel .class );
408405
@@ -442,7 +439,7 @@ public void channelRefreshShouldSwapChannels() throws IOException {
442439 }
443440
444441 @ Test
445- public void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits () throws Exception {
442+ void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits () throws Exception {
446443 ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
447444
448445 List <ManagedChannel > channels = new ArrayList <>();
@@ -521,7 +518,7 @@ public void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits() thro
521518 }
522519
523520 @ Test
524- public void removedIdleChannelsAreShutdown () throws Exception {
521+ void removedIdleChannelsAreShutdown () throws Exception {
525522 ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
526523
527524 List <ManagedChannel > channels = new ArrayList <>();
@@ -561,7 +558,7 @@ public void removedIdleChannelsAreShutdown() throws Exception {
561558 }
562559
563560 @ Test
564- public void removedActiveChannelsAreShutdown () throws Exception {
561+ void removedActiveChannelsAreShutdown () throws Exception {
565562 ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
566563
567564 List <ManagedChannel > channels = new ArrayList <>();
@@ -622,7 +619,7 @@ public void removedActiveChannelsAreShutdown() throws Exception {
622619 }
623620
624621 @ Test
625- public void testReleasingClientCallCancelEarly () throws IOException {
622+ void testReleasingClientCallCancelEarly () throws IOException {
626623 ClientCall mockClientCall = Mockito .mock (ClientCall .class );
627624 Mockito .doAnswer (invocation -> null ).when (mockClientCall ).cancel (Mockito .any (), Mockito .any ());
628625 ManagedChannel fakeChannel = Mockito .mock (ManagedChannel .class );
@@ -650,7 +647,7 @@ public void testReleasingClientCallCancelEarly() throws IOException {
650647 Color request = Color .newBuilder ().setRed (0.5f ).build ();
651648
652649 IllegalStateException e =
653- Assert .assertThrows (
650+ Assertions .assertThrows (
654651 IllegalStateException .class ,
655652 () ->
656653 streamingCallable .call (
@@ -675,7 +672,7 @@ public void onComplete() {}
675672 }
676673
677674 @ Test
678- public void testDoubleRelease () throws Exception {
675+ void testDoubleRelease () throws Exception {
679676 FakeLogHandler logHandler = new FakeLogHandler ();
680677 ChannelPool .LOG .addHandler (logHandler );
681678
0 commit comments