File tree Expand file tree Collapse file tree
src/test/org/apache/commons/cli2/validation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,4 +77,35 @@ public void testMinimumBounds() throws InvalidArgumentException {
7777 }
7878 }
7979 }
80+
81+ public void testMaximumBounds () throws InvalidArgumentException {
82+ final DateValidator validator = new DateValidator (formats );
83+ final Calendar cal = Calendar .getInstance ();
84+
85+ {
86+ final Object [] array = new Object [] { "23/12/03" , "2002-10-12" };
87+ final List list = Arrays .asList (array );
88+ cal .set (2004 , 1 , 12 );
89+ final Date max = cal .getTime ();
90+ validator .setMaximum (max );
91+ validator .validate (list );
92+ }
93+
94+ {
95+ final Object [] array = new Object [] { "23/12/03" , "2004-10-12" };
96+ final List list = Arrays .asList (array );
97+ cal .set (2004 , 1 , 12 );
98+ final Date max = cal .getTime ();
99+ validator .setMaximum (max );
100+
101+ try {
102+ validator .validate (list );
103+ fail ("maximum out of bounds exception not caught" );
104+ }
105+ catch (final InvalidArgumentException exp ) {
106+ assertEquals ("Out of range: 2004-10-12" , exp .getMessage ());
107+ }
108+ }
109+ }
110+
80111}
You can’t perform that action at this time.
0 commit comments