1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jexl3;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21 import org.junit.Assert;
22 import org.junit.Test;
23
24
25
26
27
28
29
30
31
32 public class ParseFailuresTest extends JexlTestCase {
33
34 static final Log LOGGER = LogFactory.getLog(ParseFailuresTest.class.getName());
35
36
37
38
39 public ParseFailuresTest() {
40 super("ParseFailuresTest");
41 }
42
43 @Test
44 public void testMalformedExpression1() throws Exception {
45
46 final String badExpression = "eq";
47 try {
48 JEXL.createExpression(badExpression);
49 Assert.fail("Parsing \"" + badExpression
50 + "\" should result in a JexlException");
51 } catch (final JexlException pe) {
52
53 LOGGER.debug(pe);
54 }
55 }
56
57 @Test
58 public void testMalformedExpression2() throws Exception {
59
60 final String badExpression = "?";
61 try {
62 JEXL.createExpression(badExpression);
63 Assert.fail("Parsing \"" + badExpression
64 + "\" should result in a JexlException");
65 } catch (final JexlException pe) {
66
67 LOGGER.debug(pe);
68 }
69 }
70
71 @Test
72 public void testMalformedScript1() throws Exception {
73
74 final String badScript = "eq";
75 try {
76 JEXL.createScript(badScript);
77 Assert.fail("Parsing \"" + badScript
78 + "\" should result in a JexlException");
79 } catch (final JexlException pe) {
80
81 LOGGER.debug(pe);
82 }
83 }
84
85 @Test
86 public void testMalformedScript2() throws Exception {
87
88 final String badScript = "?";
89 try {
90 JEXL.createScript(badScript);
91 Assert.fail("Parsing \"" + badScript
92 + "\" should result in a JexlException");
93 } catch (final JexlException pe) {
94
95 LOGGER.debug(pe);
96 }
97 }
98
99 @Test
100 public void testMalformedScript3() throws Exception {
101
102 final String badScript = "foo=1;bar=2;a?b:c:d;";
103 try {
104 JEXL.createScript(badScript);
105 Assert.fail("Parsing \"" + badScript
106 + "\" should result in a JexlException");
107 } catch (final JexlException pe) {
108
109 LOGGER.debug(pe);
110 }
111 }
112
113 }