Adds a test to cover missing access to #context

This commit is contained in:
Lukasz Lenart
2018-03-21 09:08:31 +01:00
parent a37eafa710
commit 5f2ed58451
@@ -803,6 +803,24 @@ public class OgnlUtilTest extends XWorkTestCase {
assertEquals(expected.getMessage(), "It isn't a simple method which can be called!");
}
public void testAccessContext() throws Exception {
Map<String, Object> context = ognlUtil.createDefaultContext(null);
Foo foo = new Foo();
Object result = ognlUtil.getValue("#context", context, null);
Object root = ognlUtil.getValue("#root", context, foo);
Object that = ognlUtil.getValue("#this", context, foo);
assertNotSame(context, result);
assertNull(result);
assertNotNull(root);
assertSame(root.getClass(), Foo.class);
assertNotNull(that);
assertSame(that.getClass(), Foo.class);
assertSame(that, root);
}
public static class Email {
String address;