commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlel...@apache.org
Subject cvs commit: jakarta-commons/validator/src/test/org/apache/commons/validator TestCommon.java TestNumber.java ByteTest.java DoubleTest.java EmailTest.java FloatTest.java IntegerTest.java LocaleTest.java LongTest.java MultipleTests.java RequiredIfTest.java RequiredNameTest.java ShortTest.java TypeTest.java
Date Sat, 06 Sep 2003 05:18:00 GMT
rleland     2003/09/05 22:18:00

  Modified:    validator/src/test/org/apache/commons/validator
                        ByteTest.java DoubleTest.java EmailTest.java
                        FloatTest.java IntegerTest.java LocaleTest.java
                        LongTest.java MultipleTests.java
                        RequiredIfTest.java RequiredNameTest.java
                        ShortTest.java TypeTest.java
  Added:       validator/src/test/org/apache/commons/validator
                        TestCommon.java TestNumber.java
  Log:
  Factor out common unit test code.
  It looks like the code might have been designed to be more
  generic but was never abstracted. I know that the
  swing interface to JUnit, JRunnder, sometimes causes problems
  since it uses its own class loaded. But since
  we use ant here there is no problem.
  
  Revision  Changes    Path
  1.12      +97 -180   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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ByteTest.java	23 Aug 2003 02:24:07 -0000	1.11
  +++ ByteTest.java	6 Sep 2003 05:17:59 -0000	1.12
  @@ -62,189 +62,106 @@
   
   package org.apache.commons.validator;
   
  -import java.io.IOException;
  -import java.io.InputStream;
  -
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.xml.sax.SAXException;
   
  -                                                          
   /**                                                       
    * <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 = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * 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-numeric.xml.
  -   */
  -   protected void setUp() throws IOException, SAXException {
  -      // Load resources
  -      InputStream in = null;
  -      
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         resources = new ValidatorResources(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.setParameter(Validator.BEAN_PARAM, 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)));
  -   }
  + */
  +public class ByteTest extends TestNumber {
  +
  +    public ByteTest(String name) {
  +        super(name);
  +        ACTION = "byte";
  +        FORM_KEY = "byteForm";
  +    }
  +
  +    /**
  +     * 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);
  +    }
  +
  +
  +    /**
  +     * 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);
  +    }
  +
   }                                                         
  
  
  
  1.12      +77 -150   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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DoubleTest.java	23 Aug 2003 02:24:07 -0000	1.11
  +++ DoubleTest.java	6 Sep 2003 05:17:59 -0000	1.12
  @@ -73,155 +73,82 @@
   import org.apache.commons.logging.LogFactory;
   import org.xml.sax.SAXException;
   
  -                                                          
  +
   /**                                                       
    * <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 = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * 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-numeric.xml.
  -   */
  -   protected void setUp() throws IOException, SAXException {
  -      // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         resources = new ValidatorResources(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.setParameter(Validator.BEAN_PARAM, 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)));
  -   }
  + */
  +public class DoubleTest extends TestNumber {
  +
  +    public DoubleTest(String name) {
  +        super(name);
  +        ACTION = "double";
  +        FORM_KEY = "doubleForm";
  +    }
  +
  +
  +    /**
  +     * 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);
  +    }
  +
  +
  +    /**
  +     * 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);
  +    }
  +
   }                                                         
  
  
  
  1.20      +8 -35     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- EmailTest.java	23 Aug 2003 02:24:07 -0000	1.19
  +++ EmailTest.java	6 Sep 2003 05:17:59 -0000	1.20
  @@ -62,14 +62,11 @@
   package org.apache.commons.validator;
   
   import java.io.IOException;
  -import java.io.InputStream;
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
  +
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
   import org.xml.sax.SAXException;
   
   /**                                                       
  @@ -80,7 +77,7 @@
    * @author Rob Leland
    * @version $Revision$ $Date$
   */                                                       
  -public class EmailTest extends TestCase {            
  +public class EmailTest extends TestCommon {
      
      /**
       * The key used to retrieve the set of validation 
  @@ -93,17 +90,7 @@
      */
      protected static String ACTION = "email";
   
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  +
      public EmailTest(String name) {                  
          super(name);                                      
      }                                                     
  @@ -131,20 +118,7 @@
       * validator-regexp.xml.
      */
      protected void setUp() throws IOException, SAXException {
  -      // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-regexp.xml");
  -         resources = new ValidatorResources(in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  +      loadResources("validator-regexp.xml");
      }
   
      protected void tearDown() {
  @@ -331,7 +305,6 @@
           valueTest(info, true);
           info.setValue("\"joe=\"@apache.org");
           valueTest(info, true);
  -
   
       }
   
  
  
  
  1.12      +75 -157   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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FloatTest.java	23 Aug 2003 02:24:07 -0000	1.11
  +++ FloatTest.java	6 Sep 2003 05:17:59 -0000	1.12
  @@ -62,166 +62,84 @@
   
   package org.apache.commons.validator;
   
  -import java.io.IOException;
  -import java.io.InputStream;
  -
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.xml.sax.SAXException;
   
  -                                                          
   /**                                                       
    * <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 = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * 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-numeric.xml.
  -   */
  -   protected void setUp() throws IOException, SAXException {
  -      // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         resources = new ValidatorResources(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.setParameter(Validator.BEAN_PARAM, 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)));
  -   }
  + */
  +public class FloatTest extends TestNumber {
  +
  +    public FloatTest(String name) {
  +        super(name);
  +        ACTION = "float";
  +        FORM_KEY = "floatForm";
  +    }
  +
  +    /**
  +     * 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);
  +    }
  +
  +
  +    /**
  +     * 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);
  +    }
  +
   }                                                         
  
  
  
  1.12      +98 -179   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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- IntegerTest.java	23 Aug 2003 02:24:07 -0000	1.11
  +++ IntegerTest.java	6 Sep 2003 05:17:59 -0000	1.12
  @@ -62,188 +62,107 @@
   
   package org.apache.commons.validator;
   
  -import java.io.IOException;
  -import java.io.InputStream;
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.xml.sax.SAXException;
   
  -                                                          
   /**                                                       
    * <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 = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * 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-numeric.xml.
  -   */
  -   protected void setUp() throws IOException, SAXException {
  -      // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         resources = new ValidatorResources(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.setParameter(Validator.BEAN_PARAM, 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)));
  -   }
  -}                                                         
  \ No newline at end of file
  + */
  +public class IntegerTest extends TestNumber {
  +
  +
  +    public IntegerTest(String name) {
  +        super(name);
  +        FORM_KEY = "intForm";
  +        ACTION = "int";
  +    }
  +
  +    /**
  +     * 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);
  +    }
  +
  +    /**
  +     * 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);
  +    }
  +
  +}
  \ No newline at end of file
  
  
  
  1.10      +8 -33     jakarta-commons/validator/src/test/org/apache/commons/validator/LocaleTest.java
  
  Index: LocaleTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/LocaleTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LocaleTest.java	23 Aug 2003 02:24:07 -0000	1.9
  +++ LocaleTest.java	6 Sep 2003 05:17:59 -0000	1.10
  @@ -63,15 +63,12 @@
   package org.apache.commons.validator;
   
   import java.io.IOException;
  -import java.io.InputStream;
   import java.util.Locale;
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  +
   import org.xml.sax.SAXException;
                                                             
   /**                                                       
  @@ -80,7 +77,7 @@
    * @author David Winterfeldt
    * @version $Revision$ $Date$
   */                                                       
  -public class LocaleTest extends TestCase {            
  +public class LocaleTest extends TestCommon {
      
      /**
       * The key used to retrieve the set of validation 
  @@ -93,17 +90,7 @@
      */
      protected static String ACTION = "required";
   
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  +
      public LocaleTest(String name) {                  
          super(name);                                      
      }                                                     
  @@ -132,19 +119,7 @@
      */
      protected void setUp() throws IOException, SAXException {
         // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-locale.xml");
  -         resources = new ValidatorResources(in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  +      loadResources("validator-locale.xml");
      }
   
      protected void tearDown() {
  
  
  
  1.12      +98 -181   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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LongTest.java	23 Aug 2003 02:24:07 -0000	1.11
  +++ LongTest.java	6 Sep 2003 05:17:59 -0000	1.12
  @@ -62,188 +62,105 @@
   
   package org.apache.commons.validator;
   
  -import java.io.IOException;
  -import java.io.InputStream;
  -
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.xml.sax.SAXException;
  -
  -                                                          
   /**                                                       
    * <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 = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * 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-numeric.xml.
  -   */
  -   protected void setUp() throws IOException, SAXException {
  -      // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         resources = new ValidatorResources(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.setParameter(Validator.BEAN_PARAM, 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)));
  -   }
  -}                                                         
  \ No newline at end of file
  + */
  +public class LongTest extends TestNumber {
  +
  +
  +    public LongTest(String name) {
  +        super(name);
  +        FORM_KEY = "longForm";
  +        ACTION = "long";
  +    }
  +
  +    /**
  +     * 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);
  +    }
  +
  +    /**
  +     * 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);
  +    }
  +
  +}
  \ No newline at end of file
  
  
  
  1.13      +6 -31     jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java
  
  Index: MultipleTests.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/MultipleTests.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MultipleTests.java	26 Aug 2003 16:12:47 -0000	1.12
  +++ MultipleTests.java	6 Sep 2003 05:17:59 -0000	1.13
  @@ -63,14 +63,10 @@
   package org.apache.commons.validator;
   
   import java.io.IOException;
  -import java.io.InputStream;
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
   import org.xml.sax.SAXException;
   
   /**
  @@ -80,7 +76,7 @@
    * @author Arun Mammen Thomas
    * @version $Revision$ $Date$
   */
  -public class MultipleTests extends TestCase {
  +public class MultipleTests extends TestCommon {
   
      /**
       * The key used to retrieve the set of validation
  @@ -94,15 +90,6 @@
      protected static String ACTION = "required";
   
   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogFactory.getLog(this.getClass());
  -
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
   
      public MultipleTests(String name) {
          super(name);
  @@ -132,19 +119,7 @@
      */
      protected void setUp() throws IOException, SAXException {
         // Load resources
  -      InputStream in = null;
  -
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-multipletest.xml");
  -         resources = new ValidatorResources(in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}
  -         }
  -      }
  +      loadResources("validator-multipletest.xml");
      }
   
      protected void tearDown() {
  
  
  
  1.11      +6 -33     jakarta-commons/validator/src/test/org/apache/commons/validator/RequiredIfTest.java
  
  Index: RequiredIfTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/RequiredIfTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RequiredIfTest.java	23 Aug 2003 02:24:07 -0000	1.10
  +++ RequiredIfTest.java	6 Sep 2003 05:17:59 -0000	1.11
  @@ -63,14 +63,10 @@
   package org.apache.commons.validator;
   
   import java.io.IOException;
  -import java.io.InputStream;
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
   import org.xml.sax.SAXException;
                                                             
   /**                                                       
  @@ -79,7 +75,7 @@
    * @author James Turner
    * @version $Revision$ $Date$
   */                                                       
  -public class RequiredIfTest extends TestCase {            
  +public class RequiredIfTest extends TestCommon {
      
      /**
       * The key used to retrieve the set of validation 
  @@ -92,17 +88,6 @@
      */
      protected static String ACTION = "requiredif";
   
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
      public RequiredIfTest(String name) {                  
          super(name);                                      
      }                                                     
  @@ -131,19 +116,7 @@
      */
      protected void setUp() throws IOException, SAXException {
         // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-requiredif.xml");
  -         resources = new ValidatorResources(in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  +      loadResources("validator-requiredif.xml");
      }
   
      protected void tearDown() {
  
  
  
  1.13      +6 -31     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RequiredNameTest.java	23 Aug 2003 02:24:07 -0000	1.12
  +++ RequiredNameTest.java	6 Sep 2003 05:17:59 -0000	1.13
  @@ -63,10 +63,8 @@
   package org.apache.commons.validator;
   
   import java.io.IOException;
  -import java.io.InputStream;
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
   import org.apache.commons.logging.Log;
  @@ -80,7 +78,7 @@
    * @author David Winterfeldt
    * @version $Revision$ $Date$
   */                                                       
  -public class RequiredNameTest extends TestCase {            
  +public class RequiredNameTest extends TestCommon {
      
      /**
       * The key used to retrieve the set of validation 
  @@ -93,17 +91,6 @@
      */
      protected static String ACTION = "required";
   
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
      public RequiredNameTest(String name) {                  
          super(name);                                      
      }                                                     
  @@ -132,19 +119,7 @@
      */
      protected void setUp() throws IOException, SAXException {
         // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-name-required.xml");
  -         resources = new ValidatorResources(in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  +      loadResources("validator-name-required.xml");
      }
   
      protected void tearDown() {
  
  
  
  1.12      +10 -111   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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ShortTest.java	23 Aug 2003 02:24:07 -0000	1.11
  +++ ShortTest.java	6 Sep 2003 05:17:59 -0000	1.12
  @@ -62,16 +62,9 @@
   
   package org.apache.commons.validator;
   
  -import java.io.IOException;
  -import java.io.InputStream;
  -
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.xml.sax.SAXException;
   
                                                             
   /**                                                       
  @@ -80,33 +73,16 @@
    * @author David Winterfeldt
    * @version $Revision$ $Date$
   */                                                       
  -public class ShortTest extends TestCase {            
  +public class ShortTest extends TestNumber {
      
  -   /**
  -    * 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 = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
  +
      public ShortTest(String name) {                  
  -       super(name);                                      
  -   }                                                     
  +       super(name);
  +      FORM_KEY = "shortForm";
  +      ACTION = "short";
  +   }
   
      /**
       * Start the tests.
  @@ -127,41 +103,6 @@
      }
   
      /**
  -    * Load <code>ValidatorResources</code> from 
  -    * validator-numeric.xml.
  -   */
  -   protected void setUp() throws IOException, SAXException {
  -      // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-numeric.xml");
  -         resources = new ValidatorResources(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 {
  @@ -186,16 +127,6 @@
      /**
       * 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();
  @@ -213,37 +144,5 @@
         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.setParameter(Validator.BEAN_PARAM, 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.13      +8 -33     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TypeTest.java	23 Aug 2003 02:24:07 -0000	1.12
  +++ TypeTest.java	6 Sep 2003 05:17:59 -0000	1.13
  @@ -63,16 +63,14 @@
   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 org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  +
   import org.xml.sax.SAXException;
   
                                                             
  @@ -82,7 +80,7 @@
    * @author David Winterfeldt
    * @version $Revision$ $Date$
   */                                                       
  -public class TypeTest extends TestCase {            
  +public class TypeTest extends TestCommon {
      
      /**
       * The key used to retrieve the set of validation 
  @@ -95,17 +93,6 @@
      */
      protected static String ACTION = "byte";
   
  -   
  -   /**
  -    * Commons Logging instance.
  -   */
  -   private Log log = LogFactory.getLog(this.getClass());
  -   
  -   /**
  -    * Resources used for validation tests.
  -   */
  -   private ValidatorResources resources = null;
  -   
      public TypeTest(String name) {                  
          super(name);                                      
      }                                                     
  @@ -134,19 +121,7 @@
      */
      protected void setUp() throws IOException, SAXException {
         // Load resources
  -      InputStream in = null;
  -      
  -      try {
  -         in = this.getClass().getResourceAsStream("validator-type.xml");
  -         resources = new ValidatorResources(in);
  -      } catch (IOException e) {
  -         log.error(e.getMessage(), e);
  -         throw e;
  -      } finally {
  -         if (in != null) {
  -            try { in.close(); } catch (Exception e) {}	
  -         }
  -      }
  +      loadResources("validator-type.xml");
      }
   
      protected void tearDown() {
  
  
  
  1.1                  jakarta-commons/validator/src/test/org/apache/commons/validator/TestCommon.java
  
  Index: TestCommon.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/TestCommon.java,v 1.1 2003/09/06 05:17:59 rleland Exp $
   * $Revision: 1.1 $
   * $Date: 2003/09/06 05:17:59 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 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 acknowledgement:
   *       "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, "Apache", "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 name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * 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 junit.framework.TestCase;
  
  import java.io.IOException;
  import java.io.InputStream;
  
  import org.xml.sax.SAXException;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * Consolidates reading in xml config file into parent class.
   */
  public class TestCommon extends TestCase {
      /**
       * Resources used for validation tests.
       */
      protected ValidatorResources resources = null;
      /**
       * Commons Logging instance.
       */
      protected Log log = LogFactory.getLog(this.getClass());
  
      public TestCommon(String string) {
          super(string);
      }
  
      /**
       * Load <code>ValidatorResources</code> from
       * validator-numeric.xml.
       */
      protected void loadResources(String file) throws IOException, SAXException {
          // Load resources
          InputStream in = null;
  
          try {
              in = this.getClass().getResourceAsStream(file);
              resources = new ValidatorResources(in);
          } catch (IOException e) {
              log.error(e.getMessage(), e);
              throw e;
          } finally {
              if (in != null) {
                  try {
                      in.close();
                  } catch (Exception e) {
                  }
              }
          }
      }
  }
  
  
  
  1.1                  jakarta-commons/validator/src/test/org/apache/commons/validator/TestNumber.java
  
  Index: TestNumber.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/TestNumber.java,v 1.1 2003/09/06 05:17:59 rleland Exp $
   * $Revision: 1.1 $
   * $Date: 2003/09/06 05:17:59 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 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 acknowledgement:
   *       "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, "Apache", "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 name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * 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 org.xml.sax.SAXException;
  
  /**
   *
   * Abstracts number unit tests methods.
   */
  public class TestNumber extends TestCommon {
      /**
       * The key used to retrieve the set of validation
       * rules from the xml file.
       */
      protected String FORM_KEY;
      /**
       * The key used to retrieve the validator action.
       */
      protected String ACTION;
  
  
      public TestNumber(String name) {
          super(name);
      }
  
      /**
       * Load <code>ValidatorResources</code> from 
       * validator-numeric.xml.
       */
      protected void setUp() throws IOException, SAXException {
          // Load resources
          loadResources("validator-numeric.xml");
      }
  
      protected void tearDown() {
      }
  
      /**
       * Tests the number validation.
       */
      public void testNumber() throws ValidatorException {
          // Create bean to run test on.
          ValueBean info = new ValueBean();
          info.setValue("0");
          if (log.isDebugEnabled()) {
              log.debug("testNumberFailure Action=" + ACTION + ", FORM_KEY=" + FORM_KEY);
          }
          valueTest(info, true);
      }
  
      /**
       * Tests the float validation failure.
       */
      public void testNumberFailure() throws ValidatorException {
          // Create bean to run test on.
          ValueBean info = new ValueBean();
          if (log.isDebugEnabled()) {
              log.debug("testNumberFailure Action=" + ACTION + ", FORM_KEY=" + FORM_KEY);
          }
          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.
       */
      protected 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.setParameter(Validator.BEAN_PARAM, 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)));
      }
  
  
  }
  
  
  

Mime
View raw message