69
69
import java .util .concurrent .ScheduledFuture ;
70
70
import java .util .concurrent .TimeUnit ;
71
71
import 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 ;
77
75
import org .mockito .ArgumentCaptor ;
78
76
import org .mockito .Mockito ;
79
77
import org .mockito .stubbing .Answer ;
80
78
81
- @ RunWith (JUnit4 .class )
82
- public class ChannelPoolTest {
79
+ class ChannelPoolTest {
83
80
private static final int DEFAULT_AWAIT_TERMINATION_SEC = 10 ;
84
81
private ChannelPool pool ;
85
82
86
- @ After
87
- public void cleanup () throws InterruptedException {
83
+ @ AfterEach
84
+ void cleanup () throws InterruptedException {
88
85
Preconditions .checkNotNull (pool , "Channel pool was never created" );
89
86
pool .shutdown ();
90
87
pool .awaitTermination (DEFAULT_AWAIT_TERMINATION_SEC , TimeUnit .SECONDS );
91
88
}
92
89
93
90
@ Test
94
- public void testAuthority () throws IOException {
91
+ void testAuthority () throws IOException {
95
92
ManagedChannel sub1 = Mockito .mock (ManagedChannel .class );
96
93
ManagedChannel sub2 = Mockito .mock (ManagedChannel .class );
97
94
@@ -105,7 +102,7 @@ public void testAuthority() throws IOException {
105
102
}
106
103
107
104
@ Test
108
- public void testRoundRobin () throws IOException {
105
+ void testRoundRobin () throws IOException {
109
106
ManagedChannel sub1 = Mockito .mock (ManagedChannel .class );
110
107
ManagedChannel sub2 = Mockito .mock (ManagedChannel .class );
111
108
@@ -144,7 +141,7 @@ private void verifyTargetChannel(
144
141
}
145
142
146
143
@ Test
147
- public void ensureEvenDistribution () throws InterruptedException , IOException {
144
+ void ensureEvenDistribution () throws InterruptedException , IOException {
148
145
int numChannels = 10 ;
149
146
final ManagedChannel [] channels = new ManagedChannel [numChannels ];
150
147
final AtomicInteger [] counts = new AtomicInteger [numChannels ];
@@ -197,7 +194,7 @@ public void ensureEvenDistribution() throws InterruptedException, IOException {
197
194
198
195
// Test channelPrimer is called same number of times as poolSize if executorService is set to null
199
196
@ Test
200
- public void channelPrimerShouldCallPoolConstruction () throws IOException {
197
+ void channelPrimerShouldCallPoolConstruction () throws IOException {
201
198
ChannelPrimer mockChannelPrimer = Mockito .mock (ChannelPrimer .class );
202
199
ManagedChannel channel1 = Mockito .mock (ManagedChannel .class );
203
200
ManagedChannel channel2 = Mockito .mock (ManagedChannel .class );
@@ -215,7 +212,7 @@ public void channelPrimerShouldCallPoolConstruction() throws IOException {
215
212
216
213
// Test channelPrimer is called periodically, if there's an executorService
217
214
@ Test
218
- public void channelPrimerIsCalledPeriodically () throws IOException {
215
+ void channelPrimerIsCalledPeriodically () throws IOException {
219
216
ChannelPrimer mockChannelPrimer = Mockito .mock (ChannelPrimer .class );
220
217
ManagedChannel channel1 = Mockito .mock (ManagedChannel .class );
221
218
ManagedChannel channel2 = Mockito .mock (ManagedChannel .class );
@@ -266,7 +263,7 @@ public void channelPrimerIsCalledPeriodically() throws IOException {
266
263
// ----
267
264
// call should be allowed to complete and the channel should not be shutdown
268
265
@ Test
269
- public void callShouldCompleteAfterCreation () throws IOException {
266
+ void callShouldCompleteAfterCreation () throws IOException {
270
267
ManagedChannel underlyingChannel = Mockito .mock (ManagedChannel .class );
271
268
ManagedChannel replacementChannel = Mockito .mock (ManagedChannel .class );
272
269
FakeChannelFactory channelFactory =
@@ -314,7 +311,7 @@ public void callShouldCompleteAfterCreation() throws IOException {
314
311
315
312
// call should be allowed to complete and the channel should not be shutdown
316
313
@ Test
317
- public void callShouldCompleteAfterStarted () throws IOException {
314
+ void callShouldCompleteAfterStarted () throws IOException {
318
315
final ManagedChannel underlyingChannel = Mockito .mock (ManagedChannel .class );
319
316
ManagedChannel replacementChannel = Mockito .mock (ManagedChannel .class );
320
317
@@ -359,7 +356,7 @@ public void callShouldCompleteAfterStarted() throws IOException {
359
356
360
357
// Channel should be shutdown after a refresh all the calls have completed
361
358
@ Test
362
- public void channelShouldShutdown () throws IOException {
359
+ void channelShouldShutdown () throws IOException {
363
360
ManagedChannel underlyingChannel = Mockito .mock (ManagedChannel .class );
364
361
ManagedChannel replacementChannel = Mockito .mock (ManagedChannel .class );
365
362
@@ -402,7 +399,7 @@ public void channelShouldShutdown() throws IOException {
402
399
}
403
400
404
401
@ Test
405
- public void channelRefreshShouldSwapChannels () throws IOException {
402
+ void channelRefreshShouldSwapChannels () throws IOException {
406
403
ManagedChannel underlyingChannel1 = Mockito .mock (ManagedChannel .class );
407
404
ManagedChannel underlyingChannel2 = Mockito .mock (ManagedChannel .class );
408
405
@@ -442,7 +439,7 @@ public void channelRefreshShouldSwapChannels() throws IOException {
442
439
}
443
440
444
441
@ Test
445
- public void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits () throws Exception {
442
+ void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits () throws Exception {
446
443
ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
447
444
448
445
List <ManagedChannel > channels = new ArrayList <>();
@@ -521,7 +518,7 @@ public void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits() thro
521
518
}
522
519
523
520
@ Test
524
- public void removedIdleChannelsAreShutdown () throws Exception {
521
+ void removedIdleChannelsAreShutdown () throws Exception {
525
522
ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
526
523
527
524
List <ManagedChannel > channels = new ArrayList <>();
@@ -561,7 +558,7 @@ public void removedIdleChannelsAreShutdown() throws Exception {
561
558
}
562
559
563
560
@ Test
564
- public void removedActiveChannelsAreShutdown () throws Exception {
561
+ void removedActiveChannelsAreShutdown () throws Exception {
565
562
ScheduledExecutorService executor = Mockito .mock (ScheduledExecutorService .class );
566
563
567
564
List <ManagedChannel > channels = new ArrayList <>();
@@ -622,7 +619,7 @@ public void removedActiveChannelsAreShutdown() throws Exception {
622
619
}
623
620
624
621
@ Test
625
- public void testReleasingClientCallCancelEarly () throws IOException {
622
+ void testReleasingClientCallCancelEarly () throws IOException {
626
623
ClientCall mockClientCall = Mockito .mock (ClientCall .class );
627
624
Mockito .doAnswer (invocation -> null ).when (mockClientCall ).cancel (Mockito .any (), Mockito .any ());
628
625
ManagedChannel fakeChannel = Mockito .mock (ManagedChannel .class );
@@ -650,7 +647,7 @@ public void testReleasingClientCallCancelEarly() throws IOException {
650
647
Color request = Color .newBuilder ().setRed (0.5f ).build ();
651
648
652
649
IllegalStateException e =
653
- Assert .assertThrows (
650
+ Assertions .assertThrows (
654
651
IllegalStateException .class ,
655
652
() ->
656
653
streamingCallable .call (
@@ -675,7 +672,7 @@ public void onComplete() {}
675
672
}
676
673
677
674
@ Test
678
- public void testDoubleRelease () throws Exception {
675
+ void testDoubleRelease () throws Exception {
679
676
FakeLogHandler logHandler = new FakeLogHandler ();
680
677
ChannelPool .LOG .addHandler (logHandler );
681
678
0 commit comments