You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/01/29 16:23:35 UTC

svn commit: r1562475 - in /commons/proper/validator/trunk/src: changes/changes.xml test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java

Author: sebb
Date: Wed Jan 29 15:23:35 2014
New Revision: 1562475

URL: http://svn.apache.org/r1562475
Log:
VALIDATOR-331 IBANCheckDigitTest.createInvalidCodes(String[] codes) uses wrong values

Modified:
    commons/proper/validator/trunk/src/changes/changes.xml
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java

Modified: commons/proper/validator/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/changes/changes.xml?rev=1562475&r1=1562474&r2=1562475&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/changes/changes.xml (original)
+++ commons/proper/validator/trunk/src/changes/changes.xml Wed Jan 29 15:23:35 2014
@@ -42,7 +42,13 @@ The <action> type attribute can be add,u
 
   <body>
 
-  <release version="1.4.0" date="in SVN" description="JDK 1.4 (minimum)">
+  <release version="1.4.1" date="TBA" description="TBA">
+    <action dev="sebb" type="fix" issue="VALIDATOR-331">
+      IBANCheckDigitTest.createInvalidCodes(String[] codes) uses wrong values
+    </action>
+  </release>
+
+  <release version="1.4.0" date="2012-02-03" description="JDK 1.4 (minimum)">
     <action dev="simonetripodi" type="fix" issue="VALIDATOR-301" due-to="Jacob Zwiers">
       CheckStyle and FindBug Issues - inner classes and key sets
     </action>

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java?rev=1562475&r1=1562474&r2=1562475&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java (original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java Wed Jan 29 15:23:35 2014
@@ -78,6 +78,19 @@ public class IBANCheckDigitTest extends 
                 "SE3550000000054910000003",      // Sweden
                 "SI56191000000123438",           // Slovenia
                 "SK3112000000198742637541",      // Slovak Republic
+                
+                // Codes AA and ZZ will never be used as ISO countries nor in IBANs
+                // add some dummy calculated codes to test the limits
+                // Current minimum length is Norway = 15
+                // Current maximum length is Malta  = 31
+                // N.B. These codes will fail online checkers which validate the IBAN format
+                //234567890123456789012345678901
+                "AA0200000000053",
+                "AA9700000000089",
+                "AA9800000000071",
+                "ZZ02ZZZZZZZZZZZZZZZZZZZZZZZZZ04",
+                "ZZ97ZZZZZZZZZZZZZZZZZZZZZZZZZ40",
+                "ZZ98ZZZZZZZZZZZZZZZZZZZZZZZZZ22",
                 };
         /*
          *  sources
@@ -95,6 +108,19 @@ public class IBANCheckDigitTest extends 
      */
     public void testZeroSum() {
         // ignore, don't run this test
+        
+        // example code used to create dummy IBANs
+//        try {
+//            for(int i=0; i<97;i++) {
+//                String check = String.format("ZZ00ZZZZZZZZZZZZZZZZZZZZZZZZZ%02d", new Object[]{Integer.valueOf(i)});
+//                String chk = routine.calculate(check);
+//                if (chk.equals("97")||chk.equals("98")||chk.equals("02")) {
+//                    System.out.println(check+ " "+chk);
+//                }
+//            }
+//        } catch (CheckDigitException e) {
+//            e.printStackTrace();
+//        }
     }
 
     /**
@@ -110,7 +136,7 @@ public class IBANCheckDigitTest extends 
         for (int i = 0; i < codes.length; i++) {
             String code = removeCheckDigit(codes[i]);
             String check  = checkDigit(codes[i]);
-            for (int j = 0; j < 96; j++) {
+            for (int j = 2; j <= 98; j++) { // check digits can be from 02-98 (00 and 01 are not possible)
                 String curr =  j > 9 ? "" + j : "0" + j;
                 if (!curr.equals(check)) {
                     list.add(code.substring(0, 2) + curr + code.substring(4));