1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.commons.ognl.test;
24
25 import junit.framework.TestCase;
26 import org.apache.commons.ognl.Node;
27 import org.apache.commons.ognl.Ognl;
28 import org.apache.commons.ognl.OgnlContext;
29 import org.apache.commons.ognl.test.objects.BaseBean;
30 import org.apache.commons.ognl.test.objects.FirstBean;
31 import org.apache.commons.ognl.test.objects.Root;
32 import org.apache.commons.ognl.test.objects.SecondBean;
33
34
35
36
37 public class InheritedMethodsTest
38 extends TestCase
39 {
40
41 private static Root ROOT = new Root();
42
43 public void test_Base_Inheritance()
44 throws Exception
45 {
46 OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
47 String expression = "map.bean.name";
48 BaseBean first = new FirstBean();
49 BaseBean second = new SecondBean();
50
51 ROOT.getMap().put( "bean", first );
52
53 Node node = Ognl.compileExpression( context, ROOT, expression );
54
55 assertEquals( first.getName(), node.getAccessor().get( context, ROOT ) );
56
57 ROOT.getMap().put( "bean", second );
58
59 assertEquals( second.getName(), node.getAccessor().get( context, ROOT ) );
60 }
61 }