Commits

Anonymous committed c3b9524

XW-551 interceptor-stack's interceptor parameter overriding does not work when there's nested interceptor-stack
o ported fix from xwork 1.2 branch

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

Comments (0)

Files changed (8)

src/java/com/opensymphony/xwork2/config/entities/InterceptorStackConfig.java

  */
 public class InterceptorStackConfig extends Located implements Serializable {
 
+    private static final long serialVersionUID = 2897260918170270343L;
+
+    /**
+     * A list of InterceptorMapping object
+     */
     private List<InterceptorMapping> interceptors;
     private String name;
 
 
+    /**
+     * Creates an InterceptorStackConfig object.
+     */
     protected InterceptorStackConfig() {
         this.interceptors = new ArrayList<InterceptorMapping>();
     }
 
+    /**
+     * Creates an InterceptorStackConfig object with a particular <code>name</code>.
+     *
+     * @param name
+     */
     protected InterceptorStackConfig(InterceptorStackConfig orig) {
         this.name = orig.name;
         this.interceptors = new ArrayList<InterceptorMapping>(orig.interceptors);
     }
 
 
+    /**
+     * Returns a <code>Collection</code> of InterceptorMapping objects.
+     *
+     * @return
+     */
     public Collection<InterceptorMapping> getInterceptors() {
         return interceptors;
     }
 
+    /**
+     * Get the name of this interceptor stack configuration.
+     *
+     * @return String
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * An InterceptorStackConfig object is equals with <code>o</code> only if
+     * <ul>
+     * <li>o is an InterceptorStackConfig object</li>
+     * <li>both names are equals</li>
+     * <li>all of their <code>InterceptorMapping</code>s are equals</li>
+     * </ul>
+     */
     public boolean equals(Object o) {
         if (this == o) {
             return true;
 
         final InterceptorStackConfig interceptorStackConfig = (InterceptorStackConfig) o;
 
-        if ((interceptors != null) ? (!interceptors.equals(interceptorStackConfig.interceptors)) : (interceptorStackConfig.interceptors != null))
-        {
+        if ((interceptors != null) ? (!interceptors.equals(interceptorStackConfig.interceptors)) : (interceptorStackConfig.interceptors != null)) {
             return false;
         }
 
         return true;
     }
 
+    /**
+     * Generate hashcode based on <code>InterceptorStackConfig</code>'s name and its
+     * <code>InterceptorMapping</code>s.
+     */
     public int hashCode() {
         int result;
         result = ((name != null) ? name.hashCode() : 0);
             return this;
         }
 
+        /**
+         * Add an <code>InterceptorMapping</code> object.
+         */
         public Builder addInterceptor(InterceptorMapping interceptor) {
             target.interceptors.add(interceptor);
             return this;
         }
 
+        /**
+         * Add a List of <code>InterceptorMapping</code> objects.
+         */
         public Builder addInterceptors(List<InterceptorMapping> interceptors) {
             target.interceptors.addAll(interceptors);
             return this;

src/java/com/opensymphony/xwork2/config/entities/PackageConfig.java

     }
 
     public int hashCode() {
-        // System.out.println("hashCode() + {Name:"+name+" abstract:"+isAbstract+" namespace:"+namespace+" parents: "+parents+"}");
         int result;
         result = ((name != null) ? name.hashCode() : 0);
         result = (29 * result) + ((parents != null) ? parents.hashCode() : 0);

src/java/com/opensymphony/xwork2/config/providers/InterceptorBuilder.java

 
 
     /**
-     * Builds a list of interceptors referenced by the refName in the supplied PackageConfig.
+     * Builds a list of interceptors referenced by the refName in the supplied PackageConfig (InterceptorMapping object).
      *
      * @param interceptorLocator
      * @param refName
      * @param refParams
-     * @return list of interceptors referenced by the refName in the supplied PackageConfig.
+     * @return list of interceptors referenced by the refName in the supplied PackageConfig (InterceptorMapping object).
      * @throws ConfigurationException
      */
     public static List<InterceptorMapping> constructInterceptorReference(InterceptorLocator interceptorLocator ,
     private static List<InterceptorMapping> constructParameterizedInterceptorReferences(
             InterceptorLocator interceptorLocator, InterceptorStackConfig stackConfig, Map refParams,
             ObjectFactory objectFactory) {
-        List<InterceptorMapping> result;
+        Set<InterceptorMapping> result;
         Map<String, Map<Object, String>> params = new LinkedHashMap<String, Map<Object, String>>();
 
+        /*
+         * We strip
+         *
+         * <interceptor-ref name="someStack">
+         *    <param name="interceptor1.param1">someValue</param>
+         *    <param name="interceptor1.param2">anotherValue</param>
+         * </interceptor-ref>
+         *
+         * down to map
+         *  interceptor1 -> [param1 -> someValue, param2 -> anotherValue]
+         *
+         * or
+         * <interceptor-ref name="someStack">
+         *    <param name="interceptorStack1.interceptor1.param1">someValue</param>
+         *    <param name="interceptorStack1.interceptor1.param2">anotherValue</param>
+         * </interceptor-ref>
+         *
+         * down to map
+         *  interceptorStack1 -> [interceptor1.param1 -> someValue, interceptor1.param2 -> anotherValue]
+         *
+         */
         for (Iterator iter = refParams.keySet().iterator(); iter.hasNext();) {
             String key = (String) iter.next();
             String value = (String) refParams.get(key);
             }
         }
 
-        result = new ArrayList<InterceptorMapping>(stackConfig.getInterceptors());
+        result = new LinkedHashSet<InterceptorMapping>(stackConfig.getInterceptors());
 
         for (String key : params.keySet()) {
 
             Map<Object, String> map = params.get(key);
 
-            InterceptorConfig cfg = (InterceptorConfig) interceptorLocator.getInterceptorConfig(key);
-            Interceptor interceptor = objectFactory.buildInterceptor(cfg, map);
 
-            InterceptorMapping mapping = new InterceptorMapping(key, interceptor);
-            if (result != null && result.contains(mapping)) {
-                int index = result.indexOf(mapping);
-                result.set(index, mapping);
-            } else {
+            Object interceptorCfgObj = interceptorLocator.getInterceptorConfig(key);
+
+            /*
+             * Now we attempt to separate out param that refers to Interceptor
+             * and Interceptor stack, eg.
+             *
+             * <interceptor-ref name="someStack">
+             *    <param name="interceptor1.param1">someValue</param>
+             *    ...
+             * </interceptor-ref>
+             *
+             *  vs
+             *
+             *  <interceptor-ref name="someStack">
+             *    <param name="interceptorStack1.interceptor1.param1">someValue</param>
+             *    ...
+             *  </interceptor-ref>
+             */
+            if(interceptorCfgObj instanceof InterceptorConfig) {  //  interceptor-ref param refer to an interceptor
+            	InterceptorConfig cfg = (InterceptorConfig) interceptorCfgObj;
+            	Interceptor interceptor = objectFactory.buildInterceptor(cfg, map);
+            
+
+//            InterceptorConfig cfg = (InterceptorConfig) interceptorLocator.getInterceptorConfig(key);
+//            Interceptor interceptor = objectFactory.buildInterceptor(cfg, map);
+//
+//            InterceptorMapping mapping = new InterceptorMapping(key, interceptor);
+//            if (result != null && result.contains(mapping)) {
+//                int index = result.indexOf(mapping);
+//                result.set(index, mapping);
+//            } else {
+            	InterceptorMapping mapping = new InterceptorMapping(key, interceptor);
+            	if ( result != null && result.contains(mapping)) {
+            		// if an existing interceptor mapping exists,
+            		// we remove from the result Set, just to make sure
+            		// there's always one unique mapping.
+            		result.remove(mapping);
+            	}
                 result.add(mapping);
             }
+            else if (interceptorCfgObj instanceof InterceptorStackConfig){  // interceptor-ref param refer to an interceptor stack
+
+            	// If its an interceptor-stack, we call this method recursively untill,
+            	// all the params (eg. interceptorStack1.interceptor1.param etc.)
+            	// are resolved down to a specific interceptor.
+
+            	InterceptorStackConfig stackCfg = (InterceptorStackConfig) interceptorCfgObj;
+            	List tmpResult = constructParameterizedInterceptorReferences(interceptorLocator, stackCfg, map, objectFactory);
+            	for (Iterator i = tmpResult.iterator(); i.hasNext(); ) {
+            		InterceptorMapping tmpInterceptorMapping = (InterceptorMapping) i.next();
+            		if (result.contains(tmpInterceptorMapping)) {
+            			result.remove(tmpInterceptorMapping);
+            		}
+            		result.add(tmpInterceptorMapping);
+            	}
+            }
         }
 
-        return result;
+        return new ArrayList<InterceptorMapping>(result);
     }
 }

src/java/com/opensymphony/xwork2/mock/MockInterceptor.java

  */
 public class MockInterceptor implements Interceptor {
 
+    private static final long serialVersionUID = 2692551676567227756L;
+    
     public static final String DEFAULT_FOO_VALUE = "fooDefault";
 
 

src/test/com/opensymphony/xwork2/config/providers/InterceptorBuilderTest.java

+package com.opensymphony.xwork2.config.providers;
+
+import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.interceptor.Interceptor;
+import com.opensymphony.xwork2.config.entities.InterceptorStackConfig;
+import com.opensymphony.xwork2.config.entities.InterceptorMapping;
+import com.opensymphony.xwork2.config.entities.InterceptorConfig;
+import com.opensymphony.xwork2.config.entities.PackageConfig;
+
+import java.util.List;
+import java.util.LinkedHashMap;
+
+/**
+ * <code>InterceptorBuilderTest</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id: $
+ */
+public class InterceptorBuilderTest extends XWorkTestCase {
+
+    ObjectFactory objectFactory;
+
+    public void setUp() throws Exception {
+        super.setUp();
+        objectFactory = container.getInstance(ObjectFactory.class);
+    }
+    
+    /**
+     * Try to test this
+     * <interceptor-ref name="interceptorStack1">
+     * <param name="interceptor1.param1">interceptor1_value1</param>
+     * <param name="interceptor1.param2">interceptor1_value2</param>
+     * <param name="interceptor2.param1">interceptor2_value1</param>
+     * <param name="interceptor2.param2">interceptor2_value2</param>
+     * </interceptor-ref>
+     *
+     * @throws Exception
+     */
+    public void testBuildInterceptor_1() throws Exception {
+        InterceptorStackConfig interceptorStackConfig1 = new InterceptorStackConfig.Builder("interceptorStack1").build();
+
+        InterceptorConfig interceptorConfig1 = new InterceptorConfig.Builder("interceptor1", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor1").build();
+
+        InterceptorConfig interceptorConfig2 = new InterceptorConfig.Builder("interceptor2", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor2").build();
+
+
+        PackageConfig packageConfig = new PackageConfig.Builder("package1").namespace("/namespace").addInterceptorConfig(interceptorConfig1).addInterceptorConfig(interceptorConfig2).addInterceptorStackConfig(interceptorStackConfig1).build();
+
+        List
+                interceptorMappings =
+                InterceptorBuilder.constructInterceptorReference(packageConfig, "interceptorStack1",
+                        new LinkedHashMap() {
+                            private static final long serialVersionUID = -1358620486812957895L;
+
+                            {
+                                put("interceptor1.param1", "interceptor1_value1");
+                                put("interceptor1.param2", "interceptor1_value2");
+                                put("interceptor2.param1", "interceptor2_value1");
+                                put("interceptor2.param2", "interceptor2_value2");
+                            }
+                        },null,  objectFactory);
+
+        assertEquals(interceptorMappings.size(), 2);
+
+        assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getName(), "interceptor1");
+        assertNotNull(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor());
+        assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor().getClass(), MockInterceptor1.class);
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam1(), "interceptor1_value1");
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam2(), "interceptor1_value2");
+
+        assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getName(), "interceptor2");
+        assertNotNull(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor());
+        assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor().getClass(), MockInterceptor2.class);
+        assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam1(), "interceptor2_value1");
+        assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam2(), "interceptor2_value2");
+    }
+
+    /**
+     * Try to test this
+     * <interceptor-ref name="interceptorStack1">
+     * <param name="interceptorStack2.interceptor1.param1">interceptor1_value1</param>
+     * <param name="interceptorStack2.interceptor1.param2">interceptor1_value2</param>
+     * <param name="interceptorStack3.interceptor2.param1">interceptor2_value1</param>
+     * <param name="interceptorStack3.interceptor2.param2">interceptor2_value2</param>
+     * </interceptor-ref>
+     *
+     * @throws Exception
+     */
+    public void testBuildInterceptor_2() throws Exception {
+        InterceptorStackConfig interceptorStackConfig1 = new InterceptorStackConfig.Builder("interceptorStack1").build();
+
+        InterceptorStackConfig interceptorStackConfig2 = new InterceptorStackConfig.Builder("interceptorStack2").build();
+
+        InterceptorStackConfig interceptorStackConfig3 = new InterceptorStackConfig.Builder("interceptorStack3").build();
+
+        InterceptorConfig interceptorConfig1 = new InterceptorConfig.Builder("interceptor1", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor1").build();
+
+        InterceptorConfig interceptorConfig2 = new InterceptorConfig.Builder("interceptor2", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor2").build();
+
+
+        PackageConfig packageConfig = new PackageConfig.Builder("package1").namespace("/namspace").
+                addInterceptorConfig(interceptorConfig1).
+                addInterceptorConfig(interceptorConfig2).
+                addInterceptorStackConfig(interceptorStackConfig1).
+                addInterceptorStackConfig(interceptorStackConfig2).
+                addInterceptorStackConfig(interceptorStackConfig3).build();
+
+        List interceptorMappings = InterceptorBuilder.constructInterceptorReference(packageConfig, "interceptorStack1",
+                new LinkedHashMap() {
+                    private static final long serialVersionUID = -5819935102242042570L;
+
+                    {
+                        put("interceptorStack2.interceptor1.param1", "interceptor1_value1");
+                        put("interceptorStack2.interceptor1.param2", "interceptor1_value2");
+                        put("interceptorStack3.interceptor2.param1", "interceptor2_value1");
+                        put("interceptorStack3.interceptor2.param2", "interceptor2_value2");
+                    }
+                }, null, objectFactory);
+
+        assertEquals(interceptorMappings.size(), 2);
+
+        assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getName(), "interceptor1");
+        assertNotNull(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor());
+        assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor().getClass(), MockInterceptor1.class);
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam1(), "interceptor1_value1");
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam2(), "interceptor1_value2");
+
+        assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getName(), "interceptor2");
+        assertNotNull(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor());
+        assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor().getClass(), MockInterceptor2.class);
+        assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam1(), "interceptor2_value1");
+        assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam2(), "interceptor2_value2");
+    }
+
+    /**
+     * Try to test this
+     * <interceptor-ref name="interceptorStack1">
+     * <param name="interceptorStack2.interceptorStack3.interceptorStack4.interceptor1.param1">interceptor1_value1</param>
+     * <param name="interceptorStack2.interceptorStack3.interceptorStack4.interceptor1.param2">interceptor1_value2</param>
+     * <param name="interceptorStack5.interceptor2.param1">interceptor2_value1</param>
+     * <param name="interceptorStack5.interceptor2.param2">interceptor2_value2</param>
+     * </interceptor-ref>
+     *
+     * @throws Exception
+     */
+    public void testBuildInterceptor_3() throws Exception {
+        InterceptorConfig interceptorConfig1 = new InterceptorConfig.Builder("interceptor1", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor1").build();
+
+        InterceptorConfig interceptorConfig2 = new InterceptorConfig.Builder("interceptor2", "com.opensymphony.xwork2.config.providers.InterceptorBuilderTest$MockInterceptor2").build();
+
+
+        InterceptorStackConfig interceptorStackConfig1 = new InterceptorStackConfig.Builder("interceptorStack1").build();
+
+
+        InterceptorStackConfig interceptorStackConfig2 = new InterceptorStackConfig.Builder("interceptorStack2").build();
+
+
+        InterceptorStackConfig interceptorStackConfig3 = new InterceptorStackConfig.Builder("interceptorStack3").build();
+
+
+        InterceptorStackConfig interceptorStackConfig4 = new InterceptorStackConfig.Builder("interceptorStack4").build();
+
+
+        InterceptorStackConfig interceptorStackConfig5 = new InterceptorStackConfig.Builder("interceptorStack5").build();
+
+
+
+        PackageConfig packageConfig = new PackageConfig.Builder("package1").
+                addInterceptorConfig(interceptorConfig1).
+                addInterceptorConfig(interceptorConfig2).
+                addInterceptorStackConfig(interceptorStackConfig1).
+                addInterceptorStackConfig(interceptorStackConfig2).
+                addInterceptorStackConfig(interceptorStackConfig3).
+                addInterceptorStackConfig(interceptorStackConfig4).
+                addInterceptorStackConfig(interceptorStackConfig5).build();
+
+
+        List interceptorMappings = InterceptorBuilder.constructInterceptorReference(
+                packageConfig, "interceptorStack1",
+                new LinkedHashMap() {
+                    private static final long serialVersionUID = 4675809753780875525L;
+
+                    {
+                        put("interceptorStack2.interceptorStack3.interceptorStack4.interceptor1.param1", "interceptor1_value1");
+                        put("interceptorStack2.interceptorStack3.interceptorStack4.interceptor1.param2", "interceptor1_value2");
+                        put("interceptorStack5.interceptor2.param1", "interceptor2_value1");
+                        put("interceptorStack5.interceptor2.param2", "interceptor2_value2");
+                    }
+                }, null, objectFactory);
+
+        assertEquals(interceptorMappings.size(), 2);
+
+        assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getName(), "interceptor1");
+        assertNotNull(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor());
+        assertEquals(((InterceptorMapping) interceptorMappings.get(0)).getInterceptor().getClass(), MockInterceptor1.class);
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam1(), "interceptor1_value1");
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(0)).getInterceptor()).getParam2(), "interceptor1_value2");
+
+        assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getName(), "interceptor2");
+        assertNotNull(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor());
+        assertEquals(((InterceptorMapping) interceptorMappings.get(1)).getInterceptor().getClass(), MockInterceptor2.class);
+        assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam1(), "interceptor2_value1");
+        assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam2(), "interceptor2_value2");
+    }
+
+
+    public static class MockInterceptor1 implements Interceptor {
+        private static final long serialVersionUID = 2939902550126175874L;
+        private String param1;
+        private String param2;
+
+        public void setParam1(String param1) {
+            this.param1 = param1;
+        }
+
+        public String getParam1() {
+            return this.param1;
+        }
+
+        public void setParam2(String param2) {
+            this.param2 = param2;
+        }
+
+        public String getParam2() {
+            return this.param2;
+        }
+
+        public void destroy() {
+        }
+
+        public void init() {
+        }
+
+        public String intercept(ActionInvocation invocation) throws Exception {
+            return invocation.invoke();
+        }
+    }
+
+    public static class MockInterceptor2 implements Interceptor {
+        private static final long serialVersionUID = 267427973306989618L;
+        private String param1;
+        private String param2;
+
+        public void setParam1(String param1) {
+            this.param1 = param1;
+        }
+
+        public String getParam1() {
+            return this.param1;
+        }
+
+        public void setParam2(String param2) {
+            this.param2 = param2;
+        }
+
+        public String getParam2() {
+            return this.param2;
+        }
+
+        public void destroy() {
+        }
+
+        public void init() {
+        }
+
+        public String intercept(ActionInvocation invocation) throws Exception {
+            return invocation.invoke();
+        }
+    }
+
+}

src/test/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java

 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Iterator;
 
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.RuntimeConfiguration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
  */
 public class XmlConfigurationProviderInterceptorParamOverridingTest extends XWorkTestCase {
 
-	public void testParamOveriding() throws Exception {
+	public void testInterceptorParamOveriding() throws Exception {
 		DefaultConfiguration conf = new DefaultConfiguration();
 		final XmlConfigurationProvider p = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml");
 		conf.reload(new ArrayList<ConfigurationProvider>(){
 		assertNotNull(actionTwoInterceptorMapping2);
 		assertNotNull(actionTwoInterceptorMapping3);
 		
-		assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping1.getInterceptor()).getParamOne(), "i1p1");
-		assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping1.getInterceptor()).getParamTwo(), "i1p2");
-		assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping2.getInterceptor()).getParamOne(), "i2p1");
-		assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping2.getInterceptor()).getParamTwo(), null);
-		assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping3.getInterceptor()).getParamOne(), null);
-		assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping3.getInterceptor()).getParamTwo(), null);
+		assertInterceptorParamOneEquals(actionOne, "interceptorOne", "i1p1");
+		assertInterceptorParamTwoEquals(actionOne, "interceptorOne", "i1p2");
+		assertInterceptorParamOneEquals(actionOne, "interceptorTwo", "i2p1" );
+		assertInterceptorParamTwoEquals(actionOne, "interceptorTwo", null);
+		assertInterceptorParamOneEquals(actionOne, "interceptorThree", null);
+		assertInterceptorParamTwoEquals(actionOne, "interceptorThree", null);
 		
-		assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping1.getInterceptor()).getParamOne(), null);
-		assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping1.getInterceptor()).getParamTwo(), null);
-		assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping2.getInterceptor()).getParamOne(), null);
-		assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping2.getInterceptor()).getParamTwo(), "i2p2");
-		assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping3.getInterceptor()).getParamOne(), "i3p1");
-		assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping3.getInterceptor()).getParamTwo(), "i3p2");
+		assertInterceptorParamOneEquals(actionTwo, "interceptorOne", null);
+		assertInterceptorParamTwoEquals(actionTwo, "interceptorOne", null);
+		assertInterceptorParamOneEquals(actionTwo, "interceptorTwo", null);
+		assertInterceptorParamTwoEquals(actionTwo, "interceptorTwo", "i2p2");
+		assertInterceptorParamOneEquals(actionTwo, "interceptorThree", "i3p1");
+		assertInterceptorParamTwoEquals(actionTwo, "interceptorThree", "i3p2");
 		
 	}
+
+
+	protected void assertInterceptorParamOneEquals(ActionConfig actionConfig,String interceptorName,  String paramValue) {
+		List interceptorMappings = actionConfig.getInterceptors();
+		for (Iterator i = interceptorMappings.iterator(); i.hasNext();) {
+			InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
+			assertNotNull(interceptorMapping.getInterceptor());
+			if (interceptorMapping.getName().equals(interceptorName)) {
+				assertEquals(((InterceptorForTestPurpose)interceptorMapping.getInterceptor()).getParamOne(), paramValue);
+				return;
+			}
+		}
+		fail();
+	}
+
+	protected void assertInterceptorParamTwoEquals(ActionConfig actionConfig, String interceptorName, String paramValue) {
+		List interceptorMappings = actionConfig.getInterceptors();
+		for (Iterator i = interceptorMappings.iterator(); i.hasNext();) {
+			InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
+			assertNotNull(interceptorMapping.getInterceptor());
+			if (interceptorMapping.getName().equals(interceptorName)) {
+				assertEquals(((InterceptorForTestPurpose)interceptorMapping.getInterceptor()).getParamTwo(), paramValue);
+				return;
+			}
+		}
+		fail();
+	}
+
+ 	protected void tearDown() throws Exception {
+
+         configurationManager.clearContainerProviders();
+ 	}
 }

src/test/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java

+package com.opensymphony.xwork2.config.providers;
+
+import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.config.entities.InterceptorMapping;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.RuntimeConfiguration;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * <code>XmlConfigurationProviderInterceptorStackParamOverridingTest</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id: $
+ */
+public class XmlConfigurationProviderInterceptorStackParamOverridingTest extends XWorkTestCase {
+    
+    public void testInterceptorStackParamOveriding() throws Exception {
+    	DefaultConfiguration conf = new DefaultConfiguration();
+    	final XmlConfigurationProvider p = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml");
+    	configurationManager.addContainerProvider(p);
+        conf.reload(new ArrayList<ConfigurationProvider>(){
+            {
+                add(new XWorkConfigurationProvider());
+                add(p);
+            }
+        });
+
+
+    	RuntimeConfiguration rtConf = conf.getRuntimeConfiguration();
+
+    	ActionConfig actionOne = rtConf.getActionConfig("", "actionOne");
+    	ActionConfig actionTwo = rtConf.getActionConfig("", "actionTwo");
+
+    	List actionOneInterceptors = actionOne.getInterceptors();
+    	List actionTwoInterceptors = actionTwo.getInterceptors();
+
+    	assertNotNull(actionOne);
+    	assertNotNull(actionTwo);
+    	assertNotNull(actionOneInterceptors);
+    	assertNotNull(actionTwoInterceptors);
+    	assertEquals(actionOneInterceptors.size(), 3);
+    	assertEquals(actionTwoInterceptors.size(), 3);
+
+    	InterceptorMapping actionOneInterceptorMapping1 = (InterceptorMapping) actionOneInterceptors.get(0);
+    	InterceptorMapping actionOneInterceptorMapping2 = (InterceptorMapping) actionOneInterceptors.get(1);
+    	InterceptorMapping actionOneInterceptorMapping3 = (InterceptorMapping) actionOneInterceptors.get(2);
+    	InterceptorMapping actionTwoInterceptorMapping1 = (InterceptorMapping) actionTwoInterceptors.get(0);
+    	InterceptorMapping actionTwoInterceptorMapping2 = (InterceptorMapping) actionTwoInterceptors.get(1);
+    	InterceptorMapping actionTwoInterceptorMapping3 = (InterceptorMapping) actionTwoInterceptors.get(2);
+
+    	assertNotNull(actionOneInterceptorMapping1);
+    	assertNotNull(actionOneInterceptorMapping2);
+    	assertNotNull(actionOneInterceptorMapping3);
+    	assertNotNull(actionTwoInterceptorMapping1);
+    	assertNotNull(actionTwoInterceptorMapping2);
+    	assertNotNull(actionTwoInterceptorMapping3);
+
+
+    	assertInterceptorParamOneEquals(actionOne, "interceptorOne", "i1p1");
+    	assertInterceptorParamTwoEquals(actionOne, "interceptorOne", "i1p2");
+    	assertInterceptorParamOneEquals(actionOne, "interceptorTwo", "i2p1" );
+    	assertInterceptorParamTwoEquals(actionOne, "interceptorTwo", null);
+    	assertInterceptorParamOneEquals(actionOne, "interceptorThree", null);
+    	assertInterceptorParamTwoEquals(actionOne, "interceptorThree", null);
+
+    	assertInterceptorParamOneEquals(actionTwo, "interceptorOne", null);
+    	assertInterceptorParamTwoEquals(actionTwo, "interceptorOne", null);
+    	assertInterceptorParamOneEquals(actionTwo, "interceptorTwo", null);
+    	assertInterceptorParamTwoEquals(actionTwo, "interceptorTwo", "i2p2");
+    	assertInterceptorParamOneEquals(actionTwo, "interceptorThree", "i3p1");
+    	assertInterceptorParamTwoEquals(actionTwo, "interceptorThree", "i3p2");
+
+    }
+
+    protected void assertInterceptorParamOneEquals(ActionConfig actionConfig,String interceptorName,  String paramValue) {
+    	List interceptorMappings = actionConfig.getInterceptors();
+    	for (Iterator i = interceptorMappings.iterator(); i.hasNext();) {
+    		InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
+    		assertNotNull(interceptorMapping.getInterceptor());
+    		if (interceptorMapping.getName().equals(interceptorName)) {
+    			assertEquals(((InterceptorForTestPurpose)interceptorMapping.getInterceptor()).getParamOne(), paramValue);
+    			return;
+    		}
+    	}
+    	fail();
+    }
+
+    protected void assertInterceptorParamTwoEquals(ActionConfig actionConfig, String interceptorName, String paramValue) {
+    	List interceptorMappings = actionConfig.getInterceptors();
+    	for (Iterator i = interceptorMappings.iterator(); i.hasNext();) {
+    		InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
+    		assertNotNull(interceptorMapping.getInterceptor());
+    		if (interceptorMapping.getName().equals(interceptorName)) {
+    			assertEquals(((InterceptorForTestPurpose)interceptorMapping.getInterceptor()).getParamTwo(), paramValue);
+    			return;
+    		}
+    	}
+    	fail();
+    }
+
+    protected void tearDown() throws Exception {
+    	configurationManager.clearContainerProviders();
+    }
+}

src/test/com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xwork PUBLIC
+    "-//OpenSymphony Group//XWork 2.0//EN"
+    "http://www.opensymphony.com/xwork/xwork-2.0.dtd">
+
+<xwork>
+	<package name="packageOne">
+		<result-types>
+			<result-type name="mock" class="com.opensymphony.xwork2.mock.MockResult" />
+		</result-types>
+
+		<interceptors>
+			<interceptor name="interceptorOne" class="com.opensymphony.xwork2.config.providers.InterceptorForTestPurpose" />
+			<interceptor name="interceptorTwo" class="com.opensymphony.xwork2.config.providers.InterceptorForTestPurpose" />
+			<interceptor name="interceptorThree" class="com.opensymphony.xwork2.config.providers.InterceptorForTestPurpose" />
+
+			<interceptor-stack name="stackOne">
+				<interceptor-ref name="interceptorOne" />
+				<interceptor-ref name="interceptorTwo" />
+				<interceptor-ref name="interceptorThree" />
+			</interceptor-stack>
+
+			<interceptor-stack name="stackTwo">
+				<interceptor-ref name="stackOne" />
+			</interceptor-stack>
+
+			<interceptor-stack name="stackThree">
+				<interceptor-ref name="stackTwo" />
+			</interceptor-stack>
+
+		</interceptors>
+
+		<action name="actionOne">
+			<interceptor-ref name="stackTwo">
+				<param name="stackOne.interceptorOne.paramOne">i1p1</param>
+				<param name="stackOne.interceptorOne.paramTwo">i1p2</param>
+				<param name="stackOne.interceptorTwo.paramOne">i2p1</param>
+			</interceptor-ref>
+			<result name="success" type="mock">test1</result>
+		</action>
+
+		<action name="actionTwo">
+			<interceptor-ref name="stackThree">
+				<param name="stackTwo.stackOne.interceptorThree.paramOne">i3p1</param>
+				<param name="stackTwo.stackOne.interceptorThree.paramTwo">i3p2</param>
+				<param name="stackTwo.stackOne.interceptorTwo.paramTwo">i2p2</param>
+			</interceptor-ref>
+			<result name="success" type="mock">test2</result>
+		</action>
+	</package>
+</xwork>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.