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:11:02 UTC
(commons-jexl) 02/05: 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 7240d600bb4e4d2d406eb3d94e82c235be50588e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 1 14:59:57 2024 -0400
Use assertThrows()
---
src/test/java/org/apache/commons/jexl3/Issues100Test.java | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/test/java/org/apache/commons/jexl3/Issues100Test.java b/src/test/java/org/apache/commons/jexl3/Issues100Test.java
index bf7bbe91..71aebded 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues100Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues100Test.java
@@ -20,6 +20,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;
@@ -258,16 +259,12 @@ public static class Foo125 {
assertNotNull(value);
options.setMathContext(MathContext.UNLIMITED);
options.setMathScale(2);
- try {
- jexl.createExpression("a / b").evaluate(context);
- fail("should fail");
- } catch (final JexlException xjexl) {
- // ok to fail
- }
+ assertThrows(JexlException.class, () -> jexl.createExpression("a / b").evaluate(context));
}
@Test
public void test107() throws Exception {
+ // @formatter:off
final String[] exprs = {
"'Q4'.toLowerCase()", "q4",
"(Q4).toLowerCase()", "q4",
@@ -278,7 +275,7 @@ public static class Foo125 {
"({ 'q' : 'Q4'})['q'].toLowerCase()", "q4",
"(['Q4'])[0].toLowerCase()", "q4"
};
-
+ // @formatter:on
final JexlContext context = new MapContext();
context.set("Q4", "Q4");
final JexlEngine jexl = new Engine();