1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.commons.validator;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 /***
28 * Performs Validation Test for <code>long</code> validations.
29 */
30 public class LongTest extends TestNumber {
31
32 public LongTest(String name) {
33 super(name);
34 FORM_KEY = "longForm";
35 ACTION = "long";
36 }
37
38 /***
39 * Start the tests.
40 *
41 * @param theArgs the arguments. Not used
42 */
43 public static void main(String[] theArgs) {
44 junit.awtui.TestRunner.main(new String[]{LongTest.class.getName()});
45 }
46
47 /***
48 * @return a test suite (<code>TestSuite</code>) that includes all methods
49 * starting with "test"
50 */
51 public static Test suite() {
52
53 return new TestSuite(LongTest.class);
54 }
55
56 /***
57 * Tests the long validation.
58 */
59 public void testLong() throws ValidatorException {
60
61 ValueBean info = new ValueBean();
62 info.setValue("0");
63
64 valueTest(info, true);
65 }
66
67 /***
68 * Tests the long validation.
69 */
70 public void testLongMin() throws ValidatorException {
71
72 ValueBean info = new ValueBean();
73 info.setValue(new Long(Long.MIN_VALUE).toString());
74
75 valueTest(info, true);
76 }
77
78 /***
79 * Tests the long validation.
80 */
81 public void testLongMax() throws ValidatorException {
82
83 ValueBean info = new ValueBean();
84 info.setValue(new Long(Long.MAX_VALUE).toString());
85
86 valueTest(info, true);
87 }
88
89 /***
90 * Tests the long validation failure.
91 */
92 public void testLongFailure() throws ValidatorException {
93
94 ValueBean info = new ValueBean();
95
96 valueTest(info, false);
97 }
98
99 /***
100 * Tests the long validation failure.
101 */
102 public void testLongBeyondMin() throws ValidatorException {
103
104 ValueBean info = new ValueBean();
105 info.setValue(Long.MIN_VALUE + "1");
106
107 valueTest(info, false);
108 }
109
110 /***
111 * Tests the long validation failure.
112 */
113 public void testLongBeyondMax() throws ValidatorException {
114
115 ValueBean info = new ValueBean();
116 info.setValue(Long.MAX_VALUE + "1");
117
118 valueTest(info, false);
119 }
120
121 }