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 063106874e572b865b5513e21ebcdbb5989e1e38 Author: Gary Gregory <[email protected]> AuthorDate: Sat Jun 1 14:40:47 2024 -0400 Use assertThrows() --- .../java/org/apache/commons/jexl3/ExceptionTest.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/ExceptionTest.java b/src/test/java/org/apache/commons/jexl3/ExceptionTest.java index 14cc15c1..ced3f05f 100644 --- a/src/test/java/org/apache/commons/jexl3/ExceptionTest.java +++ b/src/test/java/org/apache/commons/jexl3/ExceptionTest.java @@ -153,24 +153,16 @@ public class ExceptionTest extends JexlTestCase { // make unknown vars throw options.setStrict(true); // empty cotext - try { - /* Object o = */ e.evaluate(ctxt); - fail("c not declared as variable should throw"); - } catch (final JexlException.Variable xjexl) { - final String msg = xjexl.getMessage(); - assertTrue(msg.indexOf("variable 'c.e'") > 0); - } + JexlException xjexl = assertThrows(JexlException.class, () -> e.evaluate(ctxt), "c not declared as variable should throw"); + String msg = xjexl.getMessage(); + assertTrue(msg.indexOf("variable 'c.e'") > 0); // disallow null operands options.setStrictArithmetic(true); ctxt.set("c.e", null); - try { - /* Object o = */ e.evaluate(ctxt); - fail("c.e as null operand should throw"); - } catch (final JexlException xjexl) { - final String msg = xjexl.getMessage(); - assertTrue(msg.indexOf("variable 'c.e'") > 0); - } + xjexl = assertThrows(JexlException.class, () -> e.evaluate(ctxt)); + msg = xjexl.getMessage(); + assertTrue(msg.indexOf("variable 'c.e'") > 0); } // null local vars and strict arithmetic effects
