001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.commons.validator;
018:
019: import junit.framework.Test;
020: import junit.framework.TestSuite;
021:
022: /**
023: * Performs Validation Test for <code>long</code> validations.
024: *
025: * @version $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
026: */
027: public class LongTest extends TestNumber {
028:
029: public LongTest(String name) {
030: super (name);
031: FORM_KEY = "longForm";
032: ACTION = "long";
033: }
034:
035: /**
036: * Start the tests.
037: *
038: * @param theArgs the arguments. Not used
039: */
040: public static void main(String[] theArgs) {
041: junit.awtui.TestRunner.main(new String[] { LongTest.class
042: .getName() });
043: }
044:
045: /**
046: * @return a test suite (<code>TestSuite</code>) that includes all methods
047: * starting with "test"
048: */
049: public static Test suite() {
050: // All methods starting with "test" will be executed in the test suite.
051: return new TestSuite(LongTest.class);
052: }
053:
054: /**
055: * Tests the long validation.
056: */
057: public void testLong() throws ValidatorException {
058: // Create bean to run test on.
059: ValueBean info = new ValueBean();
060: info.setValue("0");
061:
062: valueTest(info, true);
063: }
064:
065: /**
066: * Tests the long validation.
067: */
068: public void testLongMin() throws ValidatorException {
069: // Create bean to run test on.
070: ValueBean info = new ValueBean();
071: info.setValue(new Long(Long.MIN_VALUE).toString());
072:
073: valueTest(info, true);
074: }
075:
076: /**
077: * Tests the long validation.
078: */
079: public void testLongMax() throws ValidatorException {
080: // Create bean to run test on.
081: ValueBean info = new ValueBean();
082: info.setValue(new Long(Long.MAX_VALUE).toString());
083:
084: valueTest(info, true);
085: }
086:
087: /**
088: * Tests the long validation failure.
089: */
090: public void testLongFailure() throws ValidatorException {
091: // Create bean to run test on.
092: ValueBean info = new ValueBean();
093:
094: valueTest(info, false);
095: }
096:
097: /**
098: * Tests the long validation failure.
099: */
100: public void testLongBeyondMin() throws ValidatorException {
101: // Create bean to run test on.
102: ValueBean info = new ValueBean();
103: info.setValue(Long.MIN_VALUE + "1");
104:
105: valueTest(info, false);
106: }
107:
108: /**
109: * Tests the long validation failure.
110: */
111: public void testLongBeyondMax() throws ValidatorException {
112: // Create bean to run test on.
113: ValueBean info = new ValueBean();
114: info.setValue(Long.MAX_VALUE + "1");
115:
116: valueTest(info, false);
117: }
118:
119: }
|