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:28 UTC
(commons-jexl) 01/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 06b788a6554e7598dcc8e45a9f7fa3a0bc10f530
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 1 15:24:26 2024 -0400
Use assertThrows()
---
src/test/java/org/apache/commons/jexl3/Issues300Test.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
index 22c79bf8..801c934c 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
@@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
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;
@@ -414,21 +415,19 @@ public class Issues300Test {
@Test
public void test309a() {
+ // @formatter:off
final String src = "<html lang=\"en\">\n"
+ " <body>\n"
+ " <h1>Hello World!</h1>\n"
+ "$$ var i = 12++;\n"
+ " </body>\n"
+ "</html>";
+ // @formatter:on
final JexlEngine jexl = new JexlBuilder().safe(true).create();
final JxltEngine jxlt = jexl.createJxltEngine();
final JexlInfo info = new JexlInfo("template", 1, 1);
- try {
- final JxltEngine.Template tmplt = jxlt.createTemplate(info, src);
- fail("shoud have thrown exception");
- } catch (final JexlException.Parsing xerror) {
- assertEquals(4, xerror.getInfo().getLine());
- }
+ final JexlException.Parsing xerror = assertThrows(JexlException.Parsing.class, () -> jxlt.createTemplate(info, src));
+ assertEquals(4, xerror.getInfo().getLine());
}
@Test