steveloughran commented on code in PR #7955:
URL: https://github.com/apache/hadoop/pull/7955#discussion_r2376168925
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/TestGenericTestUtils.java:
##########
@@ -35,31 +37,39 @@ public class TestGenericTestUtils extends GenericTestUtils {
@Test
public void testAssertExceptionContainsNullEx() throws Throwable {
+ boolean assertTriggered = false;
try {
assertExceptionContains("", null);
} catch (AssertionError e) {
+ assertTriggered = true;
if (!e.toString().contains(E_NULL_THROWABLE)) {
throw e;
}
}
+ assertTrue(assertTriggered);
}
@Test
public void testAssertExceptionContainsNullString() throws Throwable {
+ boolean assertTriggered = false;
try {
assertExceptionContains("", new BrokenException());
} catch (AssertionError e) {
+ assertTriggered = true;
if (!e.toString().contains(E_NULL_THROWABLE_STRING)) {
throw e;
}
}
+ assertTrue(assertTriggered);
}
@Test
public void testAssertExceptionContainsWrongText() throws Throwable {
+ boolean assertTriggered = false;
try {
assertExceptionContains("Expected", new Exception("(actual)"));
} catch (AssertionError e) {
+ assertTriggered = true;
String s = e.toString();
if (!s.contains(E_UNEXPECTED_EXCEPTION)
Review Comment:
again, use intercept, but here
```
AssertionError e = intercept(AssertionError.class, "", () ->
assertExceptionContains("Expected", new Exception("(actual)")));
// checks from L32 onwards
String s = e.toString();
if (!s.contains(E_UNEXPECTED_EXCEPTION) ...
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/TestGenericTestUtils.java:
##########
@@ -35,31 +37,39 @@ public class TestGenericTestUtils extends GenericTestUtils {
@Test
public void testAssertExceptionContainsNullEx() throws Throwable {
+ boolean assertTriggered = false;
Review Comment:
use LambdaTestUtils.intercept here.
```
intercept(AssertionError.class, E_NULL_THROWABLE, () ->
assertExceptionContains("", null));
```
same below.
--
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]