Skip to content

Commit 9920d5e

Browse files
committed
4
1 parent 2c37f24 commit 9920d5e

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

xds/src/test/java/io/grpc/xds/WeightedRandomPickerTest.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.grpc.xds;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20+
import static org.junit.Assert.assertThrows;
2021
import static org.mockito.Mockito.mock;
2122

2223
import io.grpc.LoadBalancer.PickResult;
@@ -30,7 +31,6 @@
3031
import java.util.List;
3132
import org.junit.Rule;
3233
import org.junit.Test;
33-
import org.junit.rules.ExpectedException;
3434
import org.junit.runner.RunWith;
3535
import org.junit.runners.JUnit4;
3636
import org.mockito.Mock;
@@ -42,9 +42,6 @@
4242
*/
4343
@RunWith(JUnit4.class)
4444
public class WeightedRandomPickerTest {
45-
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
46-
@Rule
47-
public final ExpectedException thrown = ExpectedException.none();
4845

4946
@Rule
5047
public final MockitoRule mockitoRule = MockitoJUnit.rule();
@@ -128,20 +125,18 @@ public long nextLong(long bound) {
128125
public void emptyList() {
129126
List<WeightedChildPicker> emptyList = new ArrayList<>();
130127

131-
thrown.expect(IllegalArgumentException.class);
132-
new WeightedRandomPicker(emptyList);
128+
assertThrows(IllegalArgumentException.class, () -> new WeightedRandomPicker(emptyList));
133129
}
134130

135131
@Test
136132
public void negativeWeight() {
137-
thrown.expect(IllegalArgumentException.class);
138-
new WeightedChildPicker(-1, childPicker0);
133+
assertThrows(IllegalArgumentException.class, () -> new WeightedChildPicker(-1, childPicker0));
139134
}
140135

141136
@Test
142137
public void overWeightSingle() {
143-
thrown.expect(IllegalArgumentException.class);
144-
new WeightedChildPicker(Integer.MAX_VALUE * 3L, childPicker0);
138+
assertThrows(IllegalArgumentException.class,
139+
() -> new WeightedChildPicker(Integer.MAX_VALUE * 3L, childPicker0));
145140
}
146141

147142
@Test
@@ -152,8 +147,8 @@ public void overWeightAggregate() {
152147
new WeightedChildPicker(Integer.MAX_VALUE, childPicker1),
153148
new WeightedChildPicker(10, childPicker2));
154149

155-
thrown.expect(IllegalArgumentException.class);
156-
new WeightedRandomPicker(weightedChildPickers, fakeRandom);
150+
assertThrows(IllegalArgumentException.class,
151+
() -> new WeightedRandomPicker(weightedChildPickers, fakeRandom));
157152
}
158153

159154
@Test

0 commit comments

Comments
 (0)