struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [32/33] struts git commit: Simplifies checking of Strict DMI to simple getter
Date Mon, 28 Sep 2015 18:53:21 GMT
Simplifies checking of Strict DMI to simple getter


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

Branch: refs/heads/master
Commit: fdb6daec7859e0cf95a0da5482991b8342cf91ad
Parents: 86afcbe
Author: Lukasz Lenart <lukasz.lenart@gmail.com>
Authored: Sat Sep 26 08:57:44 2015 +0200
Committer: Lukasz Lenart <lukasz.lenart@gmail.com>
Committed: Sat Sep 26 08:57:44 2015 +0200

----------------------------------------------------------------------
 .../xwork2/config/entities/PackageConfig.java   | 14 +----
 .../config/entities/PackageConfigTest.java      | 62 +++++++++++++++++++-
 2 files changed, 62 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/fdb6daec/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java
b/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java
index e297b49..1e7a4dd 100644
--- a/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java
+++ b/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java
@@ -600,22 +600,12 @@ public class PackageConfig extends Located implements Comparable, Serializable,
         }
 
         public Builder strictMethodInvocation(boolean strict) {
-            strictDMI = strict;
+            target.strictMethodInvocation = strict;
             return this;
         }
 
         public boolean isStrictMethodInvocation() {
-            // if Strict DMI was disabled in this package,
-            // return without evaluating parent packages
-            if (!strictDMI) {
-                return false;
-            }
-            for (PackageConfig parent : target.parents) {
-                if (parent.isStrictMethodInvocation()) {
-                    return true;
-                }
-            }
-            return true;
+            return target.strictMethodInvocation;
         }
 
         public PackageConfig build() {

http://git-wip-us.apache.org/repos/asf/struts/blob/fdb6daec/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java
b/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java
index e2f2868..4a25ccb 100644
--- a/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java
@@ -30,5 +30,63 @@ public class PackageConfigTest extends XWorkTestCase {
         
         assertEquals("ref2", cfg.getFullDefaultInterceptorRef());
     }
-    
-}
\ No newline at end of file
+
+    public void testStrictDMIInheritance() {
+        // given
+        PackageConfig parent = new PackageConfig.Builder("parent").build();
+
+        // when
+        PackageConfig child = new PackageConfig.Builder("child")
+                .addParent(parent)
+                .build();
+
+        // then
+        assertTrue(child.isStrictMethodInvocation());
+    }
+
+    public void testStrictDMIInheritanceDisabledInParentPackage() {
+        // given
+        PackageConfig parent = new PackageConfig.Builder("parent")
+                .strictMethodInvocation(false)
+                .build();
+
+        // when
+        PackageConfig child = new PackageConfig.Builder("child")
+                .addParent(parent)
+                .build();
+
+        // then
+        assertTrue(child.isStrictMethodInvocation());
+    }
+
+    public void testStrictDMIInheritanceDisabledInBothPackage() {
+        // given
+        PackageConfig parent = new PackageConfig.Builder("parent")
+                .strictMethodInvocation(false)
+                .build();
+
+        // when
+        PackageConfig child = new PackageConfig.Builder("child")
+                .addParent(parent)
+                .strictMethodInvocation(false)
+                .build();
+
+        // then
+        assertFalse(child.isStrictMethodInvocation());
+    }
+
+    public void testStrictDMIInheritanceDisabledInChildPackage() {
+        // given
+        PackageConfig parent = new PackageConfig.Builder("parent").build();
+
+        // when
+        PackageConfig child = new PackageConfig.Builder("child")
+                .addParent(parent)
+                .strictMethodInvocation(false)
+                .build();
+
+        // then
+        assertFalse(child.isStrictMethodInvocation());
+    }
+
+}


Mime
View raw message