struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnenn...@apache.org
Subject [03/10] struts git commit: added testcase for action with method prefixed by 'do'
Date Fri, 12 Jun 2015 08:53:33 GMT
added testcase for action with method prefixed by 'do'

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

Branch: refs/heads/master
Commit: f20570a470d3d1d6e3c5c26437d1b7b4031fc81f
Parents: c82b4d9
Author: cnenning <cnenning@apache.org>
Authored: Wed Jun 10 14:50:16 2015 +0200
Committer: cnenning <cnenning@apache.org>
Committed: Wed Jun 10 14:50:16 2015 +0200

----------------------------------------------------------------------
 .../BeanValidationInterceptorTest.java          | 15 +++++++++++++
 .../actions/FieldActionDoExecute.java           | 23 ++++++++++++++++++++
 .../src/test/resources/bean-validation-test.xml |  4 ++++
 3 files changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/f20570a4/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
----------------------------------------------------------------------
diff --git a/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
b/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
index 11aa135..a049061 100644
--- a/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
+++ b/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
@@ -24,7 +24,9 @@ import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+
 import org.apache.struts.beanvalidation.actions.FieldAction;
+import org.apache.struts.beanvalidation.actions.FieldActionDoExecute;
 import org.apache.struts.beanvalidation.actions.FieldMatchAction;
 import org.apache.struts.beanvalidation.actions.ModelDrivenAction;
 
@@ -133,6 +135,19 @@ public class BeanValidationInterceptorTest extends XWorkTestCase {
         assertEquals(2, actionErrors.size());
     }
 
+    public void testFieldActionDoExecute() throws Exception {
+        ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("bean-validation",
"fieldActionDoExecute", null, null);
+        FieldActionDoExecute action = (FieldActionDoExecute) baseActionProxy.getAction();
+        action.setTest(" ");
+        baseActionProxy.execute();
+
+        Map<String, List<String>> fieldErrors = ((ValidationAware) baseActionProxy.getAction()).getFieldErrors();
+
+        assertNotNull(fieldErrors);
+        assertEquals(1, fieldErrors.size());
+        assertTrue(fieldErrors.get("test").size() > 0);
+    }
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();

http://git-wip-us.apache.org/repos/asf/struts/blob/f20570a4/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/actions/FieldActionDoExecute.java
----------------------------------------------------------------------
diff --git a/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/actions/FieldActionDoExecute.java
b/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/actions/FieldActionDoExecute.java
new file mode 100644
index 0000000..8bb510e
--- /dev/null
+++ b/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/actions/FieldActionDoExecute.java
@@ -0,0 +1,23 @@
+package org.apache.struts.beanvalidation.actions;
+
+import org.hibernate.validator.constraints.NotBlank;
+
+import com.opensymphony.xwork2.ActionSupport;
+import com.opensymphony.xwork2.ValidationAwareSupport;
+
+public class FieldActionDoExecute extends ValidationAwareSupport {
+    @NotBlank(message = "canNotBeBlank")
+    private String test;
+
+    public String doExecute() {
+    	return ActionSupport.SUCCESS;
+    }
+
+    public String getTest() {
+        return test;
+    }
+
+    public void setTest(String test) {
+        this.test = test;
+    }
+}

http://git-wip-us.apache.org/repos/asf/struts/blob/f20570a4/plugins/bean-validation/src/test/resources/bean-validation-test.xml
----------------------------------------------------------------------
diff --git a/plugins/bean-validation/src/test/resources/bean-validation-test.xml b/plugins/bean-validation/src/test/resources/bean-validation-test.xml
index 3e616aa..cb44a74 100644
--- a/plugins/bean-validation/src/test/resources/bean-validation-test.xml
+++ b/plugins/bean-validation/src/test/resources/bean-validation-test.xml
@@ -34,6 +34,10 @@
             <interceptor-ref name="beanValidation"/>
             <result type="void"/>
         </action>
+        <action name="fieldActionDoExecute" class="org.apache.struts.beanvalidation.actions.FieldActionDoExecute">
+            <interceptor-ref name="beanValidation"/>
+            <result type="void"/>
+        </action>
 
     </package>
 </xwork>


Mime
View raw message