1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.validator;
18
19 import junit.framework.Test;
20 import junit.framework.TestSuite;
21
22 /***
23 * Performs Validation Test for <code>short</code> validations.
24 *
25 * @version $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
26 */
27 public class ShortTest extends TestNumber {
28
29 public ShortTest(String name) {
30 super(name);
31 FORM_KEY = "shortForm";
32 ACTION = "short";
33 }
34
35 /***
36 * Start the tests.
37 *
38 * @param theArgs the arguments. Not used
39 */
40 public static void main(String[] theArgs) {
41 junit.awtui.TestRunner.main(new String[] {ShortTest.class.getName()});
42 }
43
44 /***
45 * @return a test suite (<code>TestSuite</code>) that includes all methods
46 * starting with "test"
47 */
48 public static Test suite() {
49
50 return new TestSuite(ShortTest.class);
51 }
52
53 /***
54 * Tests the short validation.
55 */
56 public void testShortMin() throws ValidatorException {
57
58 ValueBean info = new ValueBean();
59 info.setValue(new Short(Short.MIN_VALUE).toString());
60
61 valueTest(info, true);
62 }
63
64 /***
65 * Tests the short validation.
66 */
67 public void testShortMax() throws ValidatorException {
68
69 ValueBean info = new ValueBean();
70 info.setValue(new Short(Short.MAX_VALUE).toString());
71
72 valueTest(info, true);
73 }
74
75 /***
76 * Tests the short validation failure.
77 */
78 public void testShortBeyondMin() throws ValidatorException {
79
80 ValueBean info = new ValueBean();
81 info.setValue(Short.MIN_VALUE + "1");
82
83 valueTest(info, false);
84 }
85
86 /***
87 * Tests the short validation failure.
88 */
89 public void testShortBeyondMax() throws ValidatorException {
90
91 ValueBean info = new ValueBean();
92 info.setValue(Short.MAX_VALUE + "1");
93
94 valueTest(info, false);
95 }
96 }