[ 
https://issues.apache.org/jira/browse/VALIDATOR-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14263735#comment-14263735
 ] 

Sebb commented on VALIDATOR-344:
--------------------------------

Fix issue 2)
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


> AbstractCheckDigit class does not fully test invalid strings
> ------------------------------------------------------------
>
>                 Key: VALIDATOR-344
>                 URL: https://issues.apache.org/jira/browse/VALIDATOR-344
>             Project: Commons Validator
>          Issue Type: Bug
>            Reporter: Sebb
>         Attachments: Validator-344-1.patch
>
>
> The AbstractCheckDigit class does not fully test invalid check digits.
> There are several aspects to this:
> 1. the createInvalidCodes method only checks for invalid digits - it does not 
> try alphabetics, for example
> 2. the "invalid" String array entries are passed unchanged to both the 
> calculate() method - which expects a string without the check digit - and to 
> the isValid() method, which expects the string to contain the check digit. As 
> a result, only strings which are syntactically invalid will generate an 
> Exception and thereby pass the test.
> 3. testMissingCode does not call isInvalid() with a string length of 1. I 
> assume the empty string should not have a check digit.
> Case 1) can be (partially) solved by including other printable characters in 
> the generated output.
> Case 2) can (I think) be solved by assuming that the string always includes 
> the check character, and stripping this off before passing it to calculate(). 
> If the method does not throw an Exception, then the test must check that the 
> calculated character does not agree. It may not be possible to check all 
> types of invalid input this way, but at least it should be more robust than 
> the current test case. Additional test cases can be added to separately test 
> calculate() and isValid() if it proves necessary.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to