01: /*
02: * Copyright 2006, 2007 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.el.tree.impl.ast;
17:
18: import javax.el.ELException;
19:
20: import de.odysseus.el.TestCase;
21:
22: public class AstTextTest extends TestCase {
23: AstText parseNode(String expression) {
24: return (AstText) parse(expression).getRoot();
25: }
26:
27: public void testEval() {
28: assertEquals("foo", parseNode("foo").eval(null, null));
29: }
30:
31: public void testAppendStructure() {
32: StringBuilder s = new StringBuilder();
33: parseNode("foo").appendStructure(s, null);
34: assertEquals("foo", s.toString());
35: }
36:
37: public void testIsLiteralText() {
38: assertTrue(parseNode("foo").isLiteralText());
39: }
40:
41: public void testIsLeftValue() {
42: assertFalse(parseNode("foo").isLeftValue());
43: }
44:
45: public void testGetType() {
46: assertNull(parseNode("foo").getType(null, null));
47: }
48:
49: public void testIsReadOnly() {
50: assertTrue(parseNode("foo").isReadOnly(null, null));
51: }
52:
53: public void testSetValue() {
54: try {
55: parseNode("foo").setValue(null, null, null);
56: fail();
57: } catch (ELException e) {
58: }
59: }
60:
61: public void testGetValue() {
62: assertEquals("1", parseNode("1").getValue(null, null, null));
63: assertEquals(1l, parseNode("1")
64: .getValue(null, null, Long.class));
65: }
66:
67: public void testInvoke() {
68: assertEquals("1", parseNode("1").invoke(null, null, null, null,
69: null));
70: assertEquals(1l, parseNode("1").invoke(null, null, Long.class,
71: null, null));
72: }
73:
74: public void testGetMethodInfo() {
75: assertNull(parseNode("foo").getMethodInfo(null, null, null,
76: null));
77: }
78: }
|