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   * Performs Validation Test for <code>byte</code> validations.
23   *
24   * @version $Revision$
25   */
26  public class ByteTest extends AbstractNumberTest {
27  
28      public ByteTest(String name) {
29          super(name);
30          ACTION = "byte";
31          FORM_KEY = "byteForm";
32      }
33  
34      /**
35       * Tests the byte validation.
36       */
37      public void testByte() throws ValidatorException {
38          // Create bean to run test on.
39          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
40          info.setValue("0");
41  
42          valueTest(info, true);
43      }
44  
45      /**
46       * Tests the byte validation.
47       */
48      public void testByteMin() throws ValidatorException {
49          // Create bean to run test on.
50          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
51          info.setValue(Byte.valueOf(Byte.MIN_VALUE).toString());
52  
53          valueTest(info, true);
54      }
55  
56      /**
57       * Tests the byte validation.
58       */
59      public void testByteMax() throws ValidatorException {
60          // Create bean to run test on.
61          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
62          info.setValue(Byte.valueOf(Byte.MAX_VALUE).toString());
63  
64          valueTest(info, true);
65      }
66  
67      /**
68       * Tests the byte validation failure.
69       */
70      public void testByteFailure() throws ValidatorException {
71          // Create bean to run test on.
72          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
73  
74          valueTest(info, false);
75      }
76  
77      /**
78       * Tests the byte validation failure.
79       */
80      public void testByteBeyondMin() throws ValidatorException {
81          // Create bean to run test on.
82          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
83          info.setValue(Byte.MIN_VALUE + "1");
84  
85          valueTest(info, false);
86      }
87  
88      /**
89       * Tests the byte validation failure.
90       */
91      public void testByteBeyondMax() throws ValidatorException {
92          // Create bean to run test on.
93          ValueBeanValueBean.html#ValueBean">ValueBean info = new ValueBean();
94          info.setValue(Byte.MAX_VALUE + "1");
95  
96          valueTest(info, false);
97      }
98  
99  }