Skip to content

Commit cce36ec

Browse files
author
John Keyes
committed
- added tests
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@278635 13f79535-47bb-0310-9956-ffa450edef68
1 parent e3f4d1c commit cce36ec

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/test/org/apache/commons/cli2/validation/DateValidatorTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* Copyright 2003-2004 The Apache Software Foundation
1+
/*
2+
* Copyright 2003-2005 The Apache Software Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,6 +28,8 @@
2828
import junit.framework.TestSuite;
2929

3030
/**
31+
* JUnit test case for DateValidator.
32+
*
3133
* @author Rob Oxspring
3234
* @author John Keyes
3335
*/
@@ -123,6 +125,8 @@ public void testMinimumBounds() throws InvalidArgumentException {
123125
cal.set(2002, 1, 12);
124126
final Date min = cal.getTime();
125127
validator.setMinimum(min);
128+
assertTrue("maximum bound is set", validator.getMaximum() == null);
129+
assertEquals("minimum bound is incorrect", min, validator.getMinimum());
126130
validator.validate(list);
127131
}
128132

@@ -143,6 +147,11 @@ public void testMinimumBounds() throws InvalidArgumentException {
143147
}
144148
}
145149

150+
public void testFormats() throws InvalidArgumentException {
151+
final DateValidator validator = new DateValidator(formats);
152+
assertEquals("date formats are incorrect", formats, validator.getFormats());
153+
}
154+
146155
public void testMaximumBounds() throws InvalidArgumentException {
147156
final DateValidator validator = new DateValidator(formats);
148157
final Calendar cal = Calendar.getInstance();
@@ -153,6 +162,8 @@ public void testMaximumBounds() throws InvalidArgumentException {
153162
cal.set(2004, 1, 12);
154163
final Date max = cal.getTime();
155164
validator.setMaximum(max);
165+
assertTrue("minimum bound is set", validator.getMinimum() == null);
166+
assertEquals("maximum bound is incorrect", max, validator.getMaximum());
156167
validator.validate(list);
157168
}
158169

src/test/org/apache/commons/cli2/validation/FileValidatorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public void testValidate_WritableFile() {
9595
assertTrue("is a file validator", validator.isFile());
9696
assertTrue("is an existing file validator", validator.isExisting());
9797
assertFalse("is not a hidden file validator", validator.isHidden());
98-
assertTrue("is not a readable file validator", validator.isReadable());
99-
assertFalse("is a writable file validator", validator.isWritable());
98+
assertFalse("is not a readable file validator", validator.isReadable());
99+
assertTrue("is a writable file validator", validator.isWritable());
100100

101101
try{
102102
validator.validate(list);

0 commit comments

Comments
 (0)