FrankChen021 commented on code in PR #20058:
URL: https://github.com/apache/druid/pull/20058#discussion_r3805094600
##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
@Test
public void testMaxPercentageThreadsRequired()
{
- expectedException.expect(NullPointerException.class);
- expectedException.expectMessage("maxLowPercent must be set");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+ Throwable exception = Assertions.assertThrows(NullPointerException.class,
() -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+ });
+ Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must
be set"));
}
@Test
public void testMaxLowPercentMustBeGreaterThanZero()
{
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("maxLowPercent must be in the range 1 to
100");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+ Throwable exception =
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
Review Comment:
Fixed in 1d66e0e97f. This was introduced by the JUnit 4→5 migration: the
constructor still executes inside assertThrows, and the expected exception and
message assertions are unchanged; the unread local assignment was removed.
##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
@Test
public void testMaxPercentageThreadsRequired()
{
- expectedException.expect(NullPointerException.class);
- expectedException.expectMessage("maxLowPercent must be set");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+ Throwable exception = Assertions.assertThrows(NullPointerException.class,
() -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+ });
+ Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must
be set"));
}
@Test
public void testMaxLowPercentMustBeGreaterThanZero()
{
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("maxLowPercent must be in the range 1 to
100");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+ Throwable exception =
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+ });
+ Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must
be in the range 1 to 100"));
}
@Test
public void testMaxLowPercentMustBeLessThanOrEqual100()
{
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("maxLowPercent must be in the range 1 to
100");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);
+ Throwable exception =
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);
+ });
+ Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must
be in the range 1 to 100"));
}
@Test
public void testMaxLowPercentZero()
{
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("maxLowPercent must be in the range 1 to
100");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(0);
+ Throwable exception =
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(0);
Review Comment:
Fixed in 1d66e0e97f. This was introduced by the JUnit 4→5 migration: the
constructor still executes inside assertThrows, and the expected exception and
message assertions are unchanged; the unread local assignment was removed.
##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
@Test
public void testMaxPercentageThreadsRequired()
{
- expectedException.expect(NullPointerException.class);
- expectedException.expectMessage("maxLowPercent must be set");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+ Throwable exception = Assertions.assertThrows(NullPointerException.class,
() -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
Review Comment:
Fixed in 1d66e0e97f. This was introduced by the JUnit 4→5 migration: the
constructor still executes inside assertThrows, and the expected exception and
message assertions are unchanged; the unread local assignment was removed.
##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
@Test
public void testMaxPercentageThreadsRequired()
{
- expectedException.expect(NullPointerException.class);
- expectedException.expectMessage("maxLowPercent must be set");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+ Throwable exception = Assertions.assertThrows(NullPointerException.class,
() -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+ });
+ Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must
be set"));
}
@Test
public void testMaxLowPercentMustBeGreaterThanZero()
{
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("maxLowPercent must be in the range 1 to
100");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+ Throwable exception =
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+ });
+ Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must
be in the range 1 to 100"));
}
@Test
public void testMaxLowPercentMustBeLessThanOrEqual100()
{
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("maxLowPercent must be in the range 1 to
100");
- QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);
+ Throwable exception =
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);
Review Comment:
Fixed in 1d66e0e97f. This was introduced by the JUnit 4→5 migration: the
constructor still executes inside assertThrows, and the expected exception and
message assertions are unchanged; the unread local assignment was removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]