Commits

Anonymous committed 8c6f1c2

Fixed issue XW-652 and new test

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1878e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits e1c5d7e

Comments (0)

Files changed (2)

src/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java

             final ValueStack stack = ac.getValueStack();
 
             for (Map.Entry<String, String> entry : parameters.entrySet()) {
-                stack.setValue(entry.getKey(), entry.getValue());
                 Object val = entry.getValue();
                 if (parse && val instanceof String) {
                     val = TextParseUtil.translateVariables(val.toString(), stack);

src/test/com/opensymphony/xwork2/interceptor/StaticParametersInterceptorTest.java

         assertEquals("${top.hero}", user.getName());
     }
 
+    public void testFewParametersParse() throws Exception {
+        MockActionInvocation mai = new MockActionInvocation();
+        MockActionProxy map = new MockActionProxy();
+        ActionConfig ac = new ActionConfig.Builder("", "", "")
+                .addParam("top.age", "${top.myAge}")
+                .addParam("top.email", "${top.myEmail}")
+                .build();
+        map.setConfig(ac);
+        mai.setProxy(map);
+        mai.setAction(new SimpleFooAction());
+
+        User user = new User();
+        ActionContext.getContext().getValueStack().push(user);
+        int before = ActionContext.getContext().getValueStack().size();
+        interceptor.setParse("true");
+        interceptor.intercept(mai);
+
+        assertEquals(before, ActionContext.getContext().getValueStack().size());
+        assertEquals(user.getMyAge(), user.age);
+        assertEquals(user.getMyEmail(), user.email);
+    }
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
 
     private class User {
         private String name;
+        private int age;
+        private String email;
 
         public String getName() {
             return name;
             this.name = name;
         }
 
+        public int getMyAge() {
+            return 33;
+        }
+
+        public void setAge(int age) {
+            this.age = age;
+        }
+
+        public String getMyEmail() {
+            return "lukasz dot lenart at gmail dot com";
+        }
+
+        public void setEmail(String email) {
+            this.email = email;
+        }
+
         public String getHero() {
             return "Superman";
         }