1 7 package org.jboss.test.xml; 8 9 import junit.framework.TestCase; 10 import org.jboss.xb.binding.Util; 11 12 18 public class XMLNameToJavaIdentifierUnitTestCase 19 extends TestCase 20 { 21 private static final String [] xmlNames = new String [] 22 { 23 "mixedCaseName", "Answer42", "name-with-dashes", "other_punct-chars", "one2three", "__-invalids-at-the-end---" 24 }; 25 26 private static final String [] clsNames = new String [] 27 { 28 "MixedCaseName", "Answer42", "NameWithDashes", "OtherPunctChars", "One2Three", "InvalidsAtTheEnd" 29 }; 30 31 private static final String [] clsNamesWithLowLines = new String [] 32 { 33 "MixedCaseName", "Answer42", "NameWithDashes", "Other_PunctChars", "One2Three", "__InvalidsAtTheEnd" 34 }; 35 36 private static final String [] getNames = new String [] 37 { 38 "getMixedCaseName", "getAnswer42", "getNameWithDashes", "getOtherPunctChars", "getOne2Three", "getInvalidsAtTheEnd" 39 }; 40 41 private static final String [] setNames = new String [] 42 { 43 "setMixedCaseName", "setAnswer42", "setNameWithDashes", "setOtherPunctChars", "setOne2Three", "setInvalidsAtTheEnd" 44 }; 45 46 private static final String [] constNames = new String [] 47 { 48 "MIXED_CASE_NAME", "ANSWER_42", "NAME_WITH_DASHES", "OTHER_PUNCT_CHARS", "ONE_2_THREE", "INVALIDS_AT_THE_END" 49 }; 50 51 public XMLNameToJavaIdentifierUnitTestCase(String localName) 52 { 53 super(localName); 54 } 55 56 public void testXmlNameToClassName() throws Exception 57 { 58 for(int i = 0; i < xmlNames.length; ++i) 59 { 60 String clsName = Util.xmlNameToClassName(xmlNames[i], true); 61 assertEquals(clsNames[i], clsName); 62 } 63 } 64 65 public void testXmlNameToClassNameWithLowLines() throws Exception 66 { 67 for(int i = 0; i < xmlNames.length; ++i) 68 { 69 String clsName = Util.xmlNameToClassName(xmlNames[i], false); 70 assertEquals(clsNamesWithLowLines[i], clsName); 71 } 72 } 73 74 public void testXmlNameToGetMethodName() throws Exception 75 { 76 for(int i = 0; i < xmlNames.length; ++i) 77 { 78 String clsName = Util.xmlNameToGetMethodName(xmlNames[i], true); 79 assertEquals(getNames[i], clsName); 80 } 81 } 82 83 public void testXmlNameToSetMethodName() throws Exception 84 { 85 for(int i = 0; i < xmlNames.length; ++i) 86 { 87 String clsName = Util.xmlNameToSetMethodName(xmlNames[i], true); 88 assertEquals(setNames[i], clsName); 89 } 90 } 91 92 public void testXmlNameToConstantName() throws Exception 93 { 94 for(int i = 0; i < xmlNames.length; ++i) 95 { 96 String clsName = Util.xmlNameToConstantName(xmlNames[i]); 97 assertEquals(constNames[i], clsName); 98 } 99 } 100 } 101 | Popular Tags |