This is an automated email from the ASF dual-hosted git repository.

kusal pushed a commit to branch WW-5363-velocity-order-2
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 0504e7076c3a94945e168d72e06ef3d15a98a0dc
Author: Kusal Kithul-Godage <g...@kusal.io>
AuthorDate: Wed Nov 15 16:06:24 2023 +1100

    WW-5363 Remove redundant method from VelocityManager
---
 .../struts2/views/velocity/StrutsVelocityContext.java     |  9 +--------
 .../struts2/views/velocity/StrutsVelocityContextTest.java | 15 ---------------
 2 files changed, 1 insertion(+), 23 deletions(-)

diff --git 
a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
 
b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
index 99be98b15..4241f6ead 100644
--- 
a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
+++ 
b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java
@@ -77,7 +77,7 @@ public class StrutsVelocityContext extends VelocityContext {
     }
 
     protected List<Function<String, Object>> contextGetterList() {
-        return Arrays.asList(this::superGet, this::chainedContextGet, 
this::stackGet, this::stackContextGet);
+        return Arrays.asList(this::superGet, this::chainedContextGet, 
this::stackGet);
     }
 
     protected Object superGet(String key) {
@@ -91,13 +91,6 @@ public class StrutsVelocityContext extends VelocityContext {
         return stack.findValue(key);
     }
 
-    protected Object stackContextGet(String key) {
-        if (stack == null) {
-            return null;
-        }
-        return stack.getContext().get(key);
-    }
-
     protected Object chainedContextGet(String key) {
         if (chainedContexts == null) {
             return null;
diff --git 
a/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java
 
b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java
index 1405637b3..6cd38c8aa 100644
--- 
a/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java
+++ 
b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java
@@ -27,9 +27,7 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import static java.util.Collections.singletonList;
 import static org.junit.Assert.assertEquals;
@@ -49,12 +47,8 @@ public class StrutsVelocityContextTest {
     @Mock
     private ValueStack stack;
 
-    private Map<String, Object> stackContext;
-
     @Before
     public void setUp() throws Exception {
-        stackContext = new HashMap<>();
-        when(stack.getContext()).thenReturn(stackContext);
         strutsVelocityContext = new 
StrutsVelocityContext(singletonList(chainedContext), stack);
     }
 
@@ -70,12 +64,6 @@ public class StrutsVelocityContextTest {
         assertEquals("bar", strutsVelocityContext.internalGet("foo"));
     }
 
-    @Test
-    public void getStackContextValue() {
-        stackContext.put("foo", "bar");
-        assertEquals("bar", strutsVelocityContext.internalGet("foo"));
-    }
-
     @Test
     public void getSuperValue() {
         strutsVelocityContext.put("foo", "bar");
@@ -84,9 +72,6 @@ public class StrutsVelocityContextTest {
 
     @Test
     public void getValuePrecedence() {
-        stackContext.put("foo", "quux");
-        assertEquals("quux", strutsVelocityContext.internalGet("foo"));
-
         when(stack.findValue("foo")).thenReturn("qux");
         assertEquals("qux", strutsVelocityContext.internalGet("foo"));
 

Reply via email to