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