You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2022/10/14 10:03:07 UTC
[struts] branch WW-5241-exec-and-wait updated: WW-5241 Adds test cases to cover checking namespace, action and method names
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch WW-5241-exec-and-wait
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/WW-5241-exec-and-wait by this push:
new 9dd256017 WW-5241 Adds test cases to cover checking namespace, action and method names
9dd256017 is described below
commit 9dd2560172c377ce182c47ef11a0c4529f4347c9
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Fri Oct 14 12:03:02 2022 +0200
WW-5241 Adds test cases to cover checking namespace, action and method names
---
.../dispatcher/mapper/DefaultActionMapperTest.java | 74 ++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java b/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
index 289e92751..0c3a592d2 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
@@ -896,4 +896,78 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
assertEquals(mapper.defaultMethodName, mapper.cleanupMethodName("${#foo='method',#foo}"));
}
+ public void testTestAllowedNamespaceName() {
+ // give
+ DefaultActionMapper mapper = new DefaultActionMapper();
+ mapper.setAllowedNamespaceNames("[a-z/]*");
+
+ // when
+ String result = mapper.cleanupNamespaceName("/ns");
+
+ // then
+ assertEquals("/ns", result);
+ }
+
+ public void testTestAllowedNamespaceNameAndFallbackToDefault() {
+ // give
+ DefaultActionMapper mapper = new DefaultActionMapper();
+ mapper.setAllowedNamespaceNames("[a-z/]*");
+ mapper.setDefaultNamespaceName("/ns");
+
+ // when
+ String result = mapper.cleanupNamespaceName("/ns2");
+
+ // then
+ assertEquals("/ns", result);
+ }
+
+ public void testTestAllowedActionName() {
+ // give
+ DefaultActionMapper mapper = new DefaultActionMapper();
+ mapper.setAllowedActionNames("[a-z]*");
+
+ // when
+ String result = mapper.cleanupActionName("action");
+
+ // then
+ assertEquals("action", result);
+ }
+
+ public void testTestAllowedActionNameAndFallbackToDefault() {
+ // give
+ DefaultActionMapper mapper = new DefaultActionMapper();
+ mapper.setAllowedActionNames("[a-z]*");
+ mapper.setDefaultActionName("error");
+
+ // when
+ String result = mapper.cleanupActionName("action2");
+
+ // then
+ assertEquals("error", result);
+ }
+
+ public void testTestAllowedMethodName() {
+ // give
+ DefaultActionMapper mapper = new DefaultActionMapper();
+ mapper.setAllowedMethodNames("[a-z]*");
+
+ // when
+ String result = mapper.cleanupMethodName("execute");
+
+ // then
+ assertEquals("execute", result);
+ }
+
+ public void testTestAllowedMethodNameAndFallbackToDefault() {
+ // give
+ DefaultActionMapper mapper = new DefaultActionMapper();
+ mapper.setAllowedMethodNames("[a-z]*");
+ mapper.setDefaultMethodName("error");
+
+ // when
+ String result = mapper.cleanupMethodName("execute2");
+
+ // then
+ assertEquals("error", result);
+ }
}