1 /* 2 * $Header: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/ByteTest.java,v 1.14 2004/02/21 17:10:30 rleland Exp $ 3 * $Revision: 1.14 $ 4 * $Date: 2004/02/21 17:10:30 $ 5 * 6 * ==================================================================== 7 * Copyright 2001-2004 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 23 package org.apache.commons.validator; 24 25 import junit.framework.Test; 26 import junit.framework.TestSuite; 27 28 29 /*** 30 * Performs Validation Test for <code>byte</code> validations. 31 */ 32 public class ByteTest extends TestNumber { 33 34 public ByteTest(String name) { 35 super(name); 36 ACTION = "byte"; 37 FORM_KEY = "byteForm"; 38 } 39 40 /*** 41 * Start the tests. 42 * 43 * @param theArgs the arguments. Not used 44 */ 45 public static void main(String[] theArgs) { 46 junit.awtui.TestRunner.main(new String[]{ByteTest.class.getName()}); 47 } 48 49 /*** 50 * @return a test suite (<code>TestSuite</code>) that includes all methods 51 * starting with "test" 52 */ 53 public static Test suite() { 54 // All methods starting with "test" will be executed in the test suite. 55 return new TestSuite(ByteTest.class); 56 } 57 58 59 /*** 60 * Tests the byte validation. 61 */ 62 public void testByte() throws ValidatorException { 63 // Create bean to run test on. 64 ValueBean info = new ValueBean(); 65 info.setValue("0"); 66 67 valueTest(info, true); 68 } 69 70 /*** 71 * Tests the byte validation. 72 */ 73 public void testByteMin() throws ValidatorException { 74 // Create bean to run test on. 75 ValueBean info = new ValueBean(); 76 info.setValue(new Byte(Byte.MIN_VALUE).toString()); 77 78 valueTest(info, true); 79 } 80 81 /*** 82 * Tests the byte validation. 83 */ 84 public void testByteMax() throws ValidatorException { 85 // Create bean to run test on. 86 ValueBean info = new ValueBean(); 87 info.setValue(new Byte(Byte.MAX_VALUE).toString()); 88 89 valueTest(info, true); 90 } 91 92 /*** 93 * Tests the byte validation failure. 94 */ 95 public void testByteFailure() throws ValidatorException { 96 // Create bean to run test on. 97 ValueBean info = new ValueBean(); 98 99 valueTest(info, false); 100 } 101 102 /*** 103 * Tests the byte validation failure. 104 */ 105 public void testByteBeyondMin() throws ValidatorException { 106 // Create bean to run test on. 107 ValueBean info = new ValueBean(); 108 info.setValue(Byte.MIN_VALUE + "1"); 109 110 valueTest(info, false); 111 } 112 113 /*** 114 * Tests the byte validation failure. 115 */ 116 public void testByteBeyondMax() throws ValidatorException { 117 // Create bean to run test on. 118 ValueBean info = new ValueBean(); 119 info.setValue(Byte.MAX_VALUE + "1"); 120 121 valueTest(info, false); 122 } 123 124 }

This page was automatically generated by Maven