KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: DoubleTest.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 package org.apache.commons.validator;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 /**
28  * Performs Validation Test for <code>double</code> validations.
29  */

30 public class DoubleTest extends TestNumber {
31
32     public DoubleTest(String JavaDoc name) {
33         super(name);
34         ACTION = "double";
35         FORM_KEY = "doubleForm";
36     }
37
38
39     /**
40      * Start the tests.
41      *
42      * @param theArgs the arguments. Not used
43      */

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

52     public static Test suite() {
53         // All methods starting with "test" will be executed in the test suite.
54
return new TestSuite(DoubleTest.class);
55     }
56
57
58     /**
59      * Tests the double validation.
60      */

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

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

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

94     public void testDoubleFailure() throws ValidatorException {
95         // Create bean to run test on.
96
ValueBean info = new ValueBean();
97
98         valueTest(info, false);
99     }
100
101 }
Popular Tags