1 21 22 23 package org.apache.commons.validator; 24 25 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 29 30 33 public class IntegerTest extends TestNumber { 34 35 36 public IntegerTest(String name) { 37 super(name); 38 FORM_KEY = "intForm"; 39 ACTION = "int"; 40 } 41 42 47 public static void main(String [] theArgs) { 48 junit.awtui.TestRunner.main(new String []{IntegerTest.class.getName()}); 49 } 50 51 55 public static Test suite() { 56 return new TestSuite(IntegerTest.class); 58 } 59 60 63 public void testInt() throws ValidatorException { 64 ValueBean info = new ValueBean(); 66 info.setValue("0"); 67 68 valueTest(info, true); 69 } 70 71 74 public void testIntMin() throws ValidatorException { 75 ValueBean info = new ValueBean(); 77 info.setValue(new Integer (Integer.MIN_VALUE).toString()); 78 79 valueTest(info, true); 80 } 81 82 85 public void testIntegerMax() throws ValidatorException { 86 ValueBean info = new ValueBean(); 88 info.setValue(new Integer (Integer.MAX_VALUE).toString()); 89 90 valueTest(info, true); 91 } 92 93 96 public void testIntFailure() throws ValidatorException { 97 ValueBean info = new ValueBean(); 99 100 valueTest(info, false); 101 } 102 103 106 public void testIntBeyondMin() throws ValidatorException { 107 ValueBean info = new ValueBean(); 109 info.setValue(Integer.MIN_VALUE + "1"); 110 111 valueTest(info, false); 112 } 113 114 117 public void testIntBeyondMax() throws ValidatorException { 118 ValueBean info = new ValueBean(); 120 info.setValue(Integer.MAX_VALUE + "1"); 121 122 valueTest(info, false); 123 } 124 125 } | Popular Tags |