1. opensymphony
  2. xwork

Commits

mrdon  committed 2254a25

Fix test failures by new missing result exception and error message
WW-420

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1147e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 82439fe
  • Branches master

Comments (0)

Files changed (5)

File src/java/com/opensymphony/xwork2/xwork-messages.properties

View file
 #
 
 xwork.error.action.execution=Error during Action invocation
-xwork.exception.missing-action=There is no Action mapped for action name {0}. 
+xwork.exception.missing-action=There is no Action mapped for action name {0}.
 xwork.exception.missing-package-action=There is no Action mapped for namespace {0} and action name {1}.
 xwork.default.invalid.fieldvalue=Invalid field value for field "{0}".
 

File src/test/com/opensymphony/xwork2/ActionNestingTest.java

View file
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.mock.MockResult;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
         public void init(Configuration configurationManager) {
             PackageConfig packageContext = new PackageConfig("nestedActionTest");
             ActionConfig config = new ActionConfig(null, SimpleAction.class, null, null, null);
+            config.addResultConfig(new ResultConfig(Action.SUCCESS, MockResult.class.getName()));
+            config.addResultConfig(new ResultConfig(Action.ERROR, MockResult.class.getName()));
             config.setPackageName("nestedActionTest");
             packageContext.addActionConfig(SIMPLE_ACTION_NAME, config);
             config = new ActionConfig("noStack", com.opensymphony.xwork2.NestedAction.class, null, null, null);
+            config.addResultConfig(new ResultConfig(Action.SUCCESS, MockResult.class.getName()));
             config.setPackageName("nestedActionTest");
             packageContext.addActionConfig(NO_STACK_ACTION_NAME, config);
             config = new ActionConfig("stack", com.opensymphony.xwork2.NestedAction.class, null, null, null);
+            config.addResultConfig(new ResultConfig(Action.SUCCESS, MockResult.class.getName()));
             config.setPackageName("nestedActionTest");
             packageContext.addActionConfig(STACK_ACTION_NAME, config);
             packageContext.setNamespace(NAMESPACE);

File src/test/com/opensymphony/xwork2/config/providers/MockConfigurationProvider.java

View file
  */
 package com.opensymphony.xwork2.config.providers;
 
+import com.opensymphony.xwork2.Action;
 import com.opensymphony.xwork2.ActionChainResult;
 import com.opensymphony.xwork2.ModelDrivenAction;
 import com.opensymphony.xwork2.SimpleAction;
 import com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor;
 import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
 import com.opensymphony.xwork2.interceptor.StaticParametersInterceptor;
+import com.opensymphony.xwork2.mock.MockResult;
 import com.opensymphony.xwork2.validator.ValidationInterceptor;
 
 import java.util.ArrayList;
         results.put("success", new ResultConfig("success", ActionChainResult.class.getName(), successParams));
 
         ActionConfig fooActionConfig = new ActionConfig(null, SimpleAction.class, params, results, null);
+        fooActionConfig.addResultConfig(new ResultConfig(Action.ERROR, MockResult.class.getName()));
         fooActionConfig.setPackageName("defaultPackage");
         defaultPackageContext.addActionConfig(FOO_ACTION_NAME, fooActionConfig);
 
         interceptors.add(new InterceptorMapping("params", new ParametersInterceptor()));
 
         ActionConfig paramInterceptorActionConfig = new ActionConfig(null, SimpleAction.class, null, results, interceptors);
+        paramInterceptorActionConfig.addResultConfig(new ResultConfig(Action.ERROR, MockResult.class.getName()));
         paramInterceptorActionConfig.setPackageName("defaultPackage");
         defaultPackageContext.addActionConfig(PARAM_INTERCEPTOR_ACTION_NAME, paramInterceptorActionConfig);
 
         interceptors.add(new InterceptorMapping("params", new ParametersInterceptor()));
 
         ActionConfig modelParamActionConfig = new ActionConfig(null, ModelDrivenAction.class, null, null, interceptors);
+        modelParamActionConfig.addResultConfig(new ResultConfig(Action.SUCCESS, MockResult.class.getName()));
         modelParamActionConfig.setPackageName("defaultPackage");
         defaultPackageContext.addActionConfig(MODEL_DRIVEN_PARAM_TEST, modelParamActionConfig);
         
         params.put("percentage", new Double(100.0123));
 
         ActionConfig validationActionConfig = new ActionConfig(null, SimpleAction.class, params, results, interceptors);
+        validationActionConfig.addResultConfig(new ResultConfig(Action.ERROR, MockResult.class.getName()));
         validationActionConfig.setPackageName("defaultPackage");
         defaultPackageContext.addActionConfig(VALIDATION_ACTION_NAME, validationActionConfig);
         defaultPackageContext.addActionConfig(VALIDATION_ALIAS_NAME, validationActionConfig);
 
         // We need this actionconfig to be the final destination for action chaining
         ActionConfig barActionConfig = new ActionConfig(null, SimpleAction.class, null, null, null);
+        barActionConfig.addResultConfig(new ResultConfig(Action.ERROR, MockResult.class.getName()));
         barActionConfig.setPackageName("defaultPackage");
         defaultPackageContext.addActionConfig("bar", barActionConfig);
 

File src/test/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java

View file
 
     public void testParameterizedDefaultMessage() throws Exception {
         String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_ACTION_EXCEPTION, Locale.getDefault(), new String[]{"AddUser"});
-        assertEquals("There is no Action mapped for action name AddUser. Check if there is such an action name defined in xwork.xml and also if the such an action class exists. Check also the log to see if the action class is successfully loaded.", message);
+        assertEquals("There is no Action mapped for action name AddUser.", message);
     }
 
     public void testParameterizedDefaultMessageWithPackage() throws Exception {
         String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, Locale.getDefault(), new String[]{"blah", "AddUser"});
-        assertEquals("There is no Action mapped for namespace blah and action name AddUser. Check if there is such an action name with such namespace defined in the xwork.xml and also if such an action class exists. Check also the log to see if the action class is successfully loaded.", message);
+        assertEquals("There is no Action mapped for namespace blah and action name AddUser.", message);
     }
 
     public void testLocalizedDateFormatIsUsed() {

File src/test/xwork-sample.xml

View file
            	<param name="aliases">#{ "aliasSource" : "aliasDest", "bar":"baz" }</param>
 			<interceptor-ref name="defaultStack"/>
          	<interceptor-ref name="alias"/>
+         	<result name="success" type="mock" />
         </action>
       
         <action name="packagelessAction" class="PackagelessAction">
         <action name="Bar" class="com.opensymphony.xwork2.SimpleAction">
         	<param name="foo">17</param>
             <param name="bar">23</param>
+            <result name="error" type="mock" />
         </action>
 
         <action name="MyBean" class="com.opensymphony.xwork2.util.MyBeanAction">
             <interceptor-ref name="debugStack"/>
             <interceptor-ref name="defaultStack"/>
+            <result name="success" type="mock" />
         </action>
 
         <action name="TestInterceptorParam" class="com.opensymphony.xwork2.SimpleAction">
             <interceptor-ref name="test">
                 <param name="expectedFoo">expectedFoo</param>
             </interceptor-ref>
+            <result name="error" type="mock" />
         </action>
 
         <action name="TestInterceptorParamOverride" class="com.opensymphony.xwork2.SimpleAction">
                 <param name="foo">foo123</param>
                 <param name="expectedFoo">foo123</param>
             </interceptor-ref>
+            <result name="error" type="mock" />
         </action>
-
+	
         <action name="TestModelDrivenValidation" class="com.opensymphony.xwork2.ModelDrivenAction">
             <interceptor-ref name="defaultStack"/>
             <interceptor-ref name="validation"/>
+            <result name="success" type="mock" />
         </action>
         <!-- test resolution  -->
         <action name="TestExternalRefResolver" class="com.opensymphony.xwork2.ExternalReferenceAction">
                 <external-ref name="foo">myFoo</external-ref>
             <interceptor-ref name="debugStack"/>
             <interceptor-ref name="defaultStack"/>
+            <result name="success" type="mock" />
         </action>
         <!-- test required flag -->
         <action name="TestExternalRefResolver2" class="com.opensymphony.xwork2.ExternalReferenceAction">
                 <external-ref required="false" name="does_not_exist">Does Not Exist</external-ref>
             <interceptor-ref name="debugStack"/>
             <interceptor-ref name="defaultStack"/>
+            <result name="success" type="mock" />
         </action>
         <!-- test where required reference is not found -->
         <action name="TestExternalRefResolver3" class="com.opensymphony.xwork2.ExternalReferenceAction">
         <action name="TestExternalRefResolver4" class="com.opensymphony.xwork2.ExternalReferenceAction">
                 <external-ref name="foo">myFoo</external-ref>
             <interceptor-ref name="defaultStack"/>
+            <result name="success" type="mock" />
         </action>
 
    </package>
 
         <action name="Bar" class="com.opensymphony.xwork2.SimpleAction">
             <interceptor-ref name="barDefaultStack"/>
+            <result name="error" type="mock" />
         </action>
 
         <action name="TestInterceptorParamInheritance" class="com.opensymphony.xwork2.SimpleAction">
             <interceptor-ref name="test">
                 <param name="expectedFoo">expectedFoo</param>
             </interceptor-ref>
+            <result name="error" type="mock" />
         </action>
 
         <action name="TestInterceptorParamInehritanceOverride" class="com.opensymphony.xwork2.SimpleAction">
                 <param name="foo">foo123</param>
                 <param name="expectedFoo">foo123</param>
             </interceptor-ref>
+            <result name="error" type="mock" />
         </action>
     </package>
 
             <result name="error" type="chain">
                 <param name="actionName">bar</param>
             </result>
+            <result name="success" type="mock" />
             <interceptor-ref name="static-params"/>
         </action>
         <action name="myCommand" class="com.opensymphony.xwork2.SimpleAction" method="commandMethod">
             <result name="success" type="chain">
                 <param name="actionName">foo</param>
             </result>
+            <result name="com.opensymphony.xwork2.SimpleAction.CommandInvoked" type="mock"/>
             <interceptor-ref name="logger"/>
         </action>
     </package>