1 16 17 package test.types; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.types.NonNegativeInteger; 21 22 25 public class TestNonNegativeInteger extends TestCase { 26 27 public TestNonNegativeInteger(String name) { 28 super(name); 29 } 30 31 34 private void runFailTest(String value) throws Exception { 35 NonNegativeInteger oNonNegativeInteger = null; 36 try { 37 oNonNegativeInteger = new NonNegativeInteger(value); 38 } 39 catch (Exception e) { } 41 assertNull("validation restriction failed [" + 43 value + "]. did not restrict bad value.", oNonNegativeInteger); 44 } 45 46 49 private void runPassTest(String value) throws Exception { 50 NonNegativeInteger oNonNegativeInteger = null; 51 try { 52 oNonNegativeInteger = new NonNegativeInteger(value); 53 } 54 catch (Exception e) { } 56 assertEquals("unsigned int not equal" + 57 value, oNonNegativeInteger.toString(), value); 58 } 59 60 63 public void testPositiveValue() throws Exception { 64 runPassTest("12345678901234567890"); 65 } 66 67 70 public void testNegativeValue() throws Exception { 71 runFailTest("-123"); 72 } 73 74 75 78 public void testMinExclusive() throws Exception { 79 runPassTest("0"); 80 } 81 82 85 public void testBelowMinExclusive() throws Exception { 86 runFailTest("-1"); 87 } 88 89 } 90 | Popular Tags |