Commits

Anonymous committed 785d8c1

Adding test proving OGNL doesn't access private variables

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

Comments (0)

Files changed (2)

src/test/com/opensymphony/xwork2/SimpleAction.java

     private String aliasSource;
     private String aliasDest;
     private Map<String,String> protectedMap = new HashMap<String,String>();
+    private Map<String,String> existingMap = new HashMap<String,String>();
     
     public static boolean resultCalled;
 
 
     public SimpleAction() {
         resultCalled = false;
+        existingMap.put("existingKey", "value");
     }
     
     public Map<String,String> getTheProtectedMap() {
         return protectedMap;
     }
 
+    public void setExistingMap(Map<String,String> map) {
+        this.existingMap = map;
+    }
+
+    public Map<String,String> getTheExistingMap() {
+        return existingMap;
+    }
+
 
     public void setBar(int bar) {
         this.bar = bar;

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

         assertNull(action.getTheProtectedMap().get("foo"));
     }
 
+    public void testParametersOverwriteField() throws Exception {
+        Map params = new LinkedHashMap();
+        params.put("existingMap.boo", "This is blah");
+
+        HashMap extraContext = new HashMap();
+        extraContext.put(ActionContext.PARAMETERS, params);
+
+        ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, extraContext);
+        proxy.execute();
+        SimpleAction action = (SimpleAction) proxy.getAction();
+        assertEquals(1, action.getTheExistingMap().size());
+        assertNotNull(action.getTheExistingMap().get("boo"));
+        assertNull(action.getTheExistingMap().get("existingKey"));
+    }
+
     public void testNonexistentParametersGetLoggedInDevMode() throws Exception {
         loadConfigurationProviders(new XmlConfigurationProvider("xwork-test-beans.xml"), 
                 new MockConfigurationProvider(Collections.singletonMap("devMode", "true")));