KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > support > ParamNameMapperTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin/mbeanapi-impl/tests/com/sun/enterprise/management/support/ParamNameMapperTest.java,v 1.4 2006/03/09 20:30:59 llc Exp $
26  * $Revision: 1.4 $
27  * $Date: 2006/03/09 20:30:59 $
28  */

29 package com.sun.enterprise.management.support;
30
31 import java.util.Map JavaDoc;
32
33 import com.sun.appserv.management.util.misc.MapUtil;
34
35
36 /**
37  */

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 JavaDoc<String JavaDoc,String JavaDoc> overrides = MapUtil.newMap(
149             new String JavaDoc[]
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