01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: 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
42: .getName() });
43: }
44:
45: /**
46: * @return a test suite (<code>TestSuite</code>) that includes all methods
47: * starting with "test"
48: */
49: public static Test suite() {
50: // All methods starting with "test" will be executed in the test suite.
51: return new TestSuite(ShortTest.class);
52: }
53:
54: /**
55: * Tests the short validation.
56: */
57: public void testShortMin() throws ValidatorException {
58: // Create bean to run test on.
59: ValueBean info = new ValueBean();
60: info.setValue(new Short(Short.MIN_VALUE).toString());
61:
62: valueTest(info, true);
63: }
64:
65: /**
66: * Tests the short validation.
67: */
68: public void testShortMax() throws ValidatorException {
69: // Create bean to run test on.
70: ValueBean info = new ValueBean();
71: info.setValue(new Short(Short.MAX_VALUE).toString());
72:
73: valueTest(info, true);
74: }
75:
76: /**
77: * Tests the short validation failure.
78: */
79: public void testShortBeyondMin() throws ValidatorException {
80: // Create bean to run test on.
81: ValueBean info = new ValueBean();
82: info.setValue(Short.MIN_VALUE + "1");
83:
84: valueTest(info, false);
85: }
86:
87: /**
88: * Tests the short validation failure.
89: */
90: public void testShortBeyondMax() throws ValidatorException {
91: // Create bean to run test on.
92: ValueBean info = new ValueBean();
93: info.setValue(Short.MAX_VALUE + "1");
94:
95: valueTest(info, false);
96: }
97: }
|