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 79eac56f58c538180cce5d48cdf840d93823fea3
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 1 14:55:30 2024 -0400

    Use assertThrows()
---
 .../java/org/apache/commons/jexl3/ForEachTest.java | 24 ++++++++--------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/ForEachTest.java 
b/src/test/java/org/apache/commons/jexl3/ForEachTest.java
index b4a3adcf..a8b65357 100644
--- a/src/test/java/org/apache/commons/jexl3/ForEachTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ForEachTest.java
@@ -19,9 +19,8 @@ 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;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -44,13 +43,10 @@ public class ForEachTest extends JexlTestCase {
 
     @Test
     public void testForEachBreakBroken() throws Exception {
-        try {
-            final JexlScript e = JEXL.createScript("if (true) { break; }");
-            fail("break is out of loop!");
-        } catch (final JexlException.Parsing xparse) {
-            final String str = xparse.detailedMessage();
-            assertTrue(str.contains("break"));
-        }
+        final JexlException.Parsing xparse = 
assertThrows(JexlException.Parsing.class, () -> JEXL.createScript("if (true) { 
break; }"),
+                "break is out of loop!");
+        assertTrue(xparse.detailedMessage().contains("break"));
+
     }
 
     @Test
@@ -66,13 +62,9 @@ public class ForEachTest extends JexlTestCase {
 
     @Test
     public void testForEachContinueBroken() throws Exception {
-        try {
-            final JexlScript e = JEXL.createScript("var rr = 0; continue;");
-            fail("continue is out of loop!");
-        } catch (final JexlException.Parsing xparse) {
-            final String str = xparse.detailedMessage();
-            assertTrue(str.contains("continue"));
-        }
+        final JexlException.Parsing xparse = 
assertThrows(JexlException.Parsing.class, () -> JEXL.createScript("var rr = 0; 
continue;"),
+                "continue is out of loop!");
+        assertTrue(xparse.detailedMessage().contains("continue"));
     }
 
     @Test

Reply via email to