1 16 17 package test.types; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.types.Token; 21 22 25 public class TestToken extends TestCase { 26 27 28 public TestToken(String name) { 29 super(name); 30 } 31 32 35 private void runFailTest(String value) throws Exception { 36 Token oToken = null; 37 try { 38 oToken = new Token(value); 39 } 40 catch (Exception e) { } 42 assertNull( 43 "Token validation restriction failed. did not restrict bad value [" + 44 value + "] did not restrict bad value", oToken); 45 } 46 47 50 private void runPassTest(String value) throws Exception { 51 Token oToken = null; 52 try { 53 oToken = new Token(value); 54 } 55 catch (Exception e) { } 57 assertEquals("Token strings not equal. orig value:" + value, oToken.toString(), value); 58 } 59 60 63 public void testSimpleString() throws Exception { 64 runPassTest("a simple string"); 65 } 66 67 70 public void testCarriageString() throws Exception { 71 runPassTest("a carriage return\r string\r"); 72 } 73 74 77 public void testLineFeed() throws Exception { 78 runFailTest("line one\n line two"); 79 } 80 81 84 public void testStringWithTabs() throws Exception { 85 runFailTest("this has \t a tab"); 86 } 87 88 91 public void testStringWithLeadingSpaces() throws Exception { 92 runFailTest(" a failure case"); 93 } 94 95 98 public void testStringWithTrailingSpaces() throws Exception { 99 runFailTest("this is a "); 100 } 101 102 106 public void testStringWithLeadingAndTrailingSpaces() throws Exception { 107 runFailTest(" centered "); 108 } 109 110 113 public void testDoubleSpace() throws Exception { 114 runFailTest("a B"); } 116 117 120 public void testEmptyString() throws Exception { 121 runPassTest(""); 122 } 123 124 127 public void testNull() throws Exception { 128 runPassTest(null); 129 } 130 } 131 | Popular Tags |