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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git

commit 08449e5a081571120e02561f017a589a867d3d5e
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 1 11:37:28 2024 -0400

    Use assertThrows()
---
 .../org/apache/commons/jexl3/junit/AsserterTest.java   | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java 
b/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java
index b1b8d276..47c79f6b 100644
--- a/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java
+++ b/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.commons.jexl3.junit;
 
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import org.apache.commons.jexl3.Foo;
 import org.apache.commons.jexl3.JexlTestCase;
@@ -37,13 +37,7 @@ public class AsserterTest extends JexlTestCase {
         final Asserter asserter = new Asserter(JEXL);
         asserter.setVariable("this", new Foo());
         asserter.assertExpression("this.repeat('abc')", "Repeat : abc");
-        try {
-            asserter.assertExpression("this.count", "Wrong Value");
-            fail("This method should have thrown an assertion exception");
-        }
-        catch (final AssertionError e) {
-            // it worked!
-        }
+        assertThrows(AssertionError.class, () -> 
asserter.assertExpression("this.count", "Wrong Value"));
     }
 
     @Test
@@ -59,12 +53,6 @@ public class AsserterTest extends JexlTestCase {
         asserter.assertExpression("foo.getCount()", Integer.valueOf(5));
         asserter.assertExpression("foo.count", Integer.valueOf(5));
 
-        try {
-            asserter.assertExpression("bar.count", Integer.valueOf(5));
-            fail("This method should have thrown an assertion exception");
-        }
-        catch (final AssertionError e) {
-            // it worked!
-        }
+        assertThrows(AssertionError.class, () -> 
asserter.assertExpression("bar.count", Integer.valueOf(5)));
     }
 }

Reply via email to