struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [1/2] struts git commit: WW-4667 Applies params to all instances of interceptor defined in stack
Date Tue, 06 Sep 2016 07:17:06 GMT
Repository: struts
Updated Branches:
  refs/heads/master 175c852ee -> f6876ce6c


WW-4667 Applies params to all instances of interceptor defined in stack

# Conflicts:
#	xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/InterceptorBuilder.java


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/ab0cb82d
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/ab0cb82d
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/ab0cb82d

Branch: refs/heads/master
Commit: ab0cb82d31cbad47664dee423ddbf0894b004d27
Parents: 175c852
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Tue Sep 6 09:07:02 2016 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Tue Sep 6 09:16:48 2016 +0200

----------------------------------------------------------------------
 .../providers/InterceptorBuilderTest.java       | 46 ++++++++++++++++++++
 1 file changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/ab0cb82d/core/src/test/java/com/opensymphony/xwork2/config/providers/InterceptorBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/InterceptorBuilderTest.java
b/core/src/test/java/com/opensymphony/xwork2/config/providers/InterceptorBuilderTest.java
index 914d963..870691a 100644
--- a/core/src/test/java/com/opensymphony/xwork2/config/providers/InterceptorBuilderTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/InterceptorBuilderTest.java
@@ -9,6 +9,7 @@ import com.opensymphony.xwork2.config.entities.InterceptorStackConfig;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
 import com.opensymphony.xwork2.interceptor.Interceptor;
 
+import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 
@@ -78,6 +79,51 @@ public class InterceptorBuilderTest extends XWorkTestCase {
         assertEquals(((MockInterceptor2) ((InterceptorMapping) interceptorMappings.get(1)).getInterceptor()).getParam2(),
"interceptor2_value2");
     }
 
+    public void testMultipleSameInterceptors() 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("multiStack")
+                .addInterceptor(new InterceptorMapping(interceptorConfig1.getName(), objectFactory.buildInterceptor(interceptorConfig1,
Collections.<String, String>emptyMap())))
+                .addInterceptor(new InterceptorMapping(interceptorConfig2.getName(), objectFactory.buildInterceptor(interceptorConfig2,
Collections.<String, String>emptyMap())))
+                .addInterceptor(new InterceptorMapping(interceptorConfig1.getName(), objectFactory.buildInterceptor(interceptorConfig1,
Collections.<String, String>emptyMap())))
+                .build();
+
+        PackageConfig packageConfig = new PackageConfig.Builder("package1")
+                .namespace("/namespace")
+                .addInterceptorConfig(interceptorConfig1)
+                .addInterceptorConfig(interceptorConfig2)
+                .addInterceptorConfig(interceptorConfig1)
+                .addInterceptorStackConfig(interceptorStackConfig1)
+                .build();
+
+        List interceptorMappings =  InterceptorBuilder.constructInterceptorReference(packageConfig,
"multiStack",
+                        new LinkedHashMap<String, String>() {
+                            {
+                                put("interceptor1.param1", "interceptor1_value1");
+                                put("interceptor1.param2", "interceptor1_value2");
+                            }
+                        }, null,  objectFactory);
+
+        assertEquals(interceptorMappings.size(), 3);
+
+        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(((InterceptorMapping) interceptorMappings.get(2)).getName(), "interceptor1");
+        assertNotNull(((InterceptorMapping) interceptorMappings.get(2)).getInterceptor());
+        assertEquals(((InterceptorMapping) interceptorMappings.get(2)).getInterceptor().getClass(),
MockInterceptor1.class);
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(2)).getInterceptor()).getParam1(),
"interceptor1_value1");
+        assertEquals(((MockInterceptor1) ((InterceptorMapping) interceptorMappings.get(2)).getInterceptor()).getParam2(),
"interceptor1_value2");
+    }
+
     /**
      * Try to test this
      * <interceptor-ref name="interceptorStack1">


Mime
View raw message