1 23 24 29 package com.sun.enterprise.management.support; 30 31 import java.util.Map ; 32 33 import com.sun.appserv.management.util.misc.MapUtil; 34 35 36 38 public final class ParamNameMapperTest extends junit.framework.TestCase 39 { 40 public 41 ParamNameMapperTest( ) 42 { 43 } 44 45 public void 46 testCreate() 47 { 48 final ParamNameMapper m = new ParamNameMapper(); 49 } 50 51 public void 52 testEmpty() 53 { 54 final ParamNameMapper m = new ParamNameMapper(); 55 56 assertEquals( "", m.mangleAttributeName( "" ) ); 57 } 58 59 60 public void 61 testSingleLowerCaseWord() 62 { 63 final ParamNameMapper m = new ParamNameMapper(); 64 65 assertEquals( "hello", m.mangleAttributeName( "hello" ) ); 66 assertEquals( "hello_there", m.mangleAttributeName( "hello_there" ) ); 67 } 68 69 public void 70 testSingleLowerCaseLetter() 71 { 72 final ParamNameMapper m = new ParamNameMapper(); 73 74 assertEquals( "x", m.mangleAttributeName( "x" ) ); 75 } 76 77 public void 78 testSingleUpperCaseLetter() 79 { 80 final ParamNameMapper m = new ParamNameMapper(); 81 82 assertEquals( "x", m.mangleAttributeName( "X" ) ); 83 } 84 85 public void 86 testSingleAllUpperCaseWord() 87 { 88 final ParamNameMapper m = new ParamNameMapper(); 89 90 assertEquals( "hello", m.mangleAttributeName( "HELLO" ) ); 91 } 92 93 public void 94 testSingleUpperCaseWord() 95 { 96 final ParamNameMapper m = new ParamNameMapper(); 97 98 assertEquals( "hello", m.mangleAttributeName( "Hello" ) ); 99 } 100 101 public void 102 testMultipleLowerCaseWords() 103 { 104 final ParamNameMapper m = new ParamNameMapper(); 105 106 assertEquals( "hello-there-you", m.mangleAttributeName( "hello-there-you" ) ); 107 } 108 109 110 public void 111 testMultipleUpperCaseWords() 112 { 113 final ParamNameMapper m = new ParamNameMapper(); 114 115 assertEquals( "hello_there_you", m.mangleAttributeName( "HelloThereYou" ) ); 116 } 117 118 public void 119 testAcronyms1() 120 { 121 final ParamNameMapper m = new ParamNameMapper(); 122 123 assertEquals( "ssl_algorithm", m.mangleAttributeName( "SSLAlgorithm" ) ); 124 } 125 126 public void 127 testAcronyms2() 128 { 129 final ParamNameMapper m = new ParamNameMapper(); 130 131 assertEquals( "ssl_algorithm_enabled_today", 132 m.mangleAttributeName( "SSLAlgorithmEnabledToday" ) ); 133 } 134 135 public void 136 testAcronyms3() 137 { 138 final ParamNameMapper m = new ParamNameMapper(); 139 140 assertEquals( "ssl-tls-http-jndi_algorithm", 141 m.mangleAttributeName( "SSL-TLS-HTTP-JNDIAlgorithm" ) ); 142 } 143 144 145 public void 146 testOverrides() 147 { 148 final Map <String ,String > overrides = MapUtil.newMap( 149 new String [] 150 { 151 "SSLTLS", "ssl_tls", 152 "GOOFY", "THECLOWN", 153 } 154 ); 155 156 final ParamNameMapper m = new ParamNameMapper( overrides ); 157 158 assertEquals( "ssl_tls", m.mangleAttributeName( "SSLTLS" ) ); 159 assertEquals( "THECLOWN", m.mangleAttributeName( "GOOFY" ) ); 160 } 161 162 } 163 164 165 | Popular Tags |