This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git


The following commit(s) were added to refs/heads/master by this push:
     new 3666453  Let expected-exception tests fail again
3666453 is described below

commit 36664539076bdaf7c000b464ff5b4ec675894692
Author: Sharang Gupta <[email protected]>
AuthorDate: Wed Oct 28 23:26:54 2026 +0000

    Let expected-exception tests fail again
    
    testIllegalIndexedType and testIllegalMappedType had no fail() after
    the call, and since the JUnit 5 migration testInappropriateEncoding
    catches the AssertionFailedError thrown by its own fail(), so all
    three passed even when the expected exception never came.
---
 .../maven/shared/utils/XmlStreamReaderTest.java       | 12 ++++--------
 .../introspection/ReflectionValueExtractorTest.java   | 19 +++++++++----------
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java 
b/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
index b6a2c61..4e16b37 100644
--- a/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
 import org.opentest4j.AssertionFailedError;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**
  *
@@ -164,13 +164,9 @@ public class XmlStreamReaderTest {
     }
 
     @Test
-    public void testInappropriateEncoding() throws IOException {
-        try {
-            checkXmlStreamReader(TEXT_UNICODE, "ISO-8859-2");
-            fail("Check should have failed, since some characters are not 
available in the specified encoding");
-        } catch (AssertionFailedError cf) {
-            // expected failure, since the encoding does not contain some 
characters
-        }
+    public void testInappropriateEncoding() {
+        // expected failure, since the encoding does not contain some 
characters
+        assertThrows(AssertionFailedError.class, () -> 
checkXmlStreamReader(TEXT_UNICODE, "ISO-8859-2"));
     }
 
     @Test
diff --git 
a/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java
 
b/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java
index f3305ed..377ebe0 100644
--- 
a/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java
+++ 
b/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**
  * @author <a href="mailto:[email protected]";>Jason van Zyl</a>
@@ -224,20 +225,18 @@ public class ReflectionValueExtractorTest {
 
     @Test
     public void testIllegalIndexedType() {
-        try {
-            ReflectionValueExtractor.evaluate("h.value[1]", new 
ValueHolder("string"));
-        } catch (IntrospectionException e) {
-            assertNotNull(e.getMessage());
-        }
+        IntrospectionException e = assertThrows(
+                IntrospectionException.class,
+                () -> ReflectionValueExtractor.evaluate("h.value[1]", new 
ValueHolder("string")));
+        assertNotNull(e.getMessage());
     }
 
     @Test
     public void testIllegalMappedType() {
-        try {
-            ReflectionValueExtractor.evaluate("h.value(key)", new 
ValueHolder("string"));
-        } catch (IntrospectionException e) {
-            assertNotNull(e.getMessage());
-        }
+        IntrospectionException e = assertThrows(
+                IntrospectionException.class,
+                () -> ReflectionValueExtractor.evaluate("h.value(key)", new 
ValueHolder("string")));
+        assertNotNull(e.getMessage());
     }
 
     @Test

Reply via email to