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 AstCompositeTest extends TestCase {
23: AstComposite parseNode(String expression) {
24: return (AstComposite) parse(expression).getRoot();
25: }
26:
27: public void testEval() {
28: assertEquals("101", parseNode("${1}0${1}").eval(null, null));
29: }
30:
31: public void testAppendStructure() {
32: StringBuilder s = new StringBuilder();
33: parseNode("${1}0${1}").appendStructure(s, null);
34: assertEquals("${1}0${1}", s.toString());
35: }
36:
37: public void testIsLiteralText() {
38: assertFalse(parseNode("${1}0${1}").isLiteralText());
39: }
40:
41: public void testIsLeftValue() {
42: assertFalse(parseNode("${1}0${1}").isLeftValue());
43: }
44:
45: public void testGetType() {
46: assertNull(parseNode("${1}0${1}").getType(null, null));
47: }
48:
49: public void testIsReadOnly() {
50: assertTrue(parseNode("${1}0${1}").isReadOnly(null, null));
51: }
52:
53: public void testSetValue() {
54: try {
55: parseNode("${1}0${1}").setValue(null, null, null);
56: fail();
57: } catch (ELException e) {
58: }
59: }
60:
61: public void testGetValue() {
62: assertEquals("101", parseNode("${1}0${1}").getValue(null, null,
63: null));
64: assertEquals(101l, parseNode("${1}0${1}").getValue(null, null,
65: Long.class));
66: }
67: }
|