Repository: struts
Updated Branches:
  refs/heads/master a399932ae -> 9fcf2dfca


[WW-4528] handling ChainingInterceptor excludes and includes lists as
comma separated String like ParameterFilterInterceptor do

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

Branch: refs/heads/master
Commit: 0437efc6f91c2b78d84f673a63d45ef2765782db
Parents: 0023d96
Author: Yasser Zamani <y.zaman...@gmail.com>
Authored: Fri Feb 3 02:01:50 2017 +0330
Committer: Yasser Zamani <y.zaman...@gmail.com>
Committed: Fri Feb 3 02:01:50 2017 +0330

----------------------------------------------------------------------
 .../xwork2/interceptor/ChainingInterceptor.java | 24 ++++++++++++++++++--
 .../interceptor/ChainingInterceptorTest.java    | 12 ++++------
 .../opensymphony/xwork2/ognl/OgnlUtilTest.java  |  4 ++--
 3 files changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/0437efc6/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
 
b/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
index 93bae6d..27a0f68 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
@@ -21,6 +21,7 @@ import com.opensymphony.xwork2.Result;
 import com.opensymphony.xwork2.Unchainable;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.CompoundRoot;
+import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
@@ -213,9 +214,18 @@ public class ChainingInterceptor extends 
AbstractInterceptor {
     /**
      * Sets the list of parameter names to exclude from copying (all others 
will be included).
      *
+     * @param excludes the excludes list as comma separated String
+     */
+    public void setExcludes(String excludes) {
+        this.excludes = TextParseUtil.commaDelimitedStringToSet(excludes);
+    }
+
+    /**
+     * Sets the list of parameter names to exclude from copying (all others 
will be included).
+     *
      * @param excludes the excludes list
      */
-    public void setExcludes(Collection<String> excludes) {
+    public void setExcludesCollection(Collection<String> excludes) {
         this.excludes = excludes;
     }
 
@@ -231,9 +241,19 @@ public class ChainingInterceptor extends 
AbstractInterceptor {
     /**
      * Sets the list of parameter names to include when copying (all others 
will be excluded).
      *
+     * @param includes the includes list as comma separated String
+     */
+    public void setIncludes(String includes) {
+        this.includes = TextParseUtil.commaDelimitedStringToSet(includes);
+    }
+
+
+    /**
+     * Sets the list of parameter names to include when copying (all others 
will be excluded).
+     *
      * @param includes the includes list
      */
-    public void setIncludes(Collection<String> includes) {
+    public void setIncludesCollection(Collection<String> includes) {
         this.includes = includes;
     }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/0437efc6/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java
 
b/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java
index 1b84209..8c18ee5 100644
--- 
a/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java
+++ 
b/core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java
@@ -103,8 +103,7 @@ public class ChainingInterceptorTest extends XWorkTestCase {
         interceptor.setCopyErrors("true");
         interceptor.setCopyMessages("true");
 
-        Collection<String> excludes = new ArrayList<>();
-        excludes.add("count");
+        String excludes = "count";
         interceptor.setExcludes(excludes);
 
         interceptor.intercept(invocation);
@@ -112,7 +111,7 @@ public class ChainingInterceptorTest extends XWorkTestCase {
         assertEquals(bean.getBirth(), action.getBirth());
         assertEquals(bean.getName(), action.getName());
         assertEquals(0, action.getCount());
-        assertEquals(excludes, interceptor.getExcludes());
+        assertEquals(interceptor.getExcludes().iterator().next(), "count");
     }
 
     public void testTwoExcludesPropertiesChained() throws Exception {
@@ -125,15 +124,14 @@ public class ChainingInterceptorTest extends 
XWorkTestCase {
         stack.push(bean);
         stack.push(action);
 
-        Collection<String> excludes = new ArrayList<>();
-        excludes.add("name");
-        excludes.add("count");
+        String excludes = "name,count";
         interceptor.setExcludes(excludes);
         interceptor.intercept(invocation);
         assertEquals(bean.getBirth(), action.getBirth());
         assertEquals(null, action.getName());
         assertEquals(0, action.getCount());
-        assertEquals(excludes, interceptor.getExcludes());
+        assertEquals(interceptor.getExcludes().iterator().next(), "count");
+        assertEquals(interceptor.getExcludes().iterator().next(), "name");
     }
 
     public void testNullCompoundRootElementAllowsProcessToContinue() throws 
Exception {

http://git-wip-us.apache.org/repos/asf/struts/blob/0437efc6/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java 
b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
index 4fdf742..a8bc7da 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
@@ -454,7 +454,7 @@ public class OgnlUtilTest extends XWorkTestCase {
         final ValueStack stack = ActionContext.getContext().getValueStack();
 
         Object result = 
Ognl.getValue(ognlUtil.compile("{\"foo\",'ruby','b','tom'}"), context, foo);
-        foo.setIncludes((Collection) result);
+        foo.setIncludesCollection((Collection) result);
 
         assertEquals(4, foo.getIncludes().size());
         assertEquals("foo", foo.getIncludes().toArray()[0]);
@@ -473,7 +473,7 @@ public class OgnlUtilTest extends XWorkTestCase {
 
         result = 
ActionContext.getContext().getValueStack().findValue("{\"foo\",'ruby','b','tom'}");
 
-        foo.setIncludes((Collection) result);
+        foo.setIncludesCollection((Collection) result);
         assertEquals(ArrayList.class, result.getClass());
 
         assertEquals(4, foo.getIncludes().size());

Reply via email to