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;
17:
18: import javax.el.ELException;
19:
20: public class ObjectValueExpressionTest extends TestCase {
21:
22: public void testHashCode() {
23: assertEquals("foo".hashCode(), new ObjectValueExpression("foo",
24: Object.class).hashCode());
25: }
26:
27: public void testEqualsObject() {
28: assertTrue(new ObjectValueExpression("foo", Object.class)
29: .equals(new ObjectValueExpression("foo", Object.class)));
30: assertTrue(new ObjectValueExpression(new String("foo"),
31: Object.class).equals(new ObjectValueExpression("foo",
32: Object.class)));
33: assertFalse(new ObjectValueExpression("foo", Object.class)
34: .equals(new ObjectValueExpression("bar", Object.class)));
35: }
36:
37: public void testGetValue() {
38: assertEquals("foo", new ObjectValueExpression("foo",
39: Object.class).getValue(null));
40: }
41:
42: public void testGetExpressionString() {
43: assertNull(new ObjectValueExpression("foo", Object.class)
44: .getExpressionString());
45: }
46:
47: public void testIsLiteralText() {
48: assertFalse(new ObjectValueExpression("foo", Object.class)
49: .isLiteralText());
50: }
51:
52: public void testGetType() {
53: assertNull(new ObjectValueExpression("foo", Object.class)
54: .getType(null));
55: }
56:
57: public void testIsReadOnly() {
58: assertTrue(new ObjectValueExpression("foo", Object.class)
59: .isReadOnly(null));
60: }
61:
62: public void testSetValue() {
63: try {
64: new ObjectValueExpression("foo", Object.class).setValue(
65: null, "bar");
66: fail();
67: } catch (ELException e) {
68: }
69: }
70:
71: public void testSerialize() throws Exception {
72: ObjectValueExpression expression = new ObjectValueExpression(
73: "foo", Object.class);
74: assertEquals(expression, deserialize(serialize(expression)));
75: }
76: }
|