Author: niallp
Date: Fri Dec 15 06:03:57 2006
New Revision: 487559

URL: http://svn.apache.org/viewvc?view=rev&rev=487559
Log:
Split up test methods in base check digit tests case and make zero-sum check 
optional

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=487559&r1=487558&r2=487559
==============================================================================
--- 
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 06:03:57 2006
@@ -71,11 +71,11 @@
     }
 
     /**
-     * Test method for [EMAIL PROTECTED] CheckDigit#isValid(java.lang.String)}.
+     * Test isValid() for valid values.
      */
-    public void testIsValid() {
+    public void testIsValidTrue() {
         if (log.isDebugEnabled()) {
-            log.debug("testIsValid() for " + routine.getClass().getName());
+            log.debug("testIsValidTrue() for " + routine.getClass().getName());
         }
 
         // test valid values
@@ -85,6 +85,15 @@
             }
             assertTrue("valid[" + i +"]: " + valid[i], 
routine.isValid(valid[i]));
         }
+    }
+
+    /**
+     * Test isValid() for invalid values.
+     */
+    public void testIsValidFalse() {
+        if (log.isDebugEnabled()) {
+            log.debug("testIsValidFalse() for " + 
routine.getClass().getName());
+        }
 
         // test invalid code values
         for (int i = 0; i < invalid.length; i++) {
@@ -110,16 +119,18 @@
         assertFalse("Test Zero Length", routine.isValid(""));
         
         // test zero sum
-        assertFalse("Test Zero Sum", routine.isValid(zeroSum));
+        if (zeroSum != null) {
+            assertFalse("Test Zero Sum", routine.isValid(zeroSum));
+        }
 
     }
 
     /**
-     * Test method for [EMAIL PROTECTED] 
CheckDigit#calculate(java.lang.String)}.
+     * Test calculate() for valid values.
      */
-    public void testCalculate() {
+    public void testCalculateValid() {
         if (log.isDebugEnabled()) {
-            log.debug("testCalculate() for " + routine.getClass().getName());
+            log.debug("testCalculateValid() for " + 
routine.getClass().getName());
         }
 
         // test valid values
@@ -136,6 +147,17 @@
             }
         }
 
+    }
+
+    /**
+     * Test calculate() for invalid values.
+     */
+    public void testCalculateInvalid() {
+
+        if (log.isDebugEnabled()) {
+            log.debug("testCalculateInvalid() for " + 
routine.getClass().getName());
+        }
+
         // test null
         try {
             routine.calculate(null);
@@ -159,19 +181,22 @@
                     log.debug("   " + i + " Testing Invalid Check Digit, 
Code=[" + invalid[i] + "]");
                 }
                 routine.calculate(invalid[i]);
-                fail("Invalid Characters[" + i + "] - expected exception");
+                fail("Invalid Characters[" + i + "]=" +  invalid[i] + " - 
expected exception");
             } catch (Exception e) {
                 assertTrue("Invalid Character[" +i +"]", 
e.getMessage().startsWith("Invalid Character["));
             }
         }
 
         // test zero sum
-        try {
-            routine.calculate(zeroSum);
-            fail("Zero Sum - expected exception");
-        } catch (Exception e) {
-            assertEquals("Zero Length",  "Invalid code, sum is zero", 
e.getMessage());
+        if (zeroSum != null) {
+            try {
+                routine.calculate(zeroSum);
+                fail("Zero Sum - expected exception");
+            } catch (Exception e) {
+                assertEquals("Zero Length",  "Invalid code, sum is zero", 
e.getMessage());
+            }
         }
+
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to