commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mart...@apache.org
Subject cvs commit: jakarta-commons/validator/src/test/org/apache/commons/validator ByteTest.java DoubleTest.java EmailTest.java FloatTest.java IntegerTest.java LongTest.java NameBean.java RequiredNameTest.java ShortTest.java TestTypeValidator.java TypeBean.java TypeTest.java ValidatorTest.java ValueBean.java
Date Sun, 15 Dec 2002 20:58:57 GMT
martinc     2002/12/15 12:58:57

  Modified:    validator/src/test/org/apache/commons/validator
                        ByteTest.java DoubleTest.java EmailTest.java
                        FloatTest.java IntegerTest.java LongTest.java
                        NameBean.java RequiredNameTest.java ShortTest.java
                        TestTypeValidator.java TypeBean.java TypeTest.java
                        ValidatorTest.java ValueBean.java
  Log:
  Fix line ends.
  
  Revision  Changes    Path
  1.2       +248 -248  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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ByteTest.java	30 Mar 2002 04:26:51 -0000	1.1
  +++ ByteTest.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,249 +1,249 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for <code>byte</code> validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class ByteTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "byteForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "byte";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public ByteTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {ByteTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(ByteTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the byte validation.
  -   */
  -   public void testByte() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue("0");
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the byte validation.
  -   */
  -   public void testByteMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Byte(Byte.MIN_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the byte validation.
  -   */
  -   public void testByteMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Byte(Byte.MAX_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the byte validation failure.
  -   */
  -   public void testByteFailure() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      
  -      valueTest(info, false);
  -   }
  -
  -   /**
  -    * Tests the byte validation failure.
  -   */
  -   public void testByteBeyondMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Byte.MIN_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Tests the byte validation failure.
  -   */
  -   public void testByteBeyondMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Byte.MAX_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Utlity class to run a test on a value.
  -    *
  -    * @param	info	Value to run test on.
  -    * @param	passed	Whether or not the test is expected to pass.
  -   */
  -   private void valueTest(Object info, boolean passed) throws ValidatorException {
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult result = results.getValidatorResult("value");
  -
  -      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -   }
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for <code>byte</code> validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class ByteTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "byteForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "byte";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public ByteTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {ByteTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(ByteTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the byte validation.
  +   */
  +   public void testByte() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue("0");
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the byte validation.
  +   */
  +   public void testByteMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Byte(Byte.MIN_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the byte validation.
  +   */
  +   public void testByteMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Byte(Byte.MAX_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the byte validation failure.
  +   */
  +   public void testByteFailure() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      
  +      valueTest(info, false);
  +   }
  +
  +   /**
  +    * Tests the byte validation failure.
  +   */
  +   public void testByteBeyondMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Byte.MIN_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Tests the byte validation failure.
  +   */
  +   public void testByteBeyondMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Byte.MAX_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Utlity class to run a test on a value.
  +    *
  +    * @param	info	Value to run test on.
  +    * @param	passed	Whether or not the test is expected to pass.
  +   */
  +   private void valueTest(Object info, boolean passed) throws ValidatorException {
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult result = results.getValidatorResult("value");
  +
  +      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +   }
   }                                                         
  
  
  
  1.2       +226 -226  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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DoubleTest.java	30 Mar 2002 04:26:51 -0000	1.1
  +++ DoubleTest.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,227 +1,227 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for <code>double</code> validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class DoubleTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "doubleForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "double";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public DoubleTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {DoubleTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(DoubleTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the double validation.
  -   */
  -   public void testDouble() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue("0");
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the double validation.
  -   */
  -   public void testDoubleMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Double(Double.MIN_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the double validation.
  -   */
  -   public void testDoubleMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Double(Double.MAX_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the double validation failure.
  -   */
  -   public void testDoubleFailure() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Utlity class to run a test on a value.
  -    *
  -    * @param	info	Value to run test on.
  -    * @param	passed	Whether or not the test is expected to pass.
  -   */
  -   private void valueTest(Object info, boolean passed) throws ValidatorException {
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult result = results.getValidatorResult("value");
  -
  -      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -   }
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for <code>double</code> validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class DoubleTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "doubleForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "double";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public DoubleTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {DoubleTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(DoubleTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the double validation.
  +   */
  +   public void testDouble() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue("0");
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the double validation.
  +   */
  +   public void testDoubleMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Double(Double.MIN_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the double validation.
  +   */
  +   public void testDoubleMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Double(Double.MAX_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the double validation failure.
  +   */
  +   public void testDoubleFailure() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Utlity class to run a test on a value.
  +    *
  +    * @param	info	Value to run test on.
  +    * @param	passed	Whether or not the test is expected to pass.
  +   */
  +   private void valueTest(Object info, boolean passed) throws ValidatorException {
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult result = results.getValidatorResult("value");
  +
  +      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +   }
   }                                                         
  
  
  
  1.3       +233 -233  jakarta-commons/validator/src/test/org/apache/commons/validator/EmailTest.java
  
  Index: EmailTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/EmailTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EmailTest.java	19 Jul 2002 03:09:06 -0000	1.2
  +++ EmailTest.java	15 Dec 2002 20:58:57 -0000	1.3
  @@ -1,233 +1,233 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for e-mail validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class EmailTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "emailForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "email";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public EmailTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {EmailTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(EmailTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-regexp.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the e-mail validation.
  -   */
  -   public void testEmail() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -
  -      info.setValue("jsmith@apache.org");
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the e-mail validation.
  -   */
  -   public void testEmailExtension() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -
  -      info.setValue("jsmith@apache.org");
  -      valueTest(info, true);
  -
  -      info.setValue("jsmith@apache.com");
  -      valueTest(info, true);
  -
  -      info.setValue("jsmith@apache.net");
  -      valueTest(info, true);
  -
  -      info.setValue("jsmith@apache.info");
  -      valueTest(info, true);
  -
  -   }
  -
  -   /**
  -    * <p>Tests the e-mail validation with a dash in 
  -    * the address.</p>
  -   */
  -   public void testEmailWithDash() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -
  -      info.setValue("andy.noble@data-workshop.com");
  -      valueTest(info, true);
  -
  -      info.setValue("andy-noble@data-workshop.com");
  -      valueTest(info, true);
  -
  -
  -   }
  -
  -   /**
  -    * Utlity class to run a test on a value.
  -    *
  -    * @param	info	Value to run test on.
  -    * @param	passed	Whether or not the test is expected to pass.
  -   */
  -   private void valueTest(Object info, boolean passed) throws ValidatorException {
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult result = results.getValidatorResult("value");
  -
  -      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      assertTrue("ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      assertTrue("ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -   }
  -}                                                         
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for e-mail validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class EmailTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "emailForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "email";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public EmailTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {EmailTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(EmailTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-regexp.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the e-mail validation.
  +   */
  +   public void testEmail() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +
  +      info.setValue("jsmith@apache.org");
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the e-mail validation.
  +   */
  +   public void testEmailExtension() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +
  +      info.setValue("jsmith@apache.org");
  +      valueTest(info, true);
  +
  +      info.setValue("jsmith@apache.com");
  +      valueTest(info, true);
  +
  +      info.setValue("jsmith@apache.net");
  +      valueTest(info, true);
  +
  +      info.setValue("jsmith@apache.info");
  +      valueTest(info, true);
  +
  +   }
  +
  +   /**
  +    * <p>Tests the e-mail validation with a dash in 
  +    * the address.</p>
  +   */
  +   public void testEmailWithDash() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +
  +      info.setValue("andy.noble@data-workshop.com");
  +      valueTest(info, true);
  +
  +      info.setValue("andy-noble@data-workshop.com");
  +      valueTest(info, true);
  +
  +
  +   }
  +
  +   /**
  +    * Utlity class to run a test on a value.
  +    *
  +    * @param	info	Value to run test on.
  +    * @param	passed	Whether or not the test is expected to pass.
  +   */
  +   private void valueTest(Object info, boolean passed) throws ValidatorException {
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult result = results.getValidatorResult("value");
  +
  +      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      assertTrue("ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      assertTrue("ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +   }
  +}                                                         
  
  
  
  1.2       +226 -226  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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FloatTest.java	30 Mar 2002 04:26:51 -0000	1.1
  +++ FloatTest.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,227 +1,227 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for <code>float</code> validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class FloatTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "floatForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "float";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public FloatTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {FloatTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(FloatTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the float validation.
  -   */
  -   public void testFloat() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue("0");
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the float validation.
  -   */
  -   public void testFloatMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Float(Float.MIN_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the float validation.
  -   */
  -   public void testFloatMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Float(Float.MAX_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the float validation failure.
  -   */
  -   public void testFloatFailure() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      
  -      valueTest(info, false);
  -   }
  -
  -   /**
  -    * Utlity class to run a test on a value.
  -    *
  -    * @param	info	Value to run test on.
  -    * @param	passed	Whether or not the test is expected to pass.
  -   */
  -   private void valueTest(Object info, boolean passed) throws ValidatorException {
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult result = results.getValidatorResult("value");
  -
  -      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -   }
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for <code>float</code> validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class FloatTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "floatForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "float";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public FloatTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {FloatTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(FloatTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the float validation.
  +   */
  +   public void testFloat() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue("0");
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the float validation.
  +   */
  +   public void testFloatMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Float(Float.MIN_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the float validation.
  +   */
  +   public void testFloatMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Float(Float.MAX_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the float validation failure.
  +   */
  +   public void testFloatFailure() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      
  +      valueTest(info, false);
  +   }
  +
  +   /**
  +    * Utlity class to run a test on a value.
  +    *
  +    * @param	info	Value to run test on.
  +    * @param	passed	Whether or not the test is expected to pass.
  +   */
  +   private void valueTest(Object info, boolean passed) throws ValidatorException {
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult result = results.getValidatorResult("value");
  +
  +      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +   }
   }                                                         
  
  
  
  1.2       +248 -248  jakarta-commons/validator/src/test/org/apache/commons/validator/IntegerTest.java
  
  Index: IntegerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/IntegerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntegerTest.java	30 Mar 2002 04:21:03 -0000	1.1
  +++ IntegerTest.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,249 +1,249 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for <code>int</code> validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class IntegerTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "intForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "int";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public IntegerTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {IntegerTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(IntegerTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the int validation.
  -   */
  -   public void testInt() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue("0");
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the int validation.
  -   */
  -   public void testIntMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Integer(Integer.MIN_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the int validation.
  -   */
  -   public void testIntegerMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Integer(Integer.MAX_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the int validation failure.
  -   */
  -   public void testIntFailure() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      
  -      valueTest(info, false);
  -   }
  -
  -   /**
  -    * Tests the int validation failure.
  -   */
  -   public void testIntBeyondMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Integer.MIN_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Tests the int validation failure.
  -   */
  -   public void testIntBeyondMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Integer.MAX_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Utlity class to run a test on a value.
  -    *
  -    * @param	info	Value to run test on.
  -    * @param	passed	Whether or not the test is expected to pass.
  -   */
  -   private void valueTest(Object info, boolean passed) throws ValidatorException {
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult result = results.getValidatorResult("value");
  -
  -      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -   }
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for <code>int</code> validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class IntegerTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "intForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "int";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public IntegerTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {IntegerTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(IntegerTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the int validation.
  +   */
  +   public void testInt() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue("0");
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the int validation.
  +   */
  +   public void testIntMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Integer(Integer.MIN_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the int validation.
  +   */
  +   public void testIntegerMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Integer(Integer.MAX_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the int validation failure.
  +   */
  +   public void testIntFailure() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      
  +      valueTest(info, false);
  +   }
  +
  +   /**
  +    * Tests the int validation failure.
  +   */
  +   public void testIntBeyondMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Integer.MIN_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Tests the int validation failure.
  +   */
  +   public void testIntBeyondMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Integer.MAX_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Utlity class to run a test on a value.
  +    *
  +    * @param	info	Value to run test on.
  +    * @param	passed	Whether or not the test is expected to pass.
  +   */
  +   private void valueTest(Object info, boolean passed) throws ValidatorException {
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult result = results.getValidatorResult("value");
  +
  +      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +   }
   }                                                         
  
  
  
  1.2       +248 -248  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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LongTest.java	30 Mar 2002 04:21:03 -0000	1.1
  +++ LongTest.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,249 +1,249 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for <code>long</code> validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class LongTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "longForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "long";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public LongTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {LongTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(LongTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the long validation.
  -   */
  -   public void testLong() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue("0");
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the long validation.
  -   */
  -   public void testLongMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Long(Long.MIN_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the long validation.
  -   */
  -   public void testLongMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Long(Long.MAX_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the long validation failure.
  -   */
  -   public void testLongFailure() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      
  -      valueTest(info, false);
  -   }
  -
  -   /**
  -    * Tests the long validation failure.
  -   */
  -   public void testLongBeyondMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Long.MIN_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Tests the long validation failure.
  -   */
  -   public void testLongBeyondMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Long.MAX_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Utlity class to run a test on a value.
  -    *
  -    * @param	info	Value to run test on.
  -    * @param	passed	Whether or not the test is expected to pass.
  -   */
  -   private void valueTest(Object info, boolean passed) throws ValidatorException {
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult result = results.getValidatorResult("value");
  -
  -      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -   }
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for <code>long</code> validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class LongTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "longForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "long";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public LongTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {LongTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(LongTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the long validation.
  +   */
  +   public void testLong() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue("0");
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the long validation.
  +   */
  +   public void testLongMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Long(Long.MIN_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the long validation.
  +   */
  +   public void testLongMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Long(Long.MAX_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the long validation failure.
  +   */
  +   public void testLongFailure() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      
  +      valueTest(info, false);
  +   }
  +
  +   /**
  +    * Tests the long validation failure.
  +   */
  +   public void testLongBeyondMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Long.MIN_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Tests the long validation failure.
  +   */
  +   public void testLongBeyondMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Long.MAX_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Utlity class to run a test on a value.
  +    *
  +    * @param	info	Value to run test on.
  +    * @param	passed	Whether or not the test is expected to pass.
  +   */
  +   private void valueTest(Object info, boolean passed) throws ValidatorException {
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult result = results.getValidatorResult("value");
  +
  +      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +   }
   }                                                         
  
  
  
  1.2       +105 -105  jakarta-commons/validator/src/test/org/apache/commons/validator/NameBean.java
  
  Index: NameBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/NameBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NameBean.java	30 Mar 2002 04:21:03 -0000	1.1
  +++ NameBean.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,106 +1,106 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -/**                                                       
  - * <p>Value object that contains a 
  - * first name and last name.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class NameBean {
  -   
  -   protected String firstName = null;
  -   
  -   protected String lastName = null;
  -                                                             
  -   /**
  -    * Gets the first name.
  -   */
  -   public String getFirstName() {
  -      return firstName;	
  -   }
  -
  -   /**
  -    * Sets the first name.
  -   */
  -   public void setFirstName(String firstName) {
  -      this.firstName = firstName;	
  -   }
  -
  -   /**
  -    * Gets the last name.
  -   */
  -   public String getLastName() {
  -      return lastName;	
  -   }
  -
  -   /**
  -    * Sets the last name.
  -   */
  -   public void setLastName(String lastName) {
  -      this.lastName = lastName;
  -   }
  -      
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +/**                                                       
  + * <p>Value object that contains a 
  + * first name and last name.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class NameBean {
  +   
  +   protected String firstName = null;
  +   
  +   protected String lastName = null;
  +                                                             
  +   /**
  +    * Gets the first name.
  +   */
  +   public String getFirstName() {
  +      return firstName;	
  +   }
  +
  +   /**
  +    * Sets the first name.
  +   */
  +   public void setFirstName(String firstName) {
  +      this.firstName = firstName;	
  +   }
  +
  +   /**
  +    * Gets the last name.
  +   */
  +   public String getLastName() {
  +      return lastName;	
  +   }
  +
  +   /**
  +    * Sets the last name.
  +   */
  +   public void setLastName(String lastName) {
  +      this.lastName = lastName;
  +   }
  +      
   }                                                         
  
  
  
  1.4       +361 -361  jakarta-commons/validator/src/test/org/apache/commons/validator/RequiredNameTest.java
  
  Index: RequiredNameTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/RequiredNameTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequiredNameTest.java	30 Mar 2002 04:30:56 -0000	1.3
  +++ RequiredNameTest.java	15 Dec 2002 20:58:57 -0000	1.4
  @@ -1,362 +1,362 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class RequiredNameTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "nameForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "required";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public RequiredNameTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {RequiredNameTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(RequiredNameTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-name-required.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the required validation failure.
  -   */
  -   public void testRequired() 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;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult firstNameResult = results.getValidatorResult("firstName");
  -      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  -      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  -      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  -      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  -      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  -   }
  -
  -   /**
  -    * Tests the required validation for first name if it is blank.
  -   */
  -   public void testRequiredFirstNameBlank() throws ValidatorException {
  -      // Create bean to run test on.
  -      NameBean name = new NameBean();
  -      name.setFirstName("");
  -      
  -      // 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 firstNameResult = results.getValidatorResult("firstName");
  -      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  -      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  -      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  -      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  -      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  -   }
  -
  -   /**
  -    * Tests the required validation for first name.
  -   */
  -   public void testRequiredFirstName() throws ValidatorException {
  -      // Create bean to run test on.
  -      NameBean name = new NameBean();
  -      name.setFirstName("Joe");
  -      
  -      // 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 firstNameResult = results.getValidatorResult("firstName");
  -      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  -      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  -      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have passed.", firstNameResult.isValid(ACTION));
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  -      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  -      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  -   }
  -
  -   /**
  -    * Tests the required validation for last name if it is blank.
  -   */
  -   public void testRequiredLastNameBlank() throws ValidatorException {
  -      // Create bean to run test on.
  -      NameBean name = new NameBean();
  -      name.setLastName("");
  -      
  -      // 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 firstNameResult = results.getValidatorResult("firstName");
  -      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  -      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  -      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  -      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  -      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  -   }
  -
  -   /**
  -    * Tests the required validation for last name.
  -   */
  -   public void testRequiredLastName() throws ValidatorException {
  -      // Create bean to run test on.
  -      NameBean name = new NameBean();
  -      name.setLastName("Smith");
  -      
  -      // 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 firstNameResult = results.getValidatorResult("firstName");
  -      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  -      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  -      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  -      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  -      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have passed.", lastNameResult.isValid(ACTION));
  -
  -   }
  -
  -   /**
  -    * Tests the required validation for first and last name.
  -   */
  -   public void testRequiredName() throws ValidatorException {
  -      // Create bean to run test on.
  -      NameBean name = new NameBean();
  -      name.setFirstName("Joe");
  -      name.setLastName("Smith");
  -      
  -      // 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 firstNameResult = results.getValidatorResult("firstName");
  -      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  -      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  -      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have passed.", firstNameResult.isValid(ACTION));
  -      
  -      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  -      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  -      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have passed.", lastNameResult.isValid(ACTION));
  -   }
  -   
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class RequiredNameTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "nameForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "required";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public RequiredNameTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {RequiredNameTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(RequiredNameTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-name-required.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the required validation failure.
  +   */
  +   public void testRequired() 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;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult firstNameResult = results.getValidatorResult("firstName");
  +      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  +      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  +      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  +      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  +      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  +   }
  +
  +   /**
  +    * Tests the required validation for first name if it is blank.
  +   */
  +   public void testRequiredFirstNameBlank() throws ValidatorException {
  +      // Create bean to run test on.
  +      NameBean name = new NameBean();
  +      name.setFirstName("");
  +      
  +      // 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 firstNameResult = results.getValidatorResult("firstName");
  +      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  +      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  +      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  +      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  +      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  +   }
  +
  +   /**
  +    * Tests the required validation for first name.
  +   */
  +   public void testRequiredFirstName() throws ValidatorException {
  +      // Create bean to run test on.
  +      NameBean name = new NameBean();
  +      name.setFirstName("Joe");
  +      
  +      // 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 firstNameResult = results.getValidatorResult("firstName");
  +      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  +      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  +      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have passed.", firstNameResult.isValid(ACTION));
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  +      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  +      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  +   }
  +
  +   /**
  +    * Tests the required validation for last name if it is blank.
  +   */
  +   public void testRequiredLastNameBlank() throws ValidatorException {
  +      // Create bean to run test on.
  +      NameBean name = new NameBean();
  +      name.setLastName("");
  +      
  +      // 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 firstNameResult = results.getValidatorResult("firstName");
  +      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  +      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  +      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  +      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  +      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have failed.", !lastNameResult.isValid(ACTION));
  +   }
  +
  +   /**
  +    * Tests the required validation for last name.
  +   */
  +   public void testRequiredLastName() throws ValidatorException {
  +      // Create bean to run test on.
  +      NameBean name = new NameBean();
  +      name.setLastName("Smith");
  +      
  +      // 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 firstNameResult = results.getValidatorResult("firstName");
  +      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  +      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  +      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have failed.", !firstNameResult.isValid(ACTION));
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  +      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  +      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have passed.", lastNameResult.isValid(ACTION));
  +
  +   }
  +
  +   /**
  +    * Tests the required validation for first and last name.
  +   */
  +   public void testRequiredName() throws ValidatorException {
  +      // Create bean to run test on.
  +      NameBean name = new NameBean();
  +      name.setFirstName("Joe");
  +      name.setLastName("Smith");
  +      
  +      // 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 firstNameResult = results.getValidatorResult("firstName");
  +      ValidatorResult lastNameResult = results.getValidatorResult("lastName");
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", firstNameResult);
  +      assertTrue("First Name ValidatorResult should contain the '" + ACTION +"' action.", firstNameResult.containsAction(ACTION));
  +      assertTrue("First Name ValidatorResult for the '" + ACTION +"' action should have passed.", firstNameResult.isValid(ACTION));
  +      
  +      assertNotNull("First Name ValidatorResult should not be null.", lastNameResult);
  +      assertTrue("Last Name ValidatorResult should contain the '" + ACTION +"' action.", lastNameResult.containsAction(ACTION));
  +      assertTrue("Last Name ValidatorResult for the '" + ACTION +"' action should have passed.", lastNameResult.isValid(ACTION));
  +   }
  +   
   }                                                         
  
  
  
  1.2       +248 -248  jakarta-commons/validator/src/test/org/apache/commons/validator/ShortTest.java
  
  Index: ShortTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/ShortTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ShortTest.java	30 Mar 2002 04:21:03 -0000	1.1
  +++ ShortTest.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,249 +1,249 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for <code>short</code> validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class ShortTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "shortForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "short";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public ShortTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {ShortTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(ShortTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the short validation.
  -   */
  -   public void testShort() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue("0");
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the short validation.
  -   */
  -   public void testShortMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Short(Short.MIN_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the short validation.
  -   */
  -   public void testShortMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(new Short(Short.MAX_VALUE).toString());
  -      
  -      valueTest(info, true);
  -   }
  -
  -   /**
  -    * Tests the short validation failure.
  -   */
  -   public void testShortFailure() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      
  -      valueTest(info, false);
  -   }
  -
  -   /**
  -    * Tests the short validation failure.
  -   */
  -   public void testShortBeyondMin() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Short.MIN_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Tests the short validation failure.
  -   */
  -   public void testShortBeyondMax() throws ValidatorException {
  -      // Create bean to run test on.
  -      ValueBean info = new ValueBean();
  -      info.setValue(Short.MAX_VALUE + "1");
  -      
  -      valueTest(info, false);
  -   }
  -   
  -   /**
  -    * Utlity class to run a test on a value.
  -    *
  -    * @param	info	Value to run test on.
  -    * @param	passed	Whether or not the test is expected to pass.
  -   */
  -   private void valueTest(Object info, boolean passed) throws ValidatorException {
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      ValidatorResult result = results.getValidatorResult("value");
  -
  -      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -   }
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for <code>short</code> validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class ShortTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "shortForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "short";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public ShortTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {ShortTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(ShortTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the short validation.
  +   */
  +   public void testShort() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue("0");
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the short validation.
  +   */
  +   public void testShortMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Short(Short.MIN_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the short validation.
  +   */
  +   public void testShortMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(new Short(Short.MAX_VALUE).toString());
  +      
  +      valueTest(info, true);
  +   }
  +
  +   /**
  +    * Tests the short validation failure.
  +   */
  +   public void testShortFailure() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      
  +      valueTest(info, false);
  +   }
  +
  +   /**
  +    * Tests the short validation failure.
  +   */
  +   public void testShortBeyondMin() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Short.MIN_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Tests the short validation failure.
  +   */
  +   public void testShortBeyondMax() throws ValidatorException {
  +      // Create bean to run test on.
  +      ValueBean info = new ValueBean();
  +      info.setValue(Short.MAX_VALUE + "1");
  +      
  +      valueTest(info, false);
  +   }
  +   
  +   /**
  +    * Utlity class to run a test on a value.
  +    *
  +    * @param	info	Value to run test on.
  +    * @param	passed	Whether or not the test is expected to pass.
  +   */
  +   private void valueTest(Object info, boolean passed) throws ValidatorException {
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      ValidatorResult result = results.getValidatorResult("value");
  +
  +      assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +   }
   }                                                         
  
  
  
  1.2       +157 -157  jakarta-commons/validator/src/test/org/apache/commons/validator/TestTypeValidator.java
  
  Index: TestTypeValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/TestTypeValidator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestTypeValidator.java	30 Mar 2002 04:21:03 -0000	1.1
  +++ TestTypeValidator.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,158 +1,158 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -                                                          
  -/**                                                       
  - * <p>Contains validation methods for different 
  - * unit tests.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class TestTypeValidator {
  -
  -   /**
  -    * Checks if the field can be successfully converted to a <code>byte</code>.
  -    *
  -    * @param 	value 		The value validation is being performed on.
  -    * @return	boolean		If the field can be successfully converted 
  -    *                           to a <code>byte</code> <code>true</code> is returned.  
  -    *                           Otherwise <code>false</code>.
  -   */
  -   public static Byte validateByte(Object bean, Field field) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -
  -      return GenericTypeValidator.formatByte(value);
  -   }
  -
  -   /**
  -    * Checks if the field can be successfully converted to a <code>short</code>.
  -    *
  -    * @param 	value 		The value validation is being performed on.
  -    * @return	boolean		If the field can be successfully converted 
  -    *                           to a <code>short</code> <code>true</code> is returned.  
  -    *                           Otherwise <code>false</code>.
  -   */
  -   public static Short validateShort(Object bean, Field field) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -
  -      return GenericTypeValidator.formatShort(value);
  -   }
  -
  -   /**
  -    * Checks if the field can be successfully converted to a <code>int</code>.
  -    *
  -    * @param 	value 		The value validation is being performed on.
  -    * @return	boolean		If the field can be successfully converted 
  -    *                           to a <code>int</code> <code>true</code> is returned.  
  -    *                           Otherwise <code>false</code>.
  -   */
  -   public static Integer validateInt(Object bean, Field field) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -
  -      return GenericTypeValidator.formatInt(value);
  -   }
  -
  -   /**
  -    * Checks if the field can be successfully converted to a <code>long</code>.
  -    *
  -    * @param 	value 		The value validation is being performed on.
  -    * @return	boolean		If the field can be successfully converted 
  -    *                           to a <code>long</code> <code>true</code> is returned.  
  -    *                           Otherwise <code>false</code>.
  -   */
  -   public static Long validateLong(Object bean, Field field) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -
  -      return GenericTypeValidator.formatLong(value);
  -   }
  -
  -   /**
  -    * Checks if the field can be successfully converted to a <code>float</code>.
  -    *
  -    * @param 	value 		The value validation is being performed on.
  -    * @return	boolean		If the field can be successfully converted 
  -    *                           to a <code>float</code> <code>true</code> is returned.  
  -    *                           Otherwise <code>false</code>.
  -   */
  -   public static Float validateFloat(Object bean, Field field) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -
  -      return GenericTypeValidator.formatFloat(value);
  -   }
  -   
  -   /**
  -    * Checks if the field can be successfully converted to a <code>double</code>.
  -    *
  -    * @param 	value 		The value validation is being performed on.
  -    * @return	boolean		If the field can be successfully converted 
  -    *                           to a <code>double</code> <code>true</code> is returned.  
  -    *                           Otherwise <code>false</code>.
  -   */
  -   public static Double validateDouble(Object bean, Field field) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -
  -      return GenericTypeValidator.formatDouble(value);
  -   }
  -      
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +                                                          
  +/**                                                       
  + * <p>Contains validation methods for different 
  + * unit tests.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class TestTypeValidator {
  +
  +   /**
  +    * Checks if the field can be successfully converted to a <code>byte</code>.
  +    *
  +    * @param 	value 		The value validation is being performed on.
  +    * @return	boolean		If the field can be successfully converted 
  +    *                           to a <code>byte</code> <code>true</code> is returned.  
  +    *                           Otherwise <code>false</code>.
  +   */
  +   public static Byte validateByte(Object bean, Field field) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +
  +      return GenericTypeValidator.formatByte(value);
  +   }
  +
  +   /**
  +    * Checks if the field can be successfully converted to a <code>short</code>.
  +    *
  +    * @param 	value 		The value validation is being performed on.
  +    * @return	boolean		If the field can be successfully converted 
  +    *                           to a <code>short</code> <code>true</code> is returned.  
  +    *                           Otherwise <code>false</code>.
  +   */
  +   public static Short validateShort(Object bean, Field field) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +
  +      return GenericTypeValidator.formatShort(value);
  +   }
  +
  +   /**
  +    * Checks if the field can be successfully converted to a <code>int</code>.
  +    *
  +    * @param 	value 		The value validation is being performed on.
  +    * @return	boolean		If the field can be successfully converted 
  +    *                           to a <code>int</code> <code>true</code> is returned.  
  +    *                           Otherwise <code>false</code>.
  +   */
  +   public static Integer validateInt(Object bean, Field field) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +
  +      return GenericTypeValidator.formatInt(value);
  +   }
  +
  +   /**
  +    * Checks if the field can be successfully converted to a <code>long</code>.
  +    *
  +    * @param 	value 		The value validation is being performed on.
  +    * @return	boolean		If the field can be successfully converted 
  +    *                           to a <code>long</code> <code>true</code> is returned.  
  +    *                           Otherwise <code>false</code>.
  +   */
  +   public static Long validateLong(Object bean, Field field) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +
  +      return GenericTypeValidator.formatLong(value);
  +   }
  +
  +   /**
  +    * Checks if the field can be successfully converted to a <code>float</code>.
  +    *
  +    * @param 	value 		The value validation is being performed on.
  +    * @return	boolean		If the field can be successfully converted 
  +    *                           to a <code>float</code> <code>true</code> is returned.  
  +    *                           Otherwise <code>false</code>.
  +   */
  +   public static Float validateFloat(Object bean, Field field) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +
  +      return GenericTypeValidator.formatFloat(value);
  +   }
  +   
  +   /**
  +    * Checks if the field can be successfully converted to a <code>double</code>.
  +    *
  +    * @param 	value 		The value validation is being performed on.
  +    * @return	boolean		If the field can be successfully converted 
  +    *                           to a <code>double</code> <code>true</code> is returned.  
  +    *                           Otherwise <code>false</code>.
  +   */
  +   public static Double validateDouble(Object bean, Field field) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +
  +      return GenericTypeValidator.formatDouble(value);
  +   }
  +      
   }                                                         
  
  
  
  1.2       +147 -147  jakarta-commons/validator/src/test/org/apache/commons/validator/TypeBean.java
  
  Index: TypeBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/TypeBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeBean.java	30 Mar 2002 04:21:03 -0000	1.1
  +++ TypeBean.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,148 +1,148 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -/**                                                       
  - * <p>Value object that contains 
  - * different fields to test 
  - * type conversion validation.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class TypeBean {
  -
  -    private String sByte = null;
  -    private String sShort = null;
  -    private String sInteger = null;
  -    private String sLong = null;
  -    private String sFloat = null;
  -    private String sDouble = null;
  -    private String sDate = null;
  -    private String sCreditCard = null;
  -
  -    public String getByte() {
  -       return sByte;	
  -    }
  -    
  -    public void setByte(String sByte) {
  -       	this.sByte = sByte;
  -    }
  -    
  -    public String getShort() {
  -       return sShort;	
  -    }
  -    
  -    public void setShort(String sShort) {
  -       	this.sShort = sShort;
  -    }
  -
  -    public String getInteger() {
  -       return sInteger;	
  -    }
  -    
  -    public void setInteger(String sInteger) {
  -       	this.sInteger = sInteger;
  -    }
  -
  -    public String getLong() {
  -       return sLong;	
  -    }
  -    
  -    public void setLong(String sLong) {
  -       	this.sLong = sLong;
  -    }
  -
  -    public String getFloat() {
  -       return sFloat;	
  -    }
  -    
  -    public void setFloat(String sFloat) {
  -       	this.sFloat = sFloat;
  -    }
  -
  -    public String getDouble() {
  -       return sDouble;	
  -    }
  -    
  -    public void setDouble(String sDouble) {
  -       	this.sDouble = sDouble;
  -    }
  -
  -    public String getDate() {
  -       return sDate;	
  -    }
  -    
  -    public void setDate(String sDate) {
  -       	this.sDate = sDate;
  -    }
  -
  -    public String getCreditCard() {
  -       return sCreditCard;	
  -    }
  -    
  -    public void setCreditCard(String sCreditCard) {
  -       	this.sCreditCard = sCreditCard;
  -    }
  -      
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +/**                                                       
  + * <p>Value object that contains 
  + * different fields to test 
  + * type conversion validation.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class TypeBean {
  +
  +    private String sByte = null;
  +    private String sShort = null;
  +    private String sInteger = null;
  +    private String sLong = null;
  +    private String sFloat = null;
  +    private String sDouble = null;
  +    private String sDate = null;
  +    private String sCreditCard = null;
  +
  +    public String getByte() {
  +       return sByte;	
  +    }
  +    
  +    public void setByte(String sByte) {
  +       	this.sByte = sByte;
  +    }
  +    
  +    public String getShort() {
  +       return sShort;	
  +    }
  +    
  +    public void setShort(String sShort) {
  +       	this.sShort = sShort;
  +    }
  +
  +    public String getInteger() {
  +       return sInteger;	
  +    }
  +    
  +    public void setInteger(String sInteger) {
  +       	this.sInteger = sInteger;
  +    }
  +
  +    public String getLong() {
  +       return sLong;	
  +    }
  +    
  +    public void setLong(String sLong) {
  +       	this.sLong = sLong;
  +    }
  +
  +    public String getFloat() {
  +       return sFloat;	
  +    }
  +    
  +    public void setFloat(String sFloat) {
  +       	this.sFloat = sFloat;
  +    }
  +
  +    public String getDouble() {
  +       return sDouble;	
  +    }
  +    
  +    public void setDouble(String sDouble) {
  +       	this.sDouble = sDouble;
  +    }
  +
  +    public String getDate() {
  +       return sDate;	
  +    }
  +    
  +    public void setDate(String sDate) {
  +       	this.sDate = sDate;
  +    }
  +
  +    public String getCreditCard() {
  +       return sCreditCard;	
  +    }
  +    
  +    public void setCreditCard(String sCreditCard) {
  +       	this.sCreditCard = sCreditCard;
  +    }
  +      
   }                                                         
  
  
  
  1.3       +208 -208  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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeTest.java	30 Mar 2002 05:13:12 -0000	1.2
  +++ TypeTest.java	15 Dec 2002 20:58:57 -0000	1.3
  @@ -1,209 +1,209 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.util.Iterator;
  -import java.util.Map;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogSource;
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test for type validations.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class TypeTest extends TestCase {            
  -   
  -   /**
  -    * The key used to retrieve the set of validation 
  -    * rules from the xml file.
  -   */
  -   protected static String FORM_KEY = "typeForm";   
  -
  -   /**
  -    * The key used to retrieve the validator action.
  -   */
  -   protected static String ACTION = "byte";
  -
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogSource.getInstance(this.getClass().getName());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  -   public TypeTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests.
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {TypeTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(TypeTest.class);
  -   }
  -
  -   /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-name-required.xml.
  -   */
  -   protected void setUp() throws IOException {
  -      // Load resources
  -      InputStream in = null;
  -      resources = new ValidatorResources();
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-type.xml");
  -         ValidatorResourcesInitializer.initialize(resources, in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Tests the byte validation.
  -   */
  -   public void testType() throws ValidatorException {
  -      // Create bean to run test on.
  -      TypeBean info = new TypeBean();
  -      info.setByte("12");
  -      info.setShort("129");
  -      info.setInteger("-144");
  -      info.setLong("88000");
  -      info.setFloat("12.1555f");
  -      info.setDouble("129.1551511111d");
  -      
  -      // 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, info);
  -
  -      // Get results of the validation.
  -      ValidatorResults results = null;
  -      
  -      // throws ValidatorException, 
  -      // but we aren't catching for testing 
  -      // since no validation methods we use 
  -      // throw this
  -      results = validator.validate();
  -      
  -      assertNotNull("Results are null.", results);
  -      
  -      Map hResultValues = results.getResultValueMap();
  -
  -      assertTrue("Expecting byte result to be an instance of Byte.", (hResultValues.get("byte") instanceof Byte));
  -      assertTrue("Expecting short result to be an instance of Short.", (hResultValues.get("short") instanceof Short));
  -      assertTrue("Expecting integer result to be an instance of Integer.", (hResultValues.get("integer") instanceof Integer));
  -      assertTrue("Expecting long result to be an instance of Long.", (hResultValues.get("long") instanceof Long));
  -      assertTrue("Expecting float result to be an instance of Float.", (hResultValues.get("float") instanceof Float));
  -      assertTrue("Expecting double result to be an instance of Double.", (hResultValues.get("double") instanceof Double));
  -      
  -      for (Iterator i = hResultValues.keySet().iterator(); i.hasNext(); ) {
  -         String key = (String)i.next();
  -         Object value = hResultValues.get(key);
  -         
  -         assertNotNull("value ValidatorResults.getResultValueMap() should not be null.", value);
  -      }
  -      
  -      //ValidatorResult result = results.getValidatorResult("value");
  -      
  -      //assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  -      //assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  -      //assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  -
  -   }
  -
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Iterator;
  +import java.util.Map;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test for type validations.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class TypeTest extends TestCase {            
  +   
  +   /**
  +    * The key used to retrieve the set of validation 
  +    * rules from the xml file.
  +   */
  +   protected static String FORM_KEY = "typeForm";   
  +
  +   /**
  +    * The key used to retrieve the validator action.
  +   */
  +   protected static String ACTION = "byte";
  +
  +   
  +   /**
  +    * Commons Logging instance.
  +   */
  +   private Log log = LogSource.getInstance(this.getClass().getName());
  +   
  +   /**
  +    * Resources used for validation tests.
  +   */
  +   private ValidatorResources resources = null;
  +   
  +   public TypeTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests.
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {TypeTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(TypeTest.class);
  +   }
  +
  +   /**
  +    * Load <code>ValidatorResources</code> from 
  +    * validator-name-required.xml.
  +   */
  +   protected void setUp() throws IOException {
  +      // Load resources
  +      InputStream in = null;
  +      resources = new ValidatorResources();
  +      
  +      try {
  +         in = this.getClass().getResourceAsStream("validator-type.xml");
  +         ValidatorResourcesInitializer.initialize(resources, in);
  +      } catch (IOException e) {
  +         log.error(e.getMessage(), e);
  +         throw e;
  +      } finally {
  +         if (in != null) {
  +            try { in.close(); } catch (Exception e) {}	
  +         }
  +      }
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Tests the byte validation.
  +   */
  +   public void testType() throws ValidatorException {
  +      // Create bean to run test on.
  +      TypeBean info = new TypeBean();
  +      info.setByte("12");
  +      info.setShort("129");
  +      info.setInteger("-144");
  +      info.setLong("88000");
  +      info.setFloat("12.1555f");
  +      info.setDouble("129.1551511111d");
  +      
  +      // 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, info);
  +
  +      // Get results of the validation.
  +      ValidatorResults results = null;
  +      
  +      // throws ValidatorException, 
  +      // but we aren't catching for testing 
  +      // since no validation methods we use 
  +      // throw this
  +      results = validator.validate();
  +      
  +      assertNotNull("Results are null.", results);
  +      
  +      Map hResultValues = results.getResultValueMap();
  +
  +      assertTrue("Expecting byte result to be an instance of Byte.", (hResultValues.get("byte") instanceof Byte));
  +      assertTrue("Expecting short result to be an instance of Short.", (hResultValues.get("short") instanceof Short));
  +      assertTrue("Expecting integer result to be an instance of Integer.", (hResultValues.get("integer") instanceof Integer));
  +      assertTrue("Expecting long result to be an instance of Long.", (hResultValues.get("long") instanceof Long));
  +      assertTrue("Expecting float result to be an instance of Float.", (hResultValues.get("float") instanceof Float));
  +      assertTrue("Expecting double result to be an instance of Double.", (hResultValues.get("double") instanceof Double));
  +      
  +      for (Iterator i = hResultValues.keySet().iterator(); i.hasNext(); ) {
  +         String key = (String)i.next();
  +         Object value = hResultValues.get(key);
  +         
  +         assertNotNull("value ValidatorResults.getResultValueMap() should not be null.", value);
  +      }
  +      
  +      //ValidatorResult result = results.getValidatorResult("value");
  +      
  +      //assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
  +      //assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
  +      //assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
  +
  +   }
  +
   }                                                         
  
  
  
  1.5       +306 -306  jakarta-commons/validator/src/test/org/apache/commons/validator/ValidatorTest.java
  
  Index: ValidatorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/ValidatorTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ValidatorTest.java	30 Mar 2002 04:33:18 -0000	1.4
  +++ ValidatorTest.java	15 Dec 2002 20:58:57 -0000	1.5
  @@ -1,307 +1,307 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -import java.util.ArrayList;
  -import java.util.Date;
  -import java.util.List;
  -import java.util.Locale;
  -import java.text.DateFormat;
  -import java.text.ParseException;
  -import junit.framework.Test;                           
  -import junit.framework.TestCase;                          
  -import junit.framework.TestSuite;
  -import junit.framework.AssertionFailedError;              
  -
  -                                                          
  -/**                                                       
  - * <p>Performs Validation Test.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class ValidatorTest extends TestCase {            
  -                                                          
  -   public ValidatorTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  -
  -   /**
  -    * Start the tests. 
  -    *
  -    * @param theArgs the arguments. Not used
  -    */
  -   public static void main(String[] theArgs) {
  -       junit.awtui.TestRunner.main(new String[] {ValidatorTest.class.getName()});
  -   }
  -
  -   /**
  -    * @return a test suite (<code>TestSuite</code>) that includes all methods
  -    *         starting with "test"
  -    */
  -   public static Test suite() {
  -       // All methods starting with "test" will be executed in the test suite.
  -       return new TestSuite(ValidatorTest.class);
  -   }
  -
  -   protected void setUp() {
  -   }
  -
  -   protected void tearDown() {
  -   }
  -
  -   /**
  -    * Verify that one value generates an error and the other passes.  The validation 
  -    * method being tested returns an object (<code>null</code> will be considered an error).
  -   */
  -   public void testManualObject() {
  -      // property name of the method we are validating
  -      String property = "date";
  -      // name of ValidatorAction
  -      String action = "date";
  -      
  -      ValidatorResources resources = new ValidatorResources();
  -
  -      ValidatorAction va = new ValidatorAction();
  -      va.setName(action);
  -      va.setClassname("org.apache.commons.validator.ValidatorTest");
  -      va.setMethod("formatDate");
  -      va.setMethodParams("java.lang.Object,org.apache.commons.validator.Field");
  -      
  -      FormSet fs = new FormSet();
  -      Form form = new Form();
  -      form.setName("testForm");
  -      Field field = new Field();
  -      field.setProperty(property);
  -      field.setDepends(action);
  -      form.addField(field);
  -      fs.addForm(form);
  -      
  -      resources.addValidatorAction(va);
  -      resources.put(fs);
  -      resources.process();
  -
  -      List l = new ArrayList();
  -
  -      TestBean bean = new TestBean();  
  -      bean.setDate("2/3/1999");
  -      
  -      Validator validator = new Validator(resources, "testForm");
  -      validator.addResource(Validator.BEAN_KEY, bean);
  -
  -      try {
  -         ValidatorResults results = validator.validate();
  -         
  -         assertNotNull("Results are null.", results);
  -         
  -         ValidatorResult result = results.getValidatorResult(property);
  -         
  -         assertNotNull("Results are null.", results);
  -         
  -         assertTrue("ValidatorResult does not contain '" + action + "' validator result.", result.containsAction(action));
  -         
  -         assertTrue("Validation of the date formatting has failed.", result.isValid(action));
  -      } catch (Exception e) {
  -         fail("An exception was thrown while calling Validator.validate()");
  -      }
  -
  -      bean.setDate("2/30/1999");
  -      
  -      try {
  -         ValidatorResults results = validator.validate();
  -         
  -         assertNotNull("Results are null.", results);
  -         
  -         ValidatorResult result = results.getValidatorResult(property);
  -         
  -         assertNotNull("Results are null.", results);
  -         
  -         assertTrue("ValidatorResult does not contain '" + action + "' validator result.", result.containsAction(action));
  -         
  -         assertTrue("Validation of the date formatting has passed when it should have failed.", !result.isValid(action));
  -      } catch (Exception e) {
  -         fail("An exception was thrown while calling Validator.validate()");
  -      }
  -
  -
  -   }
  -                                                          
  -   /**
  -    * Verify that one value generates an error and the other passes.  The validation 
  -    * method being tested returns a <code>boolean</code> value.
  -   */
  -   public void testManualBoolean() {
  -      ValidatorResources resources = new ValidatorResources();
  -
  -      ValidatorAction va = new ValidatorAction();
  -      va.setName("capLetter");
  -      va.setClassname("org.apache.commons.validator.ValidatorTest");
  -      va.setMethod("isCapLetter");
  -      va.setMethodParams("java.lang.Object,org.apache.commons.validator.Field,java.util.List");
  -      
  -      FormSet fs = new FormSet();
  -      Form form = new Form();
  -      form.setName("testForm");
  -      Field field = new Field();
  -      field.setProperty("letter");
  -      field.setDepends("capLetter");
  -      form.addField(field);
  -      fs.addForm(form);
  -      
  -      resources.addValidatorAction(va);
  -      resources.put(fs);
  -      resources.process();
  -
  -      List l = new ArrayList();
  -
  -      TestBean bean = new TestBean();  
  -      bean.setLetter("A");
  -      
  -      Validator validator = new Validator(resources, "testForm");
  -      validator.addResource(Validator.BEAN_KEY, bean);
  -      validator.addResource("java.util.List", l);
  -
  -      try {
  -         validator.validate();
  -      } catch (Exception e) {
  -         fail("An exception was thrown while calling Validator.validate()");
  -      }
  -
  -      assertEquals("Validation of the letter 'A'.", 0, l.size());
  -
  -      l.clear();       
  -      bean.setLetter("AA");
  -
  -      try {
  -         validator.validate();
  -      } catch (Exception e) {
  -         fail("An exception was thrown while calling Validator.validate()");
  -      }
  -      
  -      assertEquals("Validation of the letter 'AA'.", 1, l.size());
  -   }
  -
  -   /**
  -    * Checks if the field is one upper case letter between 'A' and 'Z'.
  -   */
  -   public static boolean isCapLetter(Object bean, Field field, List l) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -
  -      if (value != null && value.length() == 1) {
  -         if (value.charAt(0) >= 'A' && value.charAt(0) <= 'Z') {
  -            return true;
  -         } else {
  -            l.add("Error");
  -            return false;
  -         }
  -      } else {
  -         l.add("Error");
  -         return false;
  -      }
  -   }
  -
  -   /**
  -    * Formats a <code>String</code> to a <code>Date</code>.  
  -    * The <code>Validator</code> will interpret a <code>null</code> 
  -    * as validation having failed.
  -   */
  -   public static Date formatDate(Object bean, Field field) {
  -      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -      Date date = null;
  -      
  -      try {
  -         DateFormat formatter = null;
  -         formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
  -            
  -         formatter.setLenient(false);
  -             
  -         date = formatter.parse(value);
  -      } catch (ParseException e) {
  -         System.out.println("ValidatorTest::formatDate - " + e.getMessage());
  -      }
  -   
  -      return date;
  -   }	
  -       
  -   public class TestBean {
  -      private String letter = null;
  -      private String date = null;
  -      
  -      public String getLetter() {
  -         return letter;
  -      }
  -      
  -      public void setLetter(String letter) {
  -         this.letter = letter;	
  -      }
  -
  -      public String getDate() {
  -         return date;
  -      }
  -      
  -      public void setDate(String date) {
  -         this.date = date;	
  -      }
  -   }
  -
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +import java.util.ArrayList;
  +import java.util.Date;
  +import java.util.List;
  +import java.util.Locale;
  +import java.text.DateFormat;
  +import java.text.ParseException;
  +import junit.framework.Test;                           
  +import junit.framework.TestCase;                          
  +import junit.framework.TestSuite;
  +import junit.framework.AssertionFailedError;              
  +
  +                                                          
  +/**                                                       
  + * <p>Performs Validation Test.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class ValidatorTest extends TestCase {            
  +                                                          
  +   public ValidatorTest(String name) {                  
  +       super(name);                                      
  +   }                                                     
  +
  +   /**
  +    * Start the tests. 
  +    *
  +    * @param theArgs the arguments. Not used
  +    */
  +   public static void main(String[] theArgs) {
  +       junit.awtui.TestRunner.main(new String[] {ValidatorTest.class.getName()});
  +   }
  +
  +   /**
  +    * @return a test suite (<code>TestSuite</code>) that includes all methods
  +    *         starting with "test"
  +    */
  +   public static Test suite() {
  +       // All methods starting with "test" will be executed in the test suite.
  +       return new TestSuite(ValidatorTest.class);
  +   }
  +
  +   protected void setUp() {
  +   }
  +
  +   protected void tearDown() {
  +   }
  +
  +   /**
  +    * Verify that one value generates an error and the other passes.  The validation 
  +    * method being tested returns an object (<code>null</code> will be considered an error).
  +   */
  +   public void testManualObject() {
  +      // property name of the method we are validating
  +      String property = "date";
  +      // name of ValidatorAction
  +      String action = "date";
  +      
  +      ValidatorResources resources = new ValidatorResources();
  +
  +      ValidatorAction va = new ValidatorAction();
  +      va.setName(action);
  +      va.setClassname("org.apache.commons.validator.ValidatorTest");
  +      va.setMethod("formatDate");
  +      va.setMethodParams("java.lang.Object,org.apache.commons.validator.Field");
  +      
  +      FormSet fs = new FormSet();
  +      Form form = new Form();
  +      form.setName("testForm");
  +      Field field = new Field();
  +      field.setProperty(property);
  +      field.setDepends(action);
  +      form.addField(field);
  +      fs.addForm(form);
  +      
  +      resources.addValidatorAction(va);
  +      resources.put(fs);
  +      resources.process();
  +
  +      List l = new ArrayList();
  +
  +      TestBean bean = new TestBean();  
  +      bean.setDate("2/3/1999");
  +      
  +      Validator validator = new Validator(resources, "testForm");
  +      validator.addResource(Validator.BEAN_KEY, bean);
  +
  +      try {
  +         ValidatorResults results = validator.validate();
  +         
  +         assertNotNull("Results are null.", results);
  +         
  +         ValidatorResult result = results.getValidatorResult(property);
  +         
  +         assertNotNull("Results are null.", results);
  +         
  +         assertTrue("ValidatorResult does not contain '" + action + "' validator result.", result.containsAction(action));
  +         
  +         assertTrue("Validation of the date formatting has failed.", result.isValid(action));
  +      } catch (Exception e) {
  +         fail("An exception was thrown while calling Validator.validate()");
  +      }
  +
  +      bean.setDate("2/30/1999");
  +      
  +      try {
  +         ValidatorResults results = validator.validate();
  +         
  +         assertNotNull("Results are null.", results);
  +         
  +         ValidatorResult result = results.getValidatorResult(property);
  +         
  +         assertNotNull("Results are null.", results);
  +         
  +         assertTrue("ValidatorResult does not contain '" + action + "' validator result.", result.containsAction(action));
  +         
  +         assertTrue("Validation of the date formatting has passed when it should have failed.", !result.isValid(action));
  +      } catch (Exception e) {
  +         fail("An exception was thrown while calling Validator.validate()");
  +      }
  +
  +
  +   }
  +                                                          
  +   /**
  +    * Verify that one value generates an error and the other passes.  The validation 
  +    * method being tested returns a <code>boolean</code> value.
  +   */
  +   public void testManualBoolean() {
  +      ValidatorResources resources = new ValidatorResources();
  +
  +      ValidatorAction va = new ValidatorAction();
  +      va.setName("capLetter");
  +      va.setClassname("org.apache.commons.validator.ValidatorTest");
  +      va.setMethod("isCapLetter");
  +      va.setMethodParams("java.lang.Object,org.apache.commons.validator.Field,java.util.List");
  +      
  +      FormSet fs = new FormSet();
  +      Form form = new Form();
  +      form.setName("testForm");
  +      Field field = new Field();
  +      field.setProperty("letter");
  +      field.setDepends("capLetter");
  +      form.addField(field);
  +      fs.addForm(form);
  +      
  +      resources.addValidatorAction(va);
  +      resources.put(fs);
  +      resources.process();
  +
  +      List l = new ArrayList();
  +
  +      TestBean bean = new TestBean();  
  +      bean.setLetter("A");
  +      
  +      Validator validator = new Validator(resources, "testForm");
  +      validator.addResource(Validator.BEAN_KEY, bean);
  +      validator.addResource("java.util.List", l);
  +
  +      try {
  +         validator.validate();
  +      } catch (Exception e) {
  +         fail("An exception was thrown while calling Validator.validate()");
  +      }
  +
  +      assertEquals("Validation of the letter 'A'.", 0, l.size());
  +
  +      l.clear();       
  +      bean.setLetter("AA");
  +
  +      try {
  +         validator.validate();
  +      } catch (Exception e) {
  +         fail("An exception was thrown while calling Validator.validate()");
  +      }
  +      
  +      assertEquals("Validation of the letter 'AA'.", 1, l.size());
  +   }
  +
  +   /**
  +    * Checks if the field is one upper case letter between 'A' and 'Z'.
  +   */
  +   public static boolean isCapLetter(Object bean, Field field, List l) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +
  +      if (value != null && value.length() == 1) {
  +         if (value.charAt(0) >= 'A' && value.charAt(0) <= 'Z') {
  +            return true;
  +         } else {
  +            l.add("Error");
  +            return false;
  +         }
  +      } else {
  +         l.add("Error");
  +         return false;
  +      }
  +   }
  +
  +   /**
  +    * Formats a <code>String</code> to a <code>Date</code>.  
  +    * The <code>Validator</code> will interpret a <code>null</code> 
  +    * as validation having failed.
  +   */
  +   public static Date formatDate(Object bean, Field field) {
  +      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  +      Date date = null;
  +      
  +      try {
  +         DateFormat formatter = null;
  +         formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
  +            
  +         formatter.setLenient(false);
  +             
  +         date = formatter.parse(value);
  +      } catch (ParseException e) {
  +         System.out.println("ValidatorTest::formatDate - " + e.getMessage());
  +      }
  +   
  +      return date;
  +   }	
  +       
  +   public class TestBean {
  +      private String letter = null;
  +      private String date = null;
  +      
  +      public String getLetter() {
  +         return letter;
  +      }
  +      
  +      public void setLetter(String letter) {
  +         this.letter = letter;	
  +      }
  +
  +      public String getDate() {
  +         return date;
  +      }
  +      
  +      public void setDate(String date) {
  +         this.date = date;	
  +      }
  +   }
  +
   }                                                         
  
  
  
  1.2       +89 -89    jakarta-commons/validator/src/test/org/apache/commons/validator/ValueBean.java
  
  Index: ValueBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/ValueBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValueBean.java	30 Mar 2002 04:26:51 -0000	1.1
  +++ ValueBean.java	15 Dec 2002 20:58:57 -0000	1.2
  @@ -1,90 +1,90 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -
  -package org.apache.commons.validator;
  -
  -/**                                                       
  - * <p>Value object for storing a value to 
  - * run tests on.</p> 
  - *
  - * @author David Winterfeldt
  - * @version $Revision$ $Date$
  -*/                                                       
  -public class ValueBean {
  -   
  -   protected String value = null;
  -   
  -   /**
  -    * Gets the value.
  -   */
  -   public String getValue() {
  -      return value;	
  -   }
  -
  -   /**
  -    * Sets the value.
  -   */
  -   public void setValue(String value) {
  -      this.value = value;	
  -   }
  -      
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +
  +package org.apache.commons.validator;
  +
  +/**                                                       
  + * <p>Value object for storing a value to 
  + * run tests on.</p> 
  + *
  + * @author David Winterfeldt
  + * @version $Revision$ $Date$
  +*/                                                       
  +public class ValueBean {
  +   
  +   protected String value = null;
  +   
  +   /**
  +    * Gets the value.
  +   */
  +   public String getValue() {
  +      return value;	
  +   }
  +
  +   /**
  +    * Sets the value.
  +   */
  +   public void setValue(String value) {
  +      this.value = value;	
  +   }
  +      
   }                                                         
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message