cvs commit: jakarta-commons/validator/src/test/org/apache/commons/validator MultipleTests.java
rleland 2003/08/26 09:12:47 Modified:validator/src/test/org/apache/commons/validator MultipleTests.java Log: Replace use of deprecated API elements with current API calls Revision ChangesPath 1.12 +8 -8 jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java Index: MultipleTests.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- MultipleTests.java26 Aug 2003 15:18:56 - 1.11 +++ MultipleTests.java26 Aug 2003 16:12:47 - 1.12 @@ -308,7 +308,7 @@ Validator validator = new Validator(resources, FORM_KEY); // add the name bean to the validator as a resource // for the validations to be performed on. - validator.addResource(Validator.BEAN_KEY, name); + validator.setParameter(Validator.BEAN_PARAM, name); // Get results of the validation. ValidatorResults results = null; @@ -346,7 +346,7 @@ Validator validator = new Validator(resources, FORM_KEY); // add the name bean to the validator as a resource // for the validations to be performed on. - validator.addResource(Validator.BEAN_KEY, name); + validator.setParameter(Validator.BEAN_PARAM, name); // Get results of the validation. ValidatorResults results = null; @@ -384,7 +384,7 @@ Validator validator = new Validator(resources, FORM_KEY); // add the name bean to the validator as a resource // for the validations to be performed on. - validator.addResource(Validator.BEAN_KEY, name); + validator.setParameter(Validator.BEAN_PARAM, name); // Get results of the validation. ValidatorResults results = null; @@ -423,7 +423,7 @@ Validator validator = new Validator(resources, FORM_KEY); // add the name bean to the validator as a resource // for the validations to be performed on. - validator.addResource(Validator.BEAN_KEY, name); + validator.setParameter(Validator.BEAN_PARAM, name); // Get results of the validation. ValidatorResults results = null; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/validator/src/test/org/apache/commons/validator MultipleTests.java NameBean.java TestValidator.java validator-multipletest.xml
rleland 2003/08/26 08:18:56 Modified:validator/src/test/org/apache/commons/validator MultipleTests.java NameBean.java TestValidator.java validator-multipletest.xml Log: Bug#: 22664, Patches submitted by Mammen Thomas Add unit tests to capture how dependencies between validators currently works. Thanks, will be in Validator 1.1.0 release. Revision ChangesPath 1.11 +156 -4 jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java Index: MultipleTests.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- MultipleTests.java23 Aug 2003 02:24:07 - 1.10 +++ MultipleTests.java26 Aug 2003 15:18:56 - 1.11 @@ -77,6 +77,7 @@ * pPerforms Validation Test./p * * @author James Turner + * @author Arun Mammen Thomas * @version $Revision$ $Date$ */ public class MultipleTests extends TestCase { @@ -292,5 +293,156 @@ assertTrue(Last Name ValidatorResult for the 'int' action should have passed., lastNameResult.isValid(int)); } + /** +* If middle name is not there, then the required dependent test should fail. +* No other tests should run +* +* @throws ValidatorException +*/ + public void testFailingFirstDependentValidator() throws ValidatorException { + // Create bean to run test on. + NameBean name = new NameBean(); + + // Construct validator based on the loaded resources + // and the form key + Validator validator = new Validator(resources, FORM_KEY); + // add the name bean to the validator as a resource + // for the validations to be performed on. + validator.addResource(Validator.BEAN_KEY, name); + + // Get results of the validation. + ValidatorResults results = null; + + results = validator.validate(); + + assertNotNull(Results are null., results); + + ValidatorResult middleNameResult = results.getValidatorResult(middleName); + + assertNotNull(Middle Name ValidatorResult should not be null., middleNameResult); + + assertTrue(Middle Name ValidatorResult should contain the 'required' action., middleNameResult.containsAction(required)); + assertTrue(Middle Name ValidatorResult for the 'required' action should have failed, !middleNameResult.isValid(required)); + + assertTrue(Middle Name ValidatorResult should not contain the 'int' action., !middleNameResult.containsAction(int)); + + assertTrue(Middle Name ValidatorResult should not contain the 'positive' action., !middleNameResult.containsAction(positive)); + } + + /** +* If middle name is there but not int, then the required dependent test +* should pass, but the int dependent test should fail. No other tests should +* run. +* +* @throws ValidatorException +*/ + public void testFailingNextDependentValidator() throws ValidatorException { + // Create bean to run test on. + NameBean name = new NameBean(); + name.setMiddleName(TEST); + + // Construct validator based on the loaded resources + // and the form key + Validator validator = new Validator(resources, FORM_KEY); + // add the name bean to the validator as a resource + // for the validations to be performed on. + validator.addResource(Validator.BEAN_KEY, name); + + // Get results of the validation. + ValidatorResults results = null; + + results = validator.validate(); + + assertNotNull(Results are null., results); + + ValidatorResult middleNameResult = results.getValidatorResult(middleName); + + assertNotNull(Middle Name ValidatorResult should not be null., middleNameResult); + + assertTrue(Middle Name ValidatorResult should contain the 'required' action., middleNameResult.containsAction(required)); + assertTrue(Middle Name ValidatorResult for the 'required' action should have passed, middleNameResult.isValid(required)); + + assertTrue(Middle Name ValidatorResult should contain the 'int' action., middleNameResult.containsAction(int)); + assertTrue(Middle Name ValidatorResult for the 'int' action should have failed, !middleNameResult.isValid(int)); + + assertTrue(Middle Name ValidatorResult should not contain the 'positive' action., !middleNameResult.containsAction(positive)); + } + /** +* If middle name is there and a negative int, then the required and int +* dependent tests should pass, but the positive test should fail. +* +* @throws
cvs commit: jakarta-commons/validator/src/test/org/apache/commons/validator MultipleTests.java TypeTest.java DoubleTest.java ByteTest.java LongTest.java FloatTest.java IntegerTest.java LocaleTest.java ShortTest.java RequiredIfTest.java EmailTest.java
dgraham 2003/08/03 10:39:11 Modified:validator/src/test/org/apache/commons/validator MultipleTests.java TypeTest.java DoubleTest.java ByteTest.java LongTest.java FloatTest.java IntegerTest.java LocaleTest.java ShortTest.java RequiredIfTest.java EmailTest.java Log: javadoc fixes only. Revision ChangesPath 1.8 +5 -5 jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java Index: MultipleTests.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- MultipleTests.java28 May 2003 04:28:00 - 1.7 +++ MultipleTests.java3 Aug 2003 17:39:11 - 1.8 @@ -126,7 +126,7 @@ /** * Load codeValidatorResources/code from -* validator-name-required.xml. +* validator-multipletest.xml. */ protected void setUp() throws IOException { // Load resources 1.10 +5 -5 jakarta-commons/validator/src/test/org/apache/commons/validator/TypeTest.java Index: TypeTest.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/TypeTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TypeTest.java 28 May 2003 04:28:00 - 1.9 +++ TypeTest.java 3 Aug 2003 17:39:11 - 1.10 @@ -129,7 +129,7 @@ /** * Load codeValidatorResources/code from -* validator-name-required.xml. +* validator-type.xml. */ protected void setUp() throws IOException { // Load resources 1.9 +5 -5 jakarta-commons/validator/src/test/org/apache/commons/validator/DoubleTest.java Index: DoubleTest.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/DoubleTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DoubleTest.java 28 May 2003 04:27:59 - 1.8 +++ DoubleTest.java 3 Aug 2003 17:39:11 - 1.9 @@ -127,7 +127,7 @@ /** * Load codeValidatorResources/code from -* validator-name-required.xml. +* validator-numeric.xml. */ protected void setUp() throws IOException { // Load resources 1.9 +5 -5 jakarta-commons/validator/src/test/org/apache/commons/validator/ByteTest.java Index: ByteTest.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/ByteTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ByteTest.java 28 May 2003 04:28:00 - 1.8 +++ ByteTest.java 3 Aug 2003 17:39:11 - 1.9 @@ -127,7 +127,7 @@ /** * Load codeValidatorResources/code from -* validator-name-required.xml. +* validator-numeric.xml. */ protected void setUp() throws IOException { // Load resources 1.9 +5 -5 jakarta-commons/validator/src/test/org/apache/commons/validator/LongTest.java Index: LongTest.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/LongTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- LongTest.java 28 May 2003 04:28:00 - 1.8 +++ LongTest.java 3 Aug 2003 17:39:11 - 1.9 @@ -127,7 +127,7 @@ /** * Load codeValidatorResources/code from -* validator-name-required.xml. +* validator-numeric.xml. */ protected void setUp() throws IOException { // Load resources 1.9 +5 -5 jakarta-commons/validator/src/test/org/apache/commons/validator/FloatTest.java Index: FloatTest.java === RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/FloatTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- FloatTest.java28 May 2003 04:28:00 - 1.8 +++ FloatTest.java3 Aug 2003 17:39:11 - 1.9 @@ -127,7 +127,7 @@ /** * Load codeValidatorResources/code from -* validator-name-required.xml. +* validator-numeric.xml. */ protected void setUp() throws IOException { // Load resources 1.9 +5 -5