View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.validator;
18  
19  
20  
21  
22  /**                                                       
23   * Performs Validation Test for <code>int</code> validations.
24   *
25   * @version $Revision$
26   */
27  public class IntegerTest extends AbstractNumberTest {
28  
29  
30      public IntegerTest(String name) {
31          super(name);
32          FORM_KEY = "intForm";
33          ACTION = "int";
34      }
35  
36      /**
37       * Tests the int validation.
38       */
39      public void testInt() throws ValidatorException {
40          // Create bean to run test on.
41          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
42          info.setValue("0");
43  
44          valueTest(info, true);
45      }
46  
47      /**
48       * Tests the int validation.
49       */
50      public void testIntMin() throws ValidatorException {
51          // Create bean to run test on.
52          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
53          info.setValue(Integer.valueOf(Integer.MIN_VALUE).toString());
54  
55          valueTest(info, true);
56      }
57  
58      /**
59       * Tests the int validation.
60       */
61      public void testIntegerMax() throws ValidatorException {
62          // Create bean to run test on.
63          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
64          info.setValue(Integer.valueOf(Integer.MAX_VALUE).toString());
65  
66          valueTest(info, true);
67      }
68  
69      /**
70       * Tests the int validation failure.
71       */
72      public void testIntFailure() throws ValidatorException {
73          // Create bean to run test on.
74          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
75  
76          valueTest(info, false);
77      }
78  
79      /**
80       * Tests the int validation failure.
81       */
82      public void testIntBeyondMin() throws ValidatorException {
83          // Create bean to run test on.
84          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
85          info.setValue(Integer.MIN_VALUE + "1");
86  
87          valueTest(info, false);
88      }
89  
90      /**
91       * Tests the int validation failure.
92       */
93      public void testIntBeyondMax() throws ValidatorException {
94          // Create bean to run test on.
95          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
96          info.setValue(Integer.MAX_VALUE + "1");
97  
98          valueTest(info, false);
99      }
100 
101 }