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 97747173167b864514b91b6770abff9a0b18d461
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Jun 1 16:15:03 2024 -0400

    Use assertThrows()
---
 src/test/java/org/apache/commons/jexl3/Issues400Test.java | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java 
b/src/test/java/org/apache/commons/jexl3/Issues400Test.java
index c4ba37d9..ebb95276 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
@@ -307,12 +308,8 @@ public class Issues400Test {
         options.setLexical(true);
         final JexlEngine jexl = builder.create();
         final JexlScript script = jexl.createScript("var c = 42; var f = y -> 
c += y; f(z)", "z");
-        try {
-            final Number result = (Number) script.execute(null, 12);
-            fail("c should be const");
-        } catch (final JexlException.Variable xvar) {
-            assertEquals("c", xvar.getVariable());
-        }
+        final JexlException.Variable xvar = 
assertThrows(JexlException.Variable.class, () -> script.execute(null, 12), "c 
should be const");
+        assertEquals("c", xvar.getVariable());
     }
 
     @Test

Reply via email to