commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1649284 - in /commons/proper/validator/trunk: RELEASE-NOTES.txt src/changes/changes.xml src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
Date Sun, 04 Jan 2015 03:13:09 GMT
Author: sebb
Date: Sun Jan  4 03:13:09 2015
New Revision: 1649284

URL: http://svn.apache.org/r1649284
Log:
VALIDATOR-344 - AbstractCheckDigit class does not fully test invalid strings
Fix up the testCalculateInvalid() invalid method to allow for 
either invalid checksum or syntax (CheckDigitException) error
when testing the entries in the invalid array.
 

Modified:
    commons/proper/validator/trunk/RELEASE-NOTES.txt
    commons/proper/validator/trunk/src/changes/changes.xml
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java

Modified: commons/proper/validator/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/RELEASE-NOTES.txt?rev=1649284&r1=1649283&r2=1649284&view=diff
==============================================================================
--- commons/proper/validator/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/validator/trunk/RELEASE-NOTES.txt Sun Jan  4 03:13:09 2015
@@ -81,6 +81,11 @@ IMPROVEMENTS OVER PREVIOUS RELEASE
                      Thanks to Sam Cooley
  * [VALIDATOR-334] - UrlValidator: isValidAuthority() returning true when supplied authority
validator fails
                      Clarified documentation: validator is intended as an override
+ * [VALIDATOR-344] - AbstractCheckDigit class does not fully test invalid strings
+                     Fix up the testCalculateInvalid() invalid method to allow for 
+                     either invalid checksum or syntax (CheckDigitException) error
+                     when testing the entries in the invalid array.
+                     
 
 DEPRECATIONS
 ============

Modified: commons/proper/validator/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/changes/changes.xml?rev=1649284&r1=1649283&r2=1649284&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/changes/changes.xml (original)
+++ commons/proper/validator/trunk/src/changes/changes.xml Sun Jan  4 03:13:09 2015
@@ -43,6 +43,12 @@ The <action> type attribute can be add,u
   <body>
 
   <release version="1.4.1" date="tba" description="1.4 Maintenance release">
+    <action issue="VALIDATOR-344" dev="sebb" type="fix" >
+      AbstractCheckDigit class does not fully test invalid strings
+      Fix up the testCalculateInvalid() invalid method to allow for 
+      either invalid checksum or syntax (CheckDigitException) error
+      when testing the entries in the invalid array.
+    </action>
     <action issue="VALIDATOR-297" dev="sebb" type="fix">
       Punycode url is not valid
       Top-level domain regex matching was wrong; did not allow embedded "-" as per RFC2396

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java?rev=1649284&r1=1649283&r2=1649284&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
(original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
Sun Jan  4 03:13:09 2015
@@ -179,13 +179,23 @@ public abstract class AbstractCheckDigit
         // test invalid code values
         for (int i = 0; i < invalid.length; i++) {
             try {
+                final String code = invalid[i];
                 if (log.isDebugEnabled()) {
-                    log.debug("   " + i + " Testing Invalid Check Digit, Code=[" + invalid[i]
+ "]");
+                    log.debug("   " + i + " Testing Invalid Check Digit, Code=[" + code +
"]");
                 }
-                routine.calculate(invalid[i]);
-                fail("Invalid Characters[" + i + "]=" +  invalid[i] + " - expected exception");
-            } catch (Exception e) {
-                assertTrue("Invalid Character[" +i +"]=" +  e.getMessage(), e.getMessage().startsWith("Invalid
Character["));
+                String expected = checkDigit(code);
+                String actual = routine.calculate(removeCheckDigit(code));
+                // If exception not thrown, check that the digit is incorrect instead
+                if (expected.equals(actual)) {
+                    fail("Expected mismatch for " + code + " expected " + expected + " actual
" + actual);
+                }
+            } catch (CheckDigitException e) {
+                // possible failure messages:
+                // Invalid ISBN Length ...
+                // Invalid Character[ ...
+                // Are there any others?
+                assertTrue("Invalid Character[" +i +"]=" +  e.getMessage(), e.getMessage().startsWith("Invalid
"));
+// WAS                assertTrue("Invalid Character[" +i +"]=" +  e.getMessage(), e.getMessage().startsWith("Invalid
Character["));
             }
         }
     }



Mime
View raw message