KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > validator > IntegerTest


1 /*
2  * $Id: IntegerTest.java 155434 2005-02-26 13:16:41Z dirkv $
3  * $Rev$
4  * $Date: 2005-02-26 05:16:41 -0800 (Sat, 26 Feb 2005) $
5  *
6  * ====================================================================
7  * Copyright 2001-2005 The Apache Software Foundation
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22
23 package org.apache.commons.validator;
24
25
26 import junit.framework.Test;
27 import junit.framework.TestSuite;
28
29
30 /**
31  * Performs Validation Test for <code>int</code> validations.
32  */

33 public class IntegerTest extends TestNumber {
34
35
36     public IntegerTest(String JavaDoc name) {
37         super(name);
38         FORM_KEY = "intForm";
39         ACTION = "int";
40     }
41
42     /**
43      * Start the tests.
44      *
45      * @param theArgs the arguments. Not used
46      */

47     public static void main(String JavaDoc[] theArgs) {
48         junit.awtui.TestRunner.main(new String JavaDoc[]{IntegerTest.class.getName()});
49     }
50
51     /**
52      * @return a test suite (<code>TestSuite</code>) that includes all methods
53      * starting with "test"
54      */

55     public static Test suite() {
56         // All methods starting with "test" will be executed in the test suite.
57
return new TestSuite(IntegerTest.class);
58     }
59
60     /**
61      * Tests the int validation.
62      */

63     public void testInt() throws ValidatorException {
64         // Create bean to run test on.
65
ValueBean info = new ValueBean();
66         info.setValue("0");
67
68         valueTest(info, true);
69     }
70
71     /**
72      * Tests the int validation.
73      */

74     public void testIntMin() throws ValidatorException {
75         // Create bean to run test on.
76
ValueBean info = new ValueBean();
77         info.setValue(new Integer JavaDoc(Integer.MIN_VALUE).toString());
78
79         valueTest(info, true);
80     }
81
82     /**
83      * Tests the int validation.
84      */

85     public void testIntegerMax() throws ValidatorException {
86         // Create bean to run test on.
87
ValueBean info = new ValueBean();
88         info.setValue(new Integer JavaDoc(Integer.MAX_VALUE).toString());
89
90         valueTest(info, true);
91     }
92
93     /**
94      * Tests the int validation failure.
95      */

96     public void testIntFailure() throws ValidatorException {
97         // Create bean to run test on.
98
ValueBean info = new ValueBean();
99
100         valueTest(info, false);
101     }
102
103     /**
104      * Tests the int validation failure.
105      */

106     public void testIntBeyondMin() throws ValidatorException {
107         // Create bean to run test on.
108
ValueBean info = new ValueBean();
109         info.setValue(Integer.MIN_VALUE + "1");
110
111         valueTest(info, false);
112     }
113
114     /**
115      * Tests the int validation failure.
116      */

117     public void testIntBeyondMax() throws ValidatorException {
118         // Create bean to run test on.
119
ValueBean info = new ValueBean();
120         info.setValue(Integer.MAX_VALUE + "1");
121
122         valueTest(info, false);
123     }
124
125 }
Popular Tags