1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ldap.server.prefs;
18
19
20 import javax.naming.Name;
21 import javax.naming.NamingException;
22
23 import junit.framework.TestCase;
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: 264732 $
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
41 {
42
43
44 String test = "/org/apache/kerberos/";
45
46 Name dn = PreferencesUtils.toSysDn( test );
47
48 assertEquals( dn.toString(), "prefNodeName=kerberos,prefNodeName=apache,prefNodeName=org," + PreferencesUtils.SYSPREF_BASE );
49
50
51
52
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
63
64 test = "/";
65
66 dn = PreferencesUtils.toSysDn( test );
67
68 assertEquals( dn.toString(), PreferencesUtils.SYSPREF_BASE );
69
70
71
72
73
74 test = "//////";
75
76 dn = PreferencesUtils.toSysDn( test );
77
78 assertEquals( dn.toString(), PreferencesUtils.SYSPREF_BASE );
79
80 }
81 }