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 EmailTest.java
Date Fri, 22 Aug 2003 04:22:42 GMT
rleland     2003/08/21 21:22:42

  Modified:    validator/src/test/org/apache/commons/validator
                        EmailTest.java
  Log:
  Cleanup tests I had slightly misinterpreted RFC822 at first.
  
  Revision  Changes    Path
  1.18      +53 -23    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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- EmailTest.java	17 Aug 2003 04:21:05 -0000	1.17
  +++ EmailTest.java	22 Aug 2003 04:22:42 -0000	1.18
  @@ -202,9 +202,9 @@
         valueTest(info, true);
   
         info.setValue("andy-noble@data-workshop.-com");
  -       valueTest(info, false);
  +       valueTest(info, true);
          info.setValue("andy-noble@data-workshop.c-om");
  -       valueTest(info, false);
  +       valueTest(info,true);
          info.setValue("andy-noble@data-workshop.co-m");
          valueTest(info, true);
   
  @@ -261,8 +261,6 @@
       /**
        * Write this test according to parts of RFC, as opposed to the type of character
        * that is being tested.
  -     * According to RFC 1738 a user name can be composed of the following :
  -     *  *[alpha | digit | "$" | "-" | "_" | "." | "+"  | "!" | "*" | "'" | "(" | ")" |
"," | "%" hex hex | ";" | "?" | "&" | "=" ]
   
        * @throws ValidatorException
        */
  @@ -276,32 +274,64 @@
           valueTest(info, true);
           info.setValue("joe_@apache.org");
           valueTest(info, true);
  +
  +        //UnQuoted Special characters are invalid
  +
           info.setValue("joe.@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe+@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe!@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe*@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe'@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe(@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe)@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe,@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe%45@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe;@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe?@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe&@apache.org");
  -        valueTest(info, true);
  +        valueTest(info, false);
           info.setValue("joe=@apache.org");
  +        valueTest(info, false);
  +
  +        //Quoted Special characters are valid
  +        info.setValue("\"joe.\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe+\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe!\"@apache.org");
           valueTest(info, true);
  +        info.setValue("\"joe*\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe'\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe(\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe)\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe,\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe%45\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe;\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe?\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe&\"@apache.org");
  +        valueTest(info, true);
  +        info.setValue("\"joe=\"@apache.org");
  +        valueTest(info, true);
  +
   
       }
   
  @@ -313,7 +343,7 @@
       * @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 {
  +   private void valueTest(ValueBean info, boolean passed) throws ValidatorException {
         // Construct validator based on the loaded resources 
         // and the form key
         Validator validator = new Validator(resources, FORM_KEY);
  @@ -335,7 +365,7 @@
         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)));
  +      assertTrue("Value "+info.getValue()+" ValidatorResult should contain the '" + ACTION
+"' action.", result.containsAction(ACTION));
  +      assertTrue("Value "+info.getValue()+"ValidatorResult for the '" + ACTION +"' action
should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
      }
   }                                                         
  
  
  

Mime
View raw message