directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r431163 - in /directory/branches/shared/0.9.5/ldap/src: main/java/org/apache/directory/shared/ldap/name/RdnParser.java test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Date Sun, 13 Aug 2006 11:41:44 GMT
Author: elecharny
Date: Sun Aug 13 04:41:43 2006
New Revision: 431163

URL: http://svn.apache.org/viewvc?rev=431163&view=rev
Log:
Fixed DIRSERVER_703. The upName was computed too early in the process, I just 
moved one line down in the parser (not totally randomly :)

Modified:
    directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
    directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
    directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java?rev=431163&r1=431162&r2=431163&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
Sun Aug 13 04:41:43 2006
@@ -259,6 +259,8 @@
      */
     private static String parseAttributeValue( String string, Position pos )
     {
+    	StringBuffer sb = new StringBuffer();
+    	
         char c = StringTools.charAt( string, pos.start );
         
         if ( c == '#' )
@@ -340,6 +342,18 @@
                     }
                     else
                     {
+                    	if ( nbChars == 1 ) 
+                    	{
+                    		sb.append( string.charAt( pos.end ) );
+                    	}
+                    	else 
+                    	{
+                    		byte b = (byte)((StringTools.HEX_VALUE[string.charAt( pos.end )] <<
4) +
+                    		StringTools.HEX_VALUE[string.charAt( pos.end + 1 )]);
+                    		
+                    		sb.append( b );
+                    	}
+                    	
                         pos.end += nbChars;
                     }
                 }
@@ -656,7 +670,6 @@
         if ( rdn != null )
         {
             rdn.addAttributeTypeAndValue( type, value );
-            rdn.setUpName( dn.substring( start, pos.end )  );
             rdn.normalizeString();
             
             pos.start = pos.end;
@@ -664,7 +677,8 @@
         }
 
         parseNameComponents( dn, pos, rdn );
-        
+
+        rdn.setUpName( dn.substring( start, pos.end )  );
         pos.start = pos.end;
         return DNUtils.PARSING_OK;
     }

Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=431163&r1=431162&r2=431163&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Sun Aug 13 04:41:43 2006
@@ -175,6 +175,20 @@
 
 
     /**
+    * Test to see if a DN with multiRdn values is preserved after an addAll.
+    */
+    public void testAddAllWithMultivaluedAttribute() throws InvalidNameException
+    {
+    	LdapDN dn = new LdapDN( "cn=Kate Bush+sn=Bush,ou=system" );
+        LdapDN target = new LdapDN();
+        target.addAll( target.size(), dn );
+        assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.toString() );
+        System.out.println( target.getUpName() );
+        assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.getUpName() );
+    }
+        
+
+    /**
      * test a simple DN with an oid prefix (uppercase) : OID.12.34.56 = azerty
      */
     public void testLdapDNOidUpper() throws InvalidNameException

Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java?rev=431163&r1=431162&r2=431163&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Sun Aug 13 04:41:43 2006
@@ -491,4 +491,10 @@
         Assert.assertEquals( "\\\\\\00-\\+\\#\\7F-", res );
     }
 
+    
+    public void testDIRSERVER_703() throws InvalidNameException 
+    {
+    	Rdn rdn = new Rdn( "cn=Kate Bush+sn=Bush" );
+    	assertEquals( "cn=Kate Bush+sn=Bush", rdn.getUpName() );
+	}
 }



Mime
View raw message