commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r487488 - /jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/routines/checkdigit/CheckDigitTestBase.java
Date Fri, 15 Dec 2006 09:10:03 GMT
Author: niallp
Date: Fri Dec 15 01:10:03 2006
New Revision: 487488

URL: http://svn.apache.org/viewvc?view=rev&rev=487488
Log:
Add debug log messages to the test case to enable generated test data to be checked

Modified:
    jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/routines/checkdigit/CheckDigitTestBase.java

Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/routines/checkdigit/CheckDigitTestBase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/routines/checkdigit/CheckDigitTestBase.java?view=diff&rev=487488&r1=487487&r2=487488
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/routines/checkdigit/CheckDigitTestBase.java
(original)
+++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/routines/checkdigit/CheckDigitTestBase.java
Fri Dec 15 01:10:03 2006
@@ -19,6 +19,8 @@
 import java.util.List;
 import java.util.ArrayList;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import junit.framework.TestCase;
 
@@ -30,6 +32,9 @@
  */
 public class CheckDigitTestBase extends TestCase {
 
+    /** logging instance */
+    protected Log log = LogFactory.getLog(getClass());
+
     /** Check digit routine being tested */
     protected int checkDigitLth = 1;
 
@@ -69,20 +74,32 @@
      * Test method for {@link CheckDigit#isValid(java.lang.String)}.
      */
     public void testIsValid() {
+        if (log.isDebugEnabled()) {
+            log.debug("testIsValid() for " + routine.getClass().getName());
+        }
 
         // test valid values
         for (int i = 0; i < valid.length; i++) {
+            if (log.isDebugEnabled()) {
+                log.debug("   " + i + " Testing Valid Code=[" + valid[i] + "]");
+            }
             assertTrue("valid[" + i +"]: " + valid[i], routine.isValid(valid[i]));
         }
 
         // test invalid code values
         for (int i = 0; i < invalid.length; i++) {
+            if (log.isDebugEnabled()) {
+                log.debug("   " + i + " Testing Invalid Code=[" + invalid[i] + "]");
+            }
             assertFalse("invalid[" + i +"]: " + invalid[i], routine.isValid(invalid[i]));
         }
 
         // test invalid check digit values
         String[] invalidCheckDigits = createInvalidCodes(valid);
         for (int i = 0; i < invalidCheckDigits.length; i++) {
+            if (log.isDebugEnabled()) {
+                log.debug("   " + i + " Testing Invalid Check Digit, Code=[" + invalidCheckDigits[i]
+ "]");
+            }
             assertFalse("invalid check digit[" + i +"]: " + invalidCheckDigits[i], routine.isValid(invalidCheckDigits[i]));
         }
 
@@ -101,12 +118,18 @@
      * Test method for {@link CheckDigit#calculate(java.lang.String)}.
      */
     public void testCalculate() {
+        if (log.isDebugEnabled()) {
+            log.debug("testCalculate() for " + routine.getClass().getName());
+        }
 
         // test valid values
         for (int i = 0; i < valid.length; i++) {
             String code = removeCheckDigit(valid[i]);
             String expected = checkDigit(valid[i]);
             try {
+                if (log.isDebugEnabled()) {
+                    log.debug("   " + i + " Testing Valid Check Digit, Code=[" + code + "]
expected=[" + expected + "]");
+                }
                 assertEquals("valid[" + i +"]: " + valid[i], expected, routine.calculate(code));
             } catch (Exception e) {
                 fail("valid[" + i +"] threw " + e);
@@ -132,6 +155,9 @@
         // test invalid code values
         for (int i = 0; i < invalid.length; i++) {
             try {
+                if (log.isDebugEnabled()) {
+                    log.debug("   " + i + " Testing Invalid Check Digit, Code=[" + invalid[i]
+ "]");
+                }
                 routine.calculate(invalid[i]);
                 fail("Invalid Characters[" + i + "] - expected exception");
             } catch (Exception e) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message