1 16 17 package test.types; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.types.NCName; 21 22 25 public class TestNCName extends TestCase { 26 27 28 public TestNCName(String name) { 29 super(name); 30 } 31 32 35 private void runFailTest(String value) throws Exception { 36 NCName oToken = null; 37 try { 38 oToken = new NCName(value); 39 } 40 catch (Exception e) { } 42 assertNull( 43 "NCName 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 NCName oToken = null; 52 try { 53 oToken = new NCName(value); 54 } 55 catch (Exception e) { } 57 assertEquals("NCName strings not equal. orig value:" + value, oToken.toString(), value); 58 } 59 60 63 public void testSimpleString() throws Exception { 64 runPassTest("Atlanta"); 65 } 66 67 70 public void testPunctuationString() throws Exception { 71 runPassTest("Atlanta_Braves.Home-Team10"); 72 } 73 74 75 78 public void testStartUnderscore() throws Exception { 79 runPassTest("_Braves"); 80 } 81 82 85 public void testMidColon() throws Exception { 86 runFailTest("Atlanta:_Braves.Home-Team10"); 87 } 88 89 92 public void testStartDigit() throws Exception { 93 runFailTest("1_Braves"); 94 } 95 96 97 100 public void testStartColon() throws Exception { 101 runFailTest(":_Braves.Home-Team:1"); 102 } 103 104 107 public void testLineFeed() throws Exception { 108 runFailTest("line one\n line two"); 109 } 110 111 114 public void testStringWithTabs() throws Exception { 115 runFailTest("this has \t a tab"); 116 } 117 118 121 public void testStringWithLeadingSpaces() throws Exception { 122 runFailTest(" a failure case"); 123 } 124 125 128 public void testStringWithTrailingSpaces() throws Exception { 129 runFailTest("this is a "); 130 } 131 132 136 public void testStringWithLeadingAndTrailingSpaces() throws Exception { 137 runFailTest(" centered "); 138 } 139 140 143 public void testDoubleSpace() throws Exception { 144 runFailTest("a B"); } 146 } 147 | Popular Tags |