1 21 22 23 package org.apache.commons.validator; 24 25 import junit.framework.Test; 26 import junit.framework.TestSuite; 27 28 29 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 45 public static void main(String [] theArgs) { 46 junit.awtui.TestRunner.main(new String []{ByteTest.class.getName()}); 47 } 48 49 53 public static Test suite() { 54 return new TestSuite(ByteTest.class); 56 } 57 58 59 62 public void testByte() throws ValidatorException { 63 ValueBean info = new ValueBean(); 65 info.setValue("0"); 66 67 valueTest(info, true); 68 } 69 70 73 public void testByteMin() throws ValidatorException { 74 ValueBean info = new ValueBean(); 76 info.setValue(new Byte (Byte.MIN_VALUE).toString()); 77 78 valueTest(info, true); 79 } 80 81 84 public void testByteMax() throws ValidatorException { 85 ValueBean info = new ValueBean(); 87 info.setValue(new Byte (Byte.MAX_VALUE).toString()); 88 89 valueTest(info, true); 90 } 91 92 95 public void testByteFailure() throws ValidatorException { 96 ValueBean info = new ValueBean(); 98 99 valueTest(info, false); 100 } 101 102 105 public void testByteBeyondMin() throws ValidatorException { 106 ValueBean info = new ValueBean(); 108 info.setValue(Byte.MIN_VALUE + "1"); 109 110 valueTest(info, false); 111 } 112 113 116 public void testByteBeyondMax() throws ValidatorException { 117 ValueBean info = new ValueBean(); 119 info.setValue(Byte.MAX_VALUE + "1"); 120 121 valueTest(info, false); 122 } 123 124 } | Popular Tags |