Use try/catch idiom instead of @Test(expected = ...) (#9037)

This commit is contained in:
Kurt Alfred Kluever 2022-03-31 22:49:12 -04:00 committed by GitHub
parent 7572afb32b
commit f04a49a7bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
@ -575,10 +576,14 @@ public class LeastRequestLoadBalancerTest {
assertThat(pickers.hasNext()).isFalse();
}
@Test(expected = IllegalArgumentException.class)
@Test
public void readyPicker_emptyList() {
// ready picker list must be non-empty
new ReadyPicker(Collections.<Subchannel>emptyList(), 2, mockRandom);
try {
// ready picker list must be non-empty
new ReadyPicker(Collections.<Subchannel>emptyList(), 2, mockRandom);
fail();
} catch (IllegalArgumentException expected) {
}
}
@Test