Commits

Anonymous committed 9fdcf24

WW-3024 Replace "/" by "-" in aliases when looking for XML validation files

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

Comments (0)

Files changed (3)

src/java/com/opensymphony/xwork2/validator/AnnotationActionValidatorManager.java

     }
 
     private  List<ValidatorConfig> buildAliasValidatorConfigs(Class aClass, String context, boolean checkFile) {
-        String fileName = aClass.getName().replace('.', '/') + "-" + context + VALIDATION_CONFIG_SUFFIX;
+        String fileName = aClass.getName().replace('.', '/') + "-" + context.replace('/', '-') + VALIDATION_CONFIG_SUFFIX;
 
         return loadFile(fileName, aClass, checkFile);
     }

src/test/com/opensymphony/xwork2/SimpleAction-some-alias-validation.xml

+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd">
+<validators>
+    <field name="baz">
+        <field-validator type="required">
+            <message>You must enter a value for baz.</message>
+        </field-validator>
+        <field-validator type="int">
+            <param name="min">2</param>
+            <param name="max">4</param>
+            <message>baz out of range.</message>
+        </field-validator>
+    </field>
+</validators>

src/test/com/opensymphony/xwork2/validator/AnnotationActionValidatorManagerTest.java

 import com.opensymphony.xwork2.AnnotatedTestBean;
 import com.opensymphony.xwork2.SimpleAnnotationAction;
 import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.SimpleAction;
 import com.opensymphony.xwork2.test.AnnotationDataAware2;
 import com.opensymphony.xwork2.test.AnnotationUser;
 import com.opensymphony.xwork2.test.SimpleAnnotationAction2;
         assertFalse(validatorList.size() == validatorList2.size());
     }
 
+    public void testSameAliasWithAliasWithSlashes() {
+        List validatorList = annotationActionValidatorManager.getValidators(SimpleAction.class, "some/alias");
+        assertNotNull(validatorList);
+        assertEquals(11, validatorList.size());
+    }
+
     public void testSkipUserMarkerActionLevelShortCircuit() {
         // get validators
         List validatorList = annotationActionValidatorManager.getValidators(AnnotationUser.class, null);