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 06e3c80aa2047bbc298c08ba51eea1d9924e48db
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 1 13:54:55 2024 -0400

    Use assertThrows()
---
 .../java/org/apache/commons/jexl3/ArithmeticTest.java    | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java 
b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
index 4005a8e9..c24786df 100644
--- a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
@@ -1272,16 +1272,15 @@ public class ArithmeticTest extends JexlTestCase {
         };
         final JexlEngine jexl = new JexlBuilder().create();
         final JexlContext jc = new EmptyTestContext();
-        JexlExpression expression;
 
         for (int e = 0; e < EXPRESSIONS.length; e += 2) {
             final String stext = (String) EXPRESSIONS[e];
             final Object expected = EXPRESSIONS[e + 1];
-            expression = jexl.createExpression(stext);
+            final JexlExpression expression = jexl.createExpression(stext);
             try {
                 final Object result = expression.evaluate(jc);
                 assertEquals(expected, result, () -> "failed on " + stext);
-            } catch(final JexlException jexlException) {
+            } catch (final JexlException jexlException) {
                 final Throwable cause = jexlException.getCause();
                 if (cause == null || !cause.getClass().equals(expected)) {
                     fail(stext);
@@ -1483,6 +1482,7 @@ public class ArithmeticTest extends JexlTestCase {
 
     @Test
     public void testFailAllOperators() {
+        // @formatter:off
         final String[] scripts = {
             "(x, y)->{ x < y }",
             "(x, y)->{ x <= y }",
@@ -1520,16 +1520,12 @@ public class ArithmeticTest extends JexlTestCase {
             "(x, ignore)->{ x-- }",
             "(x, ignore)->{ x++ }"
         };
+        // @formatter:on
         final JexlEngine jexl = new JexlBuilder().cache(64).arithmetic(new 
ArithmeticFail(true)).create();
         final JexlContext jc = new EmptyTestContext();
-        for(final String src : scripts) {
+        for (final String src : scripts) {
             final JexlScript script = jexl.createScript(src);
-            try {
-                final Object result = script.execute(jc, new Var(42), new 
Var(43));
-                fail(src);
-            } catch(final JexlException xjexl) {
-                assertNotNull(jexl);
-            }
+            assertThrows(JexlException.class, () -> script.execute(jc, new 
Var(42), new Var(43)));
         }
     }
 

Reply via email to