directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r891807 - in /directory/shared/branches/shared-schema/ldap/src: main/java/org/apache/directory/shared/ldap/name/Rdn.java test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Date Thu, 17 Dec 2009 17:29:15 GMT
Author: elecharny
Date: Thu Dec 17 17:29:14 2009
New Revision: 891807

URL: http://svn.apache.org/viewvc?rev=891807&view=rev
Log:
Added a constructor for RDN( type, value ), and an associated test

Modified:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?rev=891807&r1=891806&r2=891807&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
Thu Dec 17 17:29:14 2009
@@ -26,7 +26,6 @@
 import java.io.ObjectOutput;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -253,6 +252,28 @@
 
 
     /**
+     * A constructor that constructs a RDN from a type and a value. Constructs
+     * an Rdn from the given attribute type and value. The string attribute
+     * values are not interpreted as RFC 2253 formatted RDN strings. That is,
+     * the values are used literally (not parsed) and assumed to be un-escaped.
+     *
+     * @param upType The user provided type of the RDN
+     * @param upValue The user provided value of the RDN
+     * @throws InvalidNameException If the RDN is invalid
+     */
+    public Rdn( String upType, String upValue ) throws InvalidNameException
+    {
+        addAttributeTypeAndValue( upType, upType, new ClientStringValue( upValue ), new ClientStringValue(
upValue ) );
+
+        upName = upType + '=' + upValue;
+        start = 0;
+        length = upName.length();
+        // create the internal normalized form
+        normalize();
+    }
+
+
+    /**
      * A constructor that constructs a RDN from a type, a position and a length.
      *
      * @param start The starting point for this RDN in the user provided DN

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java?rev=891807&r1=891806&r2=891807&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Thu Dec 17 17:29:14 2009
@@ -300,6 +300,20 @@
 
 
     /**
+     * Test teh creation of a new RDN
+     * 
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testRDNCreation() throws InvalidNameException
+    {
+        Rdn rdn = new Rdn( "A", "  b  " );
+        assertEquals( "a=\\  b \\ ", rdn.getNormName() );
+        assertEquals( "A=  b  ", rdn.getUpName() );
+    }
+
+
+    /**
      * Test the clone method for a RDN.
      * 
      * @throws InvalidNameException



Mime
View raw message