commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject svn commit: r191209 - /jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/DateValidatorTest.java
Date Fri, 17 Jun 2005 21:22:20 GMT
Author: jkeyes
Date: Fri Jun 17 14:22:19 2005
New Revision: 191209

URL: http://svn.apache.org/viewcvs?rev=191209&view=rev
Log:
- added test for maximum date

Modified:
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/DateValidatorTest.java

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/DateValidatorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/DateValidatorTest.java?rev=191209&r1=191208&r2=191209&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/DateValidatorTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/DateValidatorTest.java
Fri Jun 17 14:22:19 2005
@@ -77,4 +77,35 @@
             }
         }
     }
+
+    public void testMaximumBounds() throws InvalidArgumentException {
+        final DateValidator validator = new DateValidator(formats);
+        final Calendar cal = Calendar.getInstance();
+
+        {
+            final Object[] array = new Object[] { "23/12/03", "2002-10-12" };
+            final List list = Arrays.asList(array);
+            cal.set(2004, 1, 12);
+            final Date max = cal.getTime();
+            validator.setMaximum(max);
+            validator.validate(list);
+        }
+
+        {
+            final Object[] array = new Object[] { "23/12/03", "2004-10-12" };
+            final List list = Arrays.asList(array);
+            cal.set(2004, 1, 12);
+            final Date max = cal.getTime();
+            validator.setMaximum(max);
+
+            try {
+                validator.validate(list);
+                fail("maximum out of bounds exception not caught");
+            }
+            catch (final InvalidArgumentException exp) {
+                assertEquals("Out of range: 2004-10-12", exp.getMessage());
+            }
+        }
+    }
+
 }



---------------------------------------------------------------------
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