From 5f2ed584517cda8d7fe45b0003b595ebc54c9576 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 21 Mar 2018 09:08:31 +0100 Subject: [PATCH] Adds a test to cover missing access to #context --- .../opensymphony/xwork2/ognl/OgnlUtilTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java index 741a39678..dec0cc0ff 100644 --- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java @@ -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 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;