KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > util > dn > TestDnComponents


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.util.dn;
15
16 import junit.framework.TestCase;
17
18 import org.apache.log4j.Logger;
19 import org.ejbca.util.CertTools;
20
21
22 /**
23  * Tests the StringTools class .
24  *
25  * @version $Id: TestDnComponents.java,v 1.2 2006/12/04 12:09:10 anatom Exp $
26  */

27 public class TestDnComponents extends TestCase {
28     private static Logger log = Logger.getLogger(TestDnComponents.class);
29
30     /**
31      * Creates a new TestStringTools object.
32      *
33      * @param name name
34      */

35     public TestDnComponents(String JavaDoc name) {
36         super(name);
37     }
38
39     protected void setUp() throws Exception JavaDoc {
40         log.debug(">setUp()");
41         log.debug("<setUp()");
42     }
43
44     protected void tearDown() throws Exception JavaDoc {
45         log.debug(">tearDown()");
46         log.debug("<tearDown()");
47     }
48
49     /**
50      * tests stipping whitespace
51      *
52      * @throws Exception error
53      */

54     public void test01CheckObjects() throws Exception JavaDoc {
55         String JavaDoc[] s = DnComponents.getDnObjects();
56         assertEquals(21, s.length);
57         assertEquals("unstructuredaddress",s[0]);
58         assertEquals("unstructuredname",s[1]);
59         assertEquals("dn",s[5]);
60         assertEquals("uid",s[6]);
61         assertEquals("cn",s[7]);
62         assertEquals("t",s[14]);
63         assertEquals("c",s[20]);
64
65         String JavaDoc[] s1 = DnComponents.getDnObjectsReverse();
66         assertEquals(21, s1.length);
67         assertEquals("unstructuredaddress",s1[20]);
68         assertEquals("unstructuredname",s1[19]);
69         assertEquals("uid",s1[14]);
70         assertEquals("cn",s1[13]);
71         assertEquals("t",s1[6]);
72         assertEquals("c",s1[0]);
73
74         String JavaDoc[] s2 = DnComponents.getDnObjects();
75         assertEquals(21, s2.length);
76         assertEquals("unstructuredaddress",s2[0]);
77         assertEquals("unstructuredname",s2[1]);
78         assertEquals("uid",s2[6]);
79         assertEquals("cn",s2[7]);
80         assertEquals("t",s2[14]);
81         assertEquals("c",s2[20]);
82
83     }
84     public void test02() {
85         String JavaDoc dn = CertTools.stringToBCDNString("uri=fff,CN=oid,C=se");
86         System.out.println(dn);
87     }
88
89 }
90
Popular Tags