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 c810d3fd5578538860e195ee6c86875e335800eb Author: Gary Gregory <[email protected]> AuthorDate: Sat Jun 1 14:01:23 2024 -0400 Use assertThrows() --- src/test/java/org/apache/commons/jexl3/AssignTest.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/AssignTest.java b/src/test/java/org/apache/commons/jexl3/AssignTest.java index 409bab67..915d15d3 100644 --- a/src/test/java/org/apache/commons/jexl3/AssignTest.java +++ b/src/test/java/org/apache/commons/jexl3/AssignTest.java @@ -18,7 +18,7 @@ package org.apache.commons.jexl3; 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; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -80,17 +80,8 @@ public class AssignTest extends JexlTestCase { final JexlContext jc = new MapContext(); final Froboz froboz = new Froboz(-169); jc.set("froboz", froboz); - Object o = null; - try { - o = assign.evaluate(jc); - } - catch (final RuntimeException xrt) { - final String str = xrt.toString(); - assertTrue(str.contains("nosuchbean")); - } - finally { - assertNull(o); - } + RuntimeException xrt = assertThrows(RuntimeException.class, () -> assign.evaluate(jc)); + assertTrue(xrt.toString().contains("nosuchbean")); } /**
