1 16 17 package test.types; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.types.NormalizedString; 21 22 25 public class TestNormalizedString extends TestCase { 26 27 public TestNormalizedString(String name) { 28 super(name); 29 } 30 31 34 private void runFailTest(String value) throws Exception { 35 NormalizedString oNormalizedString = null; 36 try { 37 oNormalizedString = new NormalizedString(value); 38 } 39 catch (Exception e) { } 41 assertNull("validation restriction failed [" + 43 value + "]. did not restrict bad value.", oNormalizedString); 44 } 45 46 49 private void runPassTest(String value) throws Exception { 50 NormalizedString oNormalizedString = null; 51 try { 52 oNormalizedString = new NormalizedString(value); 53 } 54 catch (Exception e) { } 56 assertEquals("normalized string not equal" + 57 value, oNormalizedString.toString(), value); 58 } 59 60 63 public void testNsSimpleString() throws Exception { 64 runPassTest("a simple string"); 65 } 66 67 70 public void testNsCarriageReturn() throws Exception { 71 runFailTest("this has \r carriage return"); 72 } 73 74 77 public void testNsLineFeed() throws Exception { 78 runFailTest("this has \n line feed"); 79 } 80 81 84 public void testNsStringWithTabs() throws Exception { 85 runFailTest("this has \t a tab"); 86 } 87 88 91 public void testNsStringWithLeadingSpaces() throws Exception { 92 runPassTest(" a failure case"); 93 } 94 95 98 public void testNsStringWithTrailingSpaces() throws Exception { 99 runPassTest("this is a "); 100 } 101 102 105 public void testNsStringWithLeadingAndTrailingSpaces() throws Exception { 106 runPassTest(" centered "); 107 } 108 109 112 public void testNsDoubleSpace() throws Exception { 113 runPassTest("a B"); } 115 } 116 | Popular Tags |