You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/06/01 19:43:34 UTC

(commons-jexl) 07/10: Use assertThrows()

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 faedf5a1bc77025ec00105472e92b9f8e1301708
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 1 15:37:09 2024 -0400

    Use assertThrows()
---
 src/test/java/org/apache/commons/jexl3/Issues300Test.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
index 59f59706..ebb1b692 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
@@ -700,8 +700,9 @@ public class Issues300Test {
     @Test
     public void test330() {
         final JexlEngine jexl = new JexlBuilder().create();
-        // Extended form of: 'literal' + VARIABLE   'literal'
+        // Extended form of: 'literal' + VARIABLE 'literal'
         // missing + operator here ---------------^
+        // @formatter:off
         final String longExpression = ""
                 + //
                 "'THIS IS A VERY VERY VERY VERY VERY VERY VERY "
@@ -709,12 +710,10 @@ public class Issues300Test {
                 "VERY VERY LONG STRING CONCATENATION ' + VARIABLE ' <--- "
                 + //
                 "error: missing + between VARIABLE and literal'";
-        try {
-            jexl.createExpression(longExpression);
-            fail("parsing malformed expression did not throw exception");
-        } catch (final JexlException.Parsing exception) {
-            assertTrue(exception.getMessage().contains("VARIABLE"));
-        }
+        // @formatter:on
+        final JexlException.Parsing xparse = assertThrows(JexlException.Parsing.class, () -> jexl.createExpression(longExpression),
+                "parsing malformed expression did not throw exception");
+        assertTrue(xparse.getMessage().contains("VARIABLE"));
     }
 
     @Test