You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/09/27 08:58:21 UTC

svn commit: r291838 - /directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapRDNTest.java

Author: elecharny
Date: Mon Sep 26 23:58:17 2005
New Revision: 291838

URL: http://svn.apache.org/viewcvs?rev=291838&view=rev
Log:
Added the tests for LdapRDN

Added:
    directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapRDNTest.java

Added: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapRDNTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapRDNTest.java?rev=291838&view=auto
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapRDNTest.java (added)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapRDNTest.java Mon Sep 26 23:58:17 2005
@@ -0,0 +1,115 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.codec.primitives;
+
+import javax.naming.InvalidNameException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+
+/**
+ * Test the class LdapRDN
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapRDNTest extends TestCase
+{
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Setup the test
+     */
+    protected void setUp()
+    {
+    }
+
+    /**
+     * Test a null RDN
+     */
+    public void testLdapRDNNull()
+    {
+        try
+        {
+            new LdapRDN( null, null );
+            // Should never go further.
+        }
+        catch ( InvalidNameException ine )
+        {
+            Assert.assertTrue( true );
+        }
+    }
+
+    /**
+     * test a simple RDN : a = b
+     */
+    public void testLdapRDNSimple()  throws InvalidNameException
+    {
+        Assert.assertEquals( "a=b", new LdapRDN( "a ", " b" ).toString() );
+    }
+
+    /**
+     * test a composite RDN : a = b + c = d
+     */
+    public void testLdapRDNComposite()  throws InvalidNameException
+    {
+        LdapRDN rdn = new LdapRDN();
+        rdn.addNameComponent( "a ", " b" );
+        rdn.addNameComponent( " c ", " d " );
+        Assert.assertEquals( "a=b+c=d", rdn.toString() );
+    }
+
+    /**
+     * test a composite RDN : A = b + c = d with uppercase
+     */
+    public void testLdapRDNCompositeUpperCase() throws InvalidNameException
+    {
+        LdapRDN rdn = new LdapRDN();
+        rdn.addNameComponent( "A ", " b" );
+        rdn.addNameComponent( " c ", " d " );
+        Assert.assertEquals( "a=b+c=d", rdn.toString() );
+    }
+
+    /**
+     * test a simple DN with pair char attribute value : a = \,\=\+\<\>\#\;\\\"\A0\00"
+     */
+    public void testLdapRDNPairCharAttributeValue() throws InvalidNameException
+    {
+        Assert.assertEquals( "a=\\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00",
+                new LdapRDN( "a ", "   \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00   " ).toString() );
+    }
+
+    /**
+     * test a simple RDN with hexString attribute value : a = #0010A0AAFF
+     */
+    public void testLdapRDNHexStringAttributeValue()  throws InvalidNameException
+    {
+        Assert.assertEquals( "a=#0010A0AAFF",
+                new LdapRDN( "a", " #0010A0AAFF  " ).toString() );
+    }
+
+    /**
+     * test a simple RDN with quoted attribute value : a = "quoted \"value"
+     */
+    public void testLdapRDNQuotedAttributeValue() throws InvalidNameException
+    {
+        Assert.assertEquals( "a=quoted \\\"value",
+                new LdapRDN( "a ", " quoted \\\"value  " ).toString() );
+    }
+}