KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > prefs > PreferencesUtilsTest


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.ldap.server.prefs;
18
19
20 import junit.framework.TestCase;
21
22 import javax.naming.Name JavaDoc;
23 import javax.naming.NamingException JavaDoc;
24
25
26 /**
27  * Test caseses for preference utility methods.
28  *
29  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
30  * @version $Rev$
31  */

32 public class PreferencesUtilsTest extends TestCase
33 {
34     /**
35      * Tests to confirm the toSysDn() method can translate an absolute
36      * preference node path into an LDAP distinguished name.
37      *
38      * @throws NamingException if there are problems transforming the name
39      */

40     public void testToSysDn() throws NamingException JavaDoc
41     {
42         // simple test
43

44         String JavaDoc test = "/org/apache/kerberos/";
45
46         Name JavaDoc dn = PreferencesUtils.toSysDn( test );
47
48         assertEquals( dn.toString(), "prefNodeName=kerberos,prefNodeName=apache,prefNodeName=org," + PreferencesUtils.SYSPREF_BASE );
49
50
51
52         // simple test without trailing '/'
53

54         test = "/org/apache/kerberos";
55
56         dn = PreferencesUtils.toSysDn( test );
57
58         assertEquals( dn.toString(), "prefNodeName=kerberos,prefNodeName=apache,prefNodeName=org," + PreferencesUtils.SYSPREF_BASE );
59
60
61
62         // basis condition tests
63

64         test = "/";
65
66         dn = PreferencesUtils.toSysDn( test );
67
68         assertEquals( dn.toString(), PreferencesUtils.SYSPREF_BASE );
69
70
71
72         // endpoint tests
73

74         test = "//////";
75
76         dn = PreferencesUtils.toSysDn( test );
77
78         assertEquals( dn.toString(), PreferencesUtils.SYSPREF_BASE );
79
80     }
81 }
82
Popular Tags