mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Simplifies checking of Strict DMI to simple getter
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -30,5 +30,63 @@ public class PackageConfigTest extends XWorkTestCase {
|
||||
|
||||
assertEquals("ref2", cfg.getFullDefaultInterceptorRef());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user