mirror of
https://github.com/apache/struts.git
synced 2026-08-07 07:37:20 +00:00
WW-5363 Fix super#internalGet
This commit is contained in:
+5
-1
@@ -77,7 +77,11 @@ public class StrutsVelocityContext extends VelocityContext {
|
||||
}
|
||||
|
||||
protected List<Function<String, Object>> contextGetterList() {
|
||||
return Arrays.asList(super::internalGet, this::chainedContextGet, this::stackGet, this::stackContextGet);
|
||||
return Arrays.asList(this::superGet, this::chainedContextGet, this::stackGet, this::stackContextGet);
|
||||
}
|
||||
|
||||
protected Object superGet(String key) {
|
||||
return super.internalGet(key);
|
||||
}
|
||||
|
||||
protected Object stackGet(String key) {
|
||||
|
||||
+14
-5
@@ -74,15 +74,24 @@ public class StrutsVelocityContextTest {
|
||||
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSuperValue() {
|
||||
strutsVelocityContext.put("foo", "bar");
|
||||
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getValuePrecedence() {
|
||||
when(chainedContext.internalGet("foo")).thenReturn("bar");
|
||||
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
|
||||
stackContext.put("foo", "quux");
|
||||
assertEquals("quux", strutsVelocityContext.internalGet("foo"));
|
||||
|
||||
when(stack.findValue("foo")).thenReturn("baz");
|
||||
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
|
||||
when(stack.findValue("foo")).thenReturn("qux");
|
||||
assertEquals("qux", strutsVelocityContext.internalGet("foo"));
|
||||
|
||||
stackContext.put("foo", "qux");
|
||||
when(chainedContext.internalGet("foo")).thenReturn("baz");
|
||||
assertEquals("baz", strutsVelocityContext.internalGet("foo"));
|
||||
|
||||
strutsVelocityContext.put("foo", "bar");
|
||||
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user