slfan1989 commented on code in PR #7369:
URL: https://github.com/apache/hadoop/pull/7369#discussion_r1948132038


##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbRemoteCallHelper.java:
##########
@@ -434,10 +431,6 @@ class MatchesPattern extends TypeSafeMatcher<String> {
       }
     }
 
-    expectedEx.expectMessage(new MatchesPattern(

Review Comment:
   In JUnit 5, `org.junit.rules.ExpectedException` has been deprecated, and it 
is recommended to use assertThrows to validate exception throwing, as shown 
below:
   
   ```
   import static org.junit.jupiter.api.Assertions.assertThrows;
   
   @Test
   public void shouldThrowException() {
     assertThrows(IllegalArgumentException.class, () -> {
         someMethodThatThrows();
     });
   }
   ```
   
   The change is primarily in syntax, where assertThrows captures exceptions 
via lambda expressions, replacing the ExpectedException rule from JUnit 4. 
However, it does not have any fundamental impact on the logic of unit tests.
   
   I can further improve this unit test to also validate the exception message 
using a regular expression.



-- 
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]

Reply via email to