You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ni...@apache.org on 2005/10/04 05:16:07 UTC
svn commit: r293502 - in
/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator:
MultipleConfigFilesTest.java validator-multiple-config-1.xml
validator-multiple-config-2.xml
Author: niallp
Date: Mon Oct 3 20:15:56 2005
New Revision: 293502
URL: http://svn.apache.org/viewcvs?rev=293502&view=rev
Log:
Test that multiple config files are merged correctly.
Modified:
jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/MultipleConfigFilesTest.java
jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-1.xml
jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-2.xml
Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/MultipleConfigFilesTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/MultipleConfigFilesTest.java?rev=293502&r1=293501&r2=293502&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/MultipleConfigFilesTest.java (original)
+++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/MultipleConfigFilesTest.java Mon Oct 3 20:15:56 2005
@@ -76,6 +76,53 @@
}
}
+ /**
+ * Check the forms and constants from different config files have
+ * been merged into the same FormSet.
+ */
+ public void testMergedConfig() throws ValidatorException {
+
+ // *********** Default Locale *******************
+
+ // Check the form from the first config file exists
+ Form form1 = resources.getForm("", "", "", "testForm1");
+ assertNotNull("Form 'testForm1' not found", form1);
+
+ // Check the form from the second config file exists
+ Form form2 = resources.getForm("", "", "", "testForm2");
+ assertNotNull("Form 'testForm2' not found", form2);
+
+ // Check the Constants for the form from the first config file
+ Field field1 = form1.getField("testProperty1");
+ assertEquals("testProperty1 - const 1", "testConstValue1", field1.getVarValue("var11"));
+ assertEquals("testProperty1 - const 2", "testConstValue2", field1.getVarValue("var12"));
+
+ // Check the Constants for the form from the second config file
+ Field field2 = form2.getField("testProperty2");
+ assertEquals("testProperty2 - const 1", "testConstValue1", field2.getVarValue("var21"));
+ assertEquals("testProperty2 - const 2", "testConstValue2", field2.getVarValue("var22"));
+
+ // *********** 'fr' locale *******************
+
+ // Check the form from the first config file exists
+ Form form1_fr = resources.getForm("fr", "", "", "testForm1_fr");
+ assertNotNull("Form 'testForm1_fr' not found", form1_fr);
+
+ // Check the form from the second config file exists
+ Form form2_fr = resources.getForm("fr", "", "", "testForm2_fr");
+ assertNotNull("Form 'testForm2_fr' not found", form2_fr);
+
+ // Check the Constants for the form from the first config file
+ Field field1_fr = form1_fr.getField("testProperty1_fr");
+ assertEquals("testProperty1_fr - const 1", "testConstValue1_fr", field1_fr.getVarValue("var11_fr"));
+ assertEquals("testProperty1_fr - const 2", "testConstValue2_fr", field1_fr.getVarValue("var12_fr"));
+
+ // Check the Constants for the form from the second config file
+ Field field2_fr = form2_fr.getField("testProperty2_fr");
+ assertEquals("testProperty2_fr - const 1", "testConstValue1_fr", field2_fr.getVarValue("var21_fr"));
+ assertEquals("testProperty2_fr - const 2", "testConstValue2_fr", field2_fr.getVarValue("var22_fr"));
+ }
+
/**
* With nothing provided, we should fail both because both are required.
*/
Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-1.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-1.xml?rev=293502&r1=293501&r2=293502&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-1.xml (original)
+++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-1.xml Mon Oct 3 20:15:56 2005
@@ -20,4 +20,49 @@
methodParams="java.lang.Object,org.apache.commons.validator.Field"
msg=""/>
</global>
+
+ <formset>
+
+ <constant>
+ <constant-name>testConstName1</constant-name>
+ <constant-value>testConstValue1</constant-value>
+ </constant>
+
+ <form name="testForm1">
+ <field property="testProperty1" depends="required">
+ <var>
+ <var-name>var11</var-name>
+ <var-value>${testConstName1}</var-value>
+ </var>
+ <var>
+ <var-name>var12</var-name>
+ <var-value>${testConstName2}</var-value>
+ </var>
+ </field>
+ </form>
+
+ </formset>
+
+ <formset language="fr">
+
+ <constant>
+ <constant-name>testConstName1_fr</constant-name>
+ <constant-value>testConstValue1_fr</constant-value>
+ </constant>
+
+ <form name="testForm1_fr">
+ <field property="testProperty1_fr" depends="required">
+ <var>
+ <var-name>var11_fr</var-name>
+ <var-value>${testConstName1_fr}</var-value>
+ </var>
+ <var>
+ <var-name>var12_fr</var-name>
+ <var-value>${testConstName2_fr}</var-value>
+ </var>
+ </field>
+ </form>
+
+ </formset>
+
</form-validation>
Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-2.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-2.xml?rev=293502&r1=293501&r2=293502&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-2.xml (original)
+++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-multiple-config-2.xml Mon Oct 3 20:15:56 2005
@@ -7,6 +7,12 @@
-->
<form-validation>
<formset>
+
+ <constant>
+ <constant-name>testConstName2</constant-name>
+ <constant-value>testConstValue2</constant-value>
+ </constant>
+
<form name="nameForm">
<field property="firstName" depends="required">
<arg key="nameForm.firstname.displayname"/>
@@ -15,5 +21,42 @@
<arg key="nameForm.lastname.displayname"/>
</field>
</form>
+
+ <form name="testForm2">
+ <field property="testProperty2" depends="required">
+ <var>
+ <var-name>var21</var-name>
+ <var-value>${testConstName1}</var-value>
+ </var>
+ <var>
+ <var-name>var22</var-name>
+ <var-value>${testConstName2}</var-value>
+ </var>
+ </field>
+ </form>
+
+ </formset>
+
+ <formset language="fr">
+
+ <constant>
+ <constant-name>testConstName2_fr</constant-name>
+ <constant-value>testConstValue2_fr</constant-value>
+ </constant>
+
+ <form name="testForm2_fr">
+ <field property="testProperty2_fr" depends="required">
+ <var>
+ <var-name>var21_fr</var-name>
+ <var-value>${testConstName1_fr}</var-value>
+ </var>
+ <var>
+ <var-name>var22_fr</var-name>
+ <var-value>${testConstName2_fr}</var-value>
+ </var>
+ </field>
+ </form>
+
</formset>
+
</form-validation>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org